mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-07-28 05:12:26 +00:00
fix: force synthesis when agent returns empty content after tool calls
When the model returns no tool calls and no content (common with Qwen 3.5 thinking mode), inject a synthesis prompt to get the final report. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
9255fdf7f3
commit
54cf71dd9a
@@ -152,7 +152,30 @@ class DeepResearchAgent(ToolUsingAgent):
|
||||
|
||||
# No tool calls -- this is the final answer
|
||||
if not tool_calls_raw:
|
||||
# If content is empty but we have prior tool results,
|
||||
# force one more generation without tools to synthesize
|
||||
if not content.strip() and all_tool_results:
|
||||
messages.append(
|
||||
Message(role=Role.ASSISTANT, content=content)
|
||||
)
|
||||
messages.append(
|
||||
Message(
|
||||
role=Role.USER,
|
||||
content=(
|
||||
"Please write your final research report "
|
||||
"based on everything you found. Cite sources."
|
||||
),
|
||||
)
|
||||
)
|
||||
synth = self._generate(messages)
|
||||
content = synth.get("content", "")
|
||||
u = synth.get("usage", {})
|
||||
for k in total_usage:
|
||||
total_usage[k] += u.get(k, 0)
|
||||
|
||||
self._emit_turn_end(turns=turns)
|
||||
sources = self._extract_sources(all_tool_results)
|
||||
total_usage["sources"] = sources
|
||||
return AgentResult(
|
||||
content=content,
|
||||
tool_results=all_tool_results,
|
||||
|
||||
Reference in New Issue
Block a user