fix(routing/proxy): emit finish_reason: tool_calls when tool call pre… - #2773
Open
crashf wants to merge 2 commits into
Open
fix(routing/proxy): emit finish_reason: tool_calls when tool call pre…#2773crashf wants to merge 2 commits into
crashf wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…cedes empty completion GPT/Codex streaming can emit `response.output_item.added` with a `function_call` before `response.completed`, whose `output` array is empty. Previously the adapter only checked `output` for function_call items, producing `finish_reason: stop` and causing the client to end the turn prematurely. - Track `sawToolCall` in `ReasoningStreamState` - Set `sawToolCall = true` on `response.output_item.added` function_call - In `handleCompletedEvent`, use `hasFunctionCalls || sawToolCall` to decide `finish_reason` - Add regression tests for empty-completion + tool-call, text-only completion, and normal function-call completion Fixes the "GPT no-respond / stops after one tool call" symptom in streaming mode.
crashf
force-pushed
the
fix/chatgpt-adapter-tool-call-finish-reason
branch
from
August 27, 2026 15:47
f2a798f to
10436f1
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2773 +/- ##
=======================================
Coverage 96.50% 96.50%
=======================================
Files 604 604
Lines 36048 36050 +2
Branches 10081 10083 +2
=======================================
+ Hits 34788 34790 +2
Misses 702 702
Partials 558 558
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…cedes empty completion
GPT/Codex streaming can emit
response.output_item.addedwith afunction_callbeforeresponse.completed, whoseoutputarray is empty. Previously the adapter only checkedoutputfor function_call items, producingfinish_reason: stopand causing the client to end the turn prematurely.sawToolCallinReasoningStreamStatesawToolCall = trueonresponse.output_item.addedfunction_callhandleCompletedEvent, usehasFunctionCalls || sawToolCallto decidefinish_reasonFixes the "GPT no-respond / stops after one tool call" symptom in streaming mode.
Summary by cubic
Fixes the ChatGPT/Codex streaming adapter emitting
finish_reason: stopwhen a tool call precedes an emptyresponse.completedoutput, which made clients end the turn before running the tool. The adapter now emitsfinish_reason: tool_callswhen anyfunction_callwas streamed, even if the completed event's output is empty.response.output_item.addedevents.finish_reason.Written for commit f2a798f. Summary will update on new commits.