mirror of
https://github.com/shareAI-lab/analysis_claude_code.git
synced 2026-06-20 20:23:36 +08:00
Fix a bug where tool_result messages must appear before text in user messages
This commit is contained in:
@@ -887,13 +887,12 @@ def agent_loop(messages: list, context: dict):
|
||||
"tool_use_id": block.id,
|
||||
"content": output})
|
||||
|
||||
# Merge background notifications + tool results into one user message
|
||||
user_content = []
|
||||
# Merge background tool results + notifications into one user message
|
||||
user_content = list(results)
|
||||
bg_notifications = collect_background_results()
|
||||
if bg_notifications:
|
||||
for notif in bg_notifications:
|
||||
user_content.append({"type": "text", "text": notif})
|
||||
user_content.extend(results)
|
||||
messages.append({"role": "user", "content": user_content})
|
||||
context = update_context(context, messages)
|
||||
system = get_system_prompt(context)
|
||||
|
||||
Reference in New Issue
Block a user