diff --git a/src/fabledassistant/services/generation_task.py b/src/fabledassistant/services/generation_task.py index 7d60407..a74bd76 100644 --- a/src/fabledassistant/services/generation_task.py +++ b/src/fabledassistant/services/generation_task.py @@ -527,9 +527,22 @@ async def run_generation( should_gen_title = not conv_title or (msg_count > 0 and msg_count % 10 == 0) if should_gen_title: - title_messages = messages + [ - {"role": "assistant", "content": buf.content_so_far} + # Feed the title model the *raw* conversation turns only — never + # the post-build_context ``messages`` list. ``build_context`` + # prepends RAG snippets, RSS excerpts, URL content, and briefing + # article dumps INTO the user message string itself, so filtering + # by role="user" downstream still surfaces that noise as the + # "user's message". That pollution caused wildly-wrong titles + # (bug #109) — the small background model was staring at article + # excerpts instead of what the user actually typed. Pass the + # original history + the raw user_content + the assistant reply. + title_messages: list[dict] = [ + {"role": m["role"], "content": m.get("content") or ""} + for m in history + if m.get("role") in ("user", "assistant") ] + title_messages.append({"role": "user", "content": user_content}) + title_messages.append({"role": "assistant", "content": buf.content_so_far}) async def _bg_title() -> None: try: