Fix a bug where tool_result messages must appear before text in user messages

This commit is contained in:
Leiber Lyu
2026-05-31 14:29:41 +10:00
parent 5c955480ee
commit 3fe4b128b5
5 changed files with 9 additions and 14 deletions

View File

@@ -1872,10 +1872,9 @@ def prepare_context(messages: list) -> list:
def build_user_content(results: list[dict]) -> list[dict]:
# Tool results and completed background notifications are both returned to
# the model as user-side content, matching the tool_result feedback loop.
content = []
content = list(results)
for note in collect_background_results():
content.append({"type": "text", "text": note})
content.extend(results)
return content