Skip to content

fix(prompt): preserve streamed tool-call identity and arguments - #2272

Open
kyboi wants to merge 2 commits into
JetBrains:developfrom
Kreoh:contribute/openai-responses-tool-identity
Open

kyboi wants to merge 2 commits into
JetBrains:developfrom
Kreoh:contribute/openai-responses-tool-identity

Conversation

@kyboi

@kyboi kyboi commented Sep 29, 2026 •

Copy link
Copy Markdown

Streaming tool calls can lose their identity or complete before their arguments finish. Responses deltas use an output item ID while completion uses a call ID; the shared stream builder also splits interleaved A/B/A/B chunks into four incomplete calls.

Map Responses item IDs to call IDs and names, with state isolated per collection. In the shared builder, retain pending calls by index or ID, fill in late identity fields, and emit complete calls in first-seen order at the existing flush boundaries. Starting another call no longer completes the previous one. Ambiguous anonymous continuations and conflicting identities are rejected.

The underlying fixes are already included in Kroog and working in production applications using Kroog: Responses identity and interleaved calls. This adaptation adds per-collection isolation to the Responses fix and keeps the builder's atomic-reference structure with an immutable pending-call list rather than importing Kroog's mutex. Responses request construction now occurs on collection. No dependencies or public signatures change.

Credit to Jewoo Shin (@jewoodev) for identifying and testing late-arriving IDs in #2134. This implementation also covers that case, and its regression test credits that PR. We tested #2134 unchanged: it fixes late IDs but still fails interleaving. Maintainers can merge this PR directly, or merge #2134 first and we can rebase this PR while retaining its regression coverage. No commit from #2134 is included here.

Validation: the interleaving and late-ID regressions fail before the builder change and pass afterwards. All 27 builder tests pass. Full JVM suites: prompt-model 200 passed with three existing ignored Markdown tests; OpenAI client 210 passed with no skips. Both modules' JVM JAR, ktlint and publication metadata checks pass, and compiled JVM ABIs exactly match their checked-in dumps. Responses regressions also cover cancelled recollection. Repository-wide, live-provider, simultaneous-emitter and non-JVM validation were not run.

Closes #2271.

@kyboi kyboi changed the title fix(openai): preserve Responses streaming tool identity fix(prompt): preserve streamed tool-call identity and arguments Sep 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streaming tool calls have inconsistent identity or complete prematurely

1 participant