fix(api): classify failed tool stream events

(cherry picked from commit 5ab0a5ee26e61d4e96d65e1dacdc2b2e1e524f1b)
This commit is contained in:
luyifan
2026-07-24 11:13:40 +08:00
committed by kshitij
parent 6c9f61efed
commit 5af9ac8ed1
3 changed files with 39 additions and 2 deletions

View File

@@ -3465,7 +3465,12 @@ class APIServerAdapter(OpenAICompatRoutesMixin, BasePlatformAdapter):
if event_type == "reasoning.available":
events.enqueue("tool.progress", {"message_id": message_id, "tool_name": tool_name or "_thinking", "delta": preview or ""})
elif event_type in {"tool.started", "tool.completed", "tool.failed"}:
events.enqueue(event_type, {"message_id": message_id, "tool_name": tool_name, "preview": preview, "args": args})
event_name = (
"tool.failed"
if event_type == "tool.completed" and kwargs.get("is_error")
else event_type
)
events.enqueue(event_name, {"message_id": message_id, "tool_name": tool_name, "preview": preview, "args": args})
def _commentary(text: str, *, already_streamed: bool = False) -> None:
# Mid-turn assistant commentary (Codex ``phase="commentary"``, text beside tool calls)