mirror of
https://github.com/shareAI-lab/analysis_claude_code.git
synced 2026-06-21 04:33:36 +08:00
Merge pull request #330 from Leiber-CivilComEngineer/fix-400-error-in-s13-background-tasks
fix 400 error in s13_background_tasks
This commit is contained in:
@@ -444,15 +444,14 @@ def agent_loop(messages: list, context: dict):
|
|||||||
"tool_use_id": block.id,
|
"tool_use_id": block.id,
|
||||||
"content": output})
|
"content": output})
|
||||||
|
|
||||||
# Inject background notifications + tool results in one user message
|
# Inject tool results + background notifications in one user message
|
||||||
user_content = []
|
user_content = list(results)
|
||||||
bg_notifications = collect_background_results()
|
bg_notifications = collect_background_results()
|
||||||
if bg_notifications:
|
if bg_notifications:
|
||||||
for notif in bg_notifications:
|
for notif in bg_notifications:
|
||||||
user_content.append({"type": "text", "text": notif})
|
user_content.append({"type": "text", "text": notif})
|
||||||
print(f" \033[32m[inject] {len(bg_notifications)} background "
|
print(f" \033[32m[inject] {len(bg_notifications)} background "
|
||||||
f"notification(s)\033[0m")
|
f"notification(s)\033[0m")
|
||||||
user_content.extend(results)
|
|
||||||
messages.append({"role": "user", "content": user_content})
|
messages.append({"role": "user", "content": user_content})
|
||||||
context = update_context(context, messages)
|
context = update_context(context, messages)
|
||||||
system = get_system_prompt(context)
|
system = get_system_prompt(context)
|
||||||
|
|||||||
@@ -726,13 +726,12 @@ def agent_loop(messages: list, context: dict) -> dict:
|
|||||||
"tool_use_id": block.id,
|
"tool_use_id": block.id,
|
||||||
"content": output})
|
"content": output})
|
||||||
|
|
||||||
# Merge background notifications + tool results into one user message
|
# Merge background tool results + notifications into one user message
|
||||||
user_content = []
|
user_content = list(results)
|
||||||
bg_notifications = collect_background_results()
|
bg_notifications = collect_background_results()
|
||||||
if bg_notifications:
|
if bg_notifications:
|
||||||
for notif in bg_notifications:
|
for notif in bg_notifications:
|
||||||
user_content.append({"type": "text", "text": notif})
|
user_content.append({"type": "text", "text": notif})
|
||||||
user_content.extend(results)
|
|
||||||
messages.append({"role": "user", "content": user_content})
|
messages.append({"role": "user", "content": user_content})
|
||||||
context = update_context(context, messages)
|
context = update_context(context, messages)
|
||||||
system = get_system_prompt(context)
|
system = get_system_prompt(context)
|
||||||
|
|||||||
@@ -887,13 +887,12 @@ def agent_loop(messages: list, context: dict):
|
|||||||
"tool_use_id": block.id,
|
"tool_use_id": block.id,
|
||||||
"content": output})
|
"content": output})
|
||||||
|
|
||||||
# Merge background notifications + tool results into one user message
|
# Merge background tool results + notifications into one user message
|
||||||
user_content = []
|
user_content = list(results)
|
||||||
bg_notifications = collect_background_results()
|
bg_notifications = collect_background_results()
|
||||||
if bg_notifications:
|
if bg_notifications:
|
||||||
for notif in bg_notifications:
|
for notif in bg_notifications:
|
||||||
user_content.append({"type": "text", "text": notif})
|
user_content.append({"type": "text", "text": notif})
|
||||||
user_content.extend(results)
|
|
||||||
messages.append({"role": "user", "content": user_content})
|
messages.append({"role": "user", "content": user_content})
|
||||||
context = update_context(context, messages)
|
context = update_context(context, messages)
|
||||||
system = get_system_prompt(context)
|
system = get_system_prompt(context)
|
||||||
|
|||||||
@@ -839,13 +839,12 @@ def agent_loop(messages: list, context: dict):
|
|||||||
"tool_use_id": block.id,
|
"tool_use_id": block.id,
|
||||||
"content": output})
|
"content": output})
|
||||||
|
|
||||||
# Merge background notifications + tool results into one user message
|
# Merge background tool results + notifications into one user message
|
||||||
user_content = []
|
user_content = list(results)
|
||||||
bg_notifications = collect_background_results()
|
bg_notifications = collect_background_results()
|
||||||
if bg_notifications:
|
if bg_notifications:
|
||||||
for notif in bg_notifications:
|
for notif in bg_notifications:
|
||||||
user_content.append({"type": "text", "text": notif})
|
user_content.append({"type": "text", "text": notif})
|
||||||
user_content.extend(results)
|
|
||||||
messages.append({"role": "user", "content": user_content})
|
messages.append({"role": "user", "content": user_content})
|
||||||
context = update_context(context, messages)
|
context = update_context(context, messages)
|
||||||
system = get_system_prompt(context)
|
system = get_system_prompt(context)
|
||||||
|
|||||||
@@ -1872,10 +1872,9 @@ def prepare_context(messages: list) -> list:
|
|||||||
def build_user_content(results: list[dict]) -> list[dict]:
|
def build_user_content(results: list[dict]) -> list[dict]:
|
||||||
# Tool results and completed background notifications are both returned to
|
# Tool results and completed background notifications are both returned to
|
||||||
# the model as user-side content, matching the tool_result feedback loop.
|
# the model as user-side content, matching the tool_result feedback loop.
|
||||||
content = []
|
content = list(results)
|
||||||
for note in collect_background_results():
|
for note in collect_background_results():
|
||||||
content.append({"type": "text", "text": note})
|
content.append({"type": "text", "text": note})
|
||||||
content.extend(results)
|
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user