feat(journal): LLM tools (record_moment, search_journal) + system prompt wiring

- services/tools/journal.py — record_moment + search_journal tool handlers
- services/tools/_registry.py: add `journal` flag on ToolDef + tool() decorator
- get_tools_for_user(user_id, conversation_type='chat'|'journal') —
  exclude journal-only tools from chat sessions; exclude set_rag_scope
  from journal sessions
- services/tools/__init__.py: register the new journal module; drop the
  unused get_briefing_tools export
- services/llm.py build_context: short-circuit for journal conversations,
  using journal_pipeline.build_journal_system_prompt and skipping all
  notes-RAG injection (preserves the journal/notes isolation invariant)
- services/generation_task.py: pass conversation_type into get_tools_for_user

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-25 22:39:42 -04:00
parent d9ab538ef4
commit ac188c40a5
5 changed files with 203 additions and 18 deletions
@@ -254,8 +254,15 @@ async def run_generation(
buf.append_event("status", {"status": "Building context..."})
# Phase 1: Resolve the tools list for this user.
tools = await get_tools_for_user(user_id)
# Phase 1: Resolve the tools list for this user, scoped to conversation type.
from fabledassistant.models import async_session as _async_session
from fabledassistant.models.conversation import Conversation as _Conversation
async with _async_session() as _sess:
_conv = await _sess.get(_Conversation, conv_id)
_conversation_type = (
_conv.conversation_type if _conv and _conv.conversation_type else "chat"
)
tools = await get_tools_for_user(user_id, conversation_type=_conversation_type)
logger.info(
"Starting generation for conv %d: model=%s, tools=%d",