From b3cf42863ab773dd11240a2322bec192d095f771 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 7 Apr 2026 12:45:08 -0400 Subject: [PATCH] fix: reinforce no-project-inference in system prompt; filter tool messages from title generation --- src/fabledassistant/services/generation_task.py | 7 +++++-- src/fabledassistant/services/llm.py | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/fabledassistant/services/generation_task.py b/src/fabledassistant/services/generation_task.py index 83fdad3..5a63b9a 100644 --- a/src/fabledassistant/services/generation_task.py +++ b/src/fabledassistant/services/generation_task.py @@ -122,10 +122,13 @@ async def _generate_title(messages: list[dict], user_id: int) -> str: # Build conversation text like summarize_conversation_as_note conv_lines = [] for m in messages: - if m["role"] == "system": + if m["role"] in ("system", "tool"): continue label = "User" if m["role"] == "user" else "Assistant" - conv_lines.append(f"{label}: {m['content']}") + content = m.get("content", "") + if not content: + continue + conv_lines.append(f"{label}: {content}") # Keep only last 6 pairs worth of text conv_lines = conv_lines[-12:] diff --git a/src/fabledassistant/services/llm.py b/src/fabledassistant/services/llm.py index 178e501..d1872e5 100644 --- a/src/fabledassistant/services/llm.py +++ b/src/fabledassistant/services/llm.py @@ -538,6 +538,11 @@ async def build_context( "Delete tools require an explicit user request. " "Never proactively search notes or comment on absent context." ) + tool_lines.append( + "IMPORTANT: When creating tasks or notes, NEVER infer or guess a project name. " + "Only set the project parameter if the user explicitly names a project. " + "If the user says 'create a task to buy milk', do NOT assign it to a project." + ) tool_guidance = "\n".join(tool_lines) static_block = (