fix: approve every tool call from a multi-call turn in ask mode (#31315)

In "Ask for approval" mode, when the model requested several tools in one turn, only the first call got an approval card. The others stayed on "Executing..." forever, never ran, could not be approved (the server answered "already resolved"), and the model was called again without their results. The stuck state was saved to the chat.

Once streaming finishes, every call in the turn is marked as completed (arguments done, nothing run yet). The approval pause only queued siblings that were still in progress, so these were skipped. They are now queued as well, and each one gets its own approval card in turn after the previous one is resolved.

Calls that already have a result and rejected calls are untouched, and single-call turns behave as before. Verified against the real approval functions with same-name, mixed-name, reject and ask_user batches, plus the tests-repo unit suite (identical results before and after).

Fixes #29293
This commit is contained in:
Classic298 2026-09-27 21:14:30 +02:00 • committed by GitHub
parent b91a558c9d
commit 35dda256f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3605,7 +3605,7 @@ async def pause_for_tool_approval(chat_id: str, message_id: str, output: list[di
if not has_pending_approval:
item['status'] = 'pending'
has_pending_approval = True
elif item.get('status') == 'in_progress':
elif item.get('status') in {'in_progress', 'completed'}:
item['status'] = 'queued'
await Chats.upsert_message_to_chat_by_id_and_message_id(