Keep the conversation going while tool calls are running #829
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
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.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #829"
general
weight: 0.35
jackboyla
Problem
A tool that has not returned blocks the conversation: any turn that arrives while a function call output is missing is rejected with "Cannot generate a response while function call outputs are pending." The user keeps talking and nothing answers. Related: #772, #805.
What changes
A running tool no longer blocks a turn. Stored history is unchanged, and other clients need no change. The one wire-visible change is that a second result for the same call is now rejected.
response.createis still rejected withfunction_call_output_pendingin one case: an incomplete parallel batch with no user speech since.function_call_outputfor a call that already has one is rejected withinvalid_conversation_item(invalid_input_itemasresponse.createinput);mainaccepted it and showed the model both.talk,local) no longer holds a result behind a slower tool from an earlier turn. Results of one response are still delivered in call order with one follow-up; responses do not wait for each other. A follow-up the server holds back leaves the results queued for the next one instead of stopping the client. If more results were queued before that refusal arrived, the client asks once more.The README's "Long-running tools" section describes this, and adds the start-and-notify pattern (return a handle at once, report the outcome later as a marked message) as the approach to prefer when the client controls the tool.
Why this design
Each choice was compared against an alternative on live models. "Correct" below means the reply did what the situation called for and nothing else: answered an unrelated question without calling a tool, did not invent a result for a running call, called a newly requested tool, announced a result that landed, and so on.
Keep the call as a real tool call, with a stand-in result. The alternative in #805's fallback path rewrites tool calls as user-role text records. Keeping the structure the models were trained on does better, mostly on small models, and repeats running calls far less often:
| 23 models, 1 to 4 tools running, 8 situations, 2,001 requests per arm | This PR | This PR without the status line | #805 fallback rewrite |
|---|---|---|---|
| Correct (repeated a running call) | 96% (1%) | 94% (2%) | 88% (8%) |
| 12 large models | 98% (0%) | 96% (1%) | 99% (0%) |
| 11 small models | 94% (2%) | 91% (4%) | 77% (17%) |
Only #805's fallback rewrite was compared, since it is the path that applies to Chat Completions and local backends; its native-async path needs provider support and was not tested.
Nothing changes when tools return in time. The stand-in and the status line exist only while a call has no output. With every result in before the next reply, the request is identical to
main(checked by rendering finished-tool conversations with both versions of the code). Apps whose tools all return at once are unaffected.A late result is a marked message where it arrived, not a tool message. Chat templates expect a tool result directly after its call, and by then the model has already replied to later turns, so moving the result back would rewrite history it answered from. Showing it where it arrived keeps earlier requests stable. Two independent implementations use the same shape: Pipecat's async tools (a "still running" tool result, replaced if the result arrives before the conversation moves on, otherwise a later message) and the
[background event, not said by the user]messages that voice clients built on this server already send.The status line is what keeps several running calls straight. Stand-ins sit next to their calls, which can be many turns back. With one call running the line makes no difference (96% with, 97% without); with more it does:
| Tools running | With the line | Without |
|---|---|---|
| 2 | 95% (2% repeats) | 91% (4%) |
| 3 | 97% (1%) | 94% (3%) |
| 4 | 97% (0%) | 92% (2%) |
| "Is the other one ready?" after one of several finished | 96% (3%) | 78% (17%) |
The line follows the newest user message instead of ending the request: when a request ended with a fresh tool result, two small models answered the status line instead of relaying the result (93% correct at the end, 97% after the user message). A late result is shown in the user role but does not take the line either: the line stays with what the user last said.
One rejection is kept on purpose. A client that asks for a follow-up after every result of a parallel batch would otherwise get one reply per result. With the batch still incomplete and nothing new from the user, the request is refused as on
main; once the user speaks, the reply goes through with stand-ins for the missing results (99% correct on the parallel-batch situations). An image on its own is not the user speaking, whether it arrives before or after the result.Further checks
033619cc.Models: Qwen3.8-2.4T, Qwen3.8-27B, Gemma 4 31B, DeepSeek-V4.1-Flash, DeepSeek-V4-Pro, Kimi-K3.1-Pro, GLM-5.3, MiniMax-M3.1-Flash, Mistral-Large-4, Muse-Spark-Open, Nemotron-3.5-Super, Hy4-preview; small: LFM3-1.7B, Ling-3.0-tiny, granite-4.2-3b, granite-4.2-8b, Qwen3.5-9B, LFM2.5-24B, Nemotron-3.5-Lightning, Gemma 4 26B, Inkling-Small, Qwen3.8-Flash-Next, Muse-Glimmer-30B. All through Hugging Face inference providers.
Known limits
[End of tool result]when the user's words follow it in the same message.maintests pin.Not in this PR