Let the Realtime conversation continue while client tool calls are pending #772
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.89) × (1 − Review Confidence (0.71)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.89 · 915 lines diff across 17 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.51 · 2 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 10%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.400
No Reviewer Assigned
no_reviewer_assigned
0.120
Mass File Touch
mass_file_touch
0.080
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
3 items
Checklist against the expected behavior in #760. 5 of 6 are met. One is met with a caveat.
call_id. A second output for the same call is now an error. Covered by test_multiple_pending_calls_resolve_out_of_order and test_duplicate_result_for_one_call_is_rejected.two scenario (two parallel calls, one result, a follow up while the other is still pending), which passed on chat-completions gpt-4.1, responses-api gpt-4.1 and responses-api gpt-5.4-mini.cohere/north-mini-code still repeated the call in 5 of 6 runs.TemplateError: Only user and assistant roles are supported, with the exception of an initial optional system message!, the helper folds it, and the rendered prompt contains the note. The API retry path (a provider answering 400) has only run against fake providers so far. The handler stays in folded mode only after the retry succeeds, so an unrelated 400 does not change it.Not covered by the issue but worth knowing: placing the note as a system message is a design choice. Folding it into the user message helped the Cohere model (2 of 6 repeats) but made gpt-4o on the Responses API repeat the call in 3 of 4 runs, so I kept the system message.
Addressed in #829, thank you for your help here!
<img src="https://static.klipy.com/ii/35ccce3d852f7995dd2da910f2abd795/c4/c9/2s2mPpE5.gif"/>
omkar-334
Description
I removed the guards that rejected
response.createand local model generation while a client function call had no output yet. The conversation can now continue on an unrelated turn while a slow tool is running, and the result is accepted whenever it arrives.Fixes #760.
Brief
Dropping the guard alone is not enough, and I hit both problems when I tried it:
1. A call without its output is invalid for most providers, so a pending call cannot go into the model request.
2. Once the call is left out, the model no longer knows the tool is running. It calls it again. Without any hint, the tool was re-issued in 47 of 48 runs across 6 OpenAI models and both backends.
So a pending call is left out of the request, and the request ends with a short system note naming the tools that are still running (name and arguments only, no call ids). It tells the model not to call them again, not to guess their results, and to answer the latest message even if it is about something else. The note exists only on the request and never enters the stored history.
I tried it in the system prompt first.
gpt-4.1-ministill re-issued the call in 4 of 6 runs there, and 0 of 6 when the note is the last message, so it goes last.Changes
api/openai_realtime/handlers/response.py: remove thefunction_call_output_pendingadmission check.LLM/language_model.pyandLLM/base_openai_compatible_language_model.py: remove the three "Cannot generate a response while function call outputs are pending" guards.LLM/chat.py:-
Chat.pending_tool_calls_notice()builds the note.- A second
function_call_outputfor the samecall_idis now an error. Results are accepted once, in any order.- A result that arrives after a later user turn was already answered is serialized where it arrived (its call and any reasoning prefix move with it). Otherwise it stays next to its call, as before. Without this the next response repeated an answer.
- When one parallel call is pending and another is finished, the finished call and its output are kept.
chat_completions_language_model.py,responses_api_language_model.py,language_model.py: append the note as the last message.api/openai_realtime/README.md: new "Pending tool calls" section.Testing
Unit tests:
tests/openai_realtime/test_pending_tool_calls.py(continued conversation, multiple pending calls resolved out of order, late result after an unrelated turn, duplicate result, result arriving mid response, cancel, failed response, barge-in, prefetch waiting for the last call, a websocket reproduction of the sequence in the issue) andtests/test_pending_notice_fallback.py. The existing tests that asserted the old rejection were updated. I checked that the first ten of these fail when the old guards are put back. Full suite, ruff and mypy pass.Live checks, not included in the PR:
nvidia/nemotron-3.5-lightningon OpenRouter: 8 of 8.Note
cohere/north-mini-codeon OpenRouter re-issued the call in 5 of 6 runs with the note (6 of 6 without it). Folding the note into the last user message cut that to 2 of 6 for that model, but made gpt-4o on the Responses API repeat the call in 3 of 4 runs, so the system message stays the default. I did not add a setting for the placement.function_call_outputused to be accepted silently and is now an error.gpt-audiomodels reject the existing text only warmup. That was already the case and I did not touch it.