You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some OpenAI-compatible providers omit response.output_item.done and rely on response.completed.output for authoritative function-call arguments. If that terminal item differed only in whether its optional item id was present, the parser looked up the pending call by the terminal item ID, skipped reconciliation, and emitted the partial streamed arguments instead.
What Changes
Completed-response reconciliation now admits a pending function call by its stable call_id, then delegates to the existing onOutputItemDone finalizer.
Stream
Result
Stable item ID
Final arguments reconcile as before
Terminal item ID omitted
Final arguments replace the partial buffer
Unseen terminal call
Still ignored
Reused or colliding protocol identities
Not supported
The existing provider test now omits the terminal item ID while asserting authoritative arguments and first-admission metadata. No parser state or identity maps were added.
Scope
This preserves the existing optional-ID compatibility behavior without attempting to interpret protocol-invalid identity reuse or collisions.
Verification
cd packages/ai
bun run test
bun typecheck
git diff --check origin/v2
927 tests passed, 25 skipped, 0 failed.
Both AI typecheck configurations passed.
The pre-push hook passed all 33 workspace typecheck tasks.
Closing this after rechecking it against current v2, the Responses contract, and recorded OpenAI/Azure streams. Conforming argument events require both item_id and output_index to identify the same output item throughout its lifecycle; output indexes and call_ids cannot be reused within a response. A function-call item id may be absent, but when present it must remain stable and unique. ID-less calls complete through item-level events using their stable call_id, which current v2 already handles.
The remaining diff primarily retains history for reused or colliding item IDs and output indexes. Those streams violate the identity/lifecycle contract and become inherently ambiguous, so four additional identity maps and 300+ lines of adversarial tests are not justified.
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
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.
Why
Some OpenAI-compatible providers omit
response.output_item.doneand rely onresponse.completed.outputfor authoritative function-call arguments. If that terminal item differed only in whether its optional itemidwas present, the parser looked up the pending call by the terminal item ID, skipped reconciliation, and emitted the partial streamed arguments instead.What Changes
Completed-response reconciliation now admits a pending function call by its stable
call_id, then delegates to the existingonOutputItemDonefinalizer.The existing provider test now omits the terminal item ID while asserting authoritative arguments and first-admission metadata. No parser state or identity maps were added.
Scope
This preserves the existing optional-ID compatibility behavior without attempting to interpret protocol-invalid identity reuse or collisions.
Verification