fix(discuss): hard-fail empty articles and skip RAG on seed turn
Discuss flow was hallucinating unrelated content when article extraction returned empty or RAG pulled in orphan notes that looked more relevant than the generic seed prompt. - seed_article_discussion raises EmptyArticleError on empty body; briefing and /news routes return 422 instead of staging an empty synthetic tool result. - build_context skips RAG auto-injection when user_message matches ARTICLE_DISCUSS_SEED so the article IS the context on turn one; follow-up turns keep RAG on. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -537,10 +537,16 @@ async def discuss_article(item_id: int):
|
||||
# exchange and the conversational seed user prompt into the conversation.
|
||||
# The /news from-article route calls the same helper so behavior stays
|
||||
# byte-identical across entry points.
|
||||
from fabledassistant.services.article_context import seed_article_discussion
|
||||
from fabledassistant.services.article_context import (
|
||||
EmptyArticleError,
|
||||
seed_article_discussion,
|
||||
)
|
||||
|
||||
model = await get_setting(uid, "default_model", "") or ""
|
||||
discuss_prompt = await seed_article_discussion(conv_id, item, model)
|
||||
try:
|
||||
discuss_prompt = await seed_article_discussion(conv_id, item, model)
|
||||
except EmptyArticleError as e:
|
||||
return jsonify({"error": str(e)}), 422
|
||||
|
||||
# Reload conversation with fresh messages to build history
|
||||
conv = await get_conversation(uid, conv_id)
|
||||
|
||||
Reference in New Issue
Block a user