relay: emit streamed tool metadata only once - #6706
Conversation
Keep Responses-to-Chat argument continuation chunks keyed by index without repeating the call ID, type, or function name. This prevents clients from treating long streamed arguments as duplicate tool calls. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe change emits tool-call ID and type only on the first streamed chunk. Empty ChangesTool-call streaming
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@relaykit/relayconvert/internal/oai_responses/to_oai_chat_resp_test.go`:
- Around line 284-295: Expand the continuation-chunk regression tests around the
single-tool and parallel-tool paths: assert each continuation’s Index and
Function.Arguments values in addition to omitted metadata. Add interleaved
argument-delta events for both parallel output indexes, then verify each emitted
chunk retains the correct per-tool index and arguments while still omitting ID,
Type, and Function.Name.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a8cc2d84-57a1-4226-b7d1-90b7dc8096dd
📒 Files selected for processing (3)
relaykit/dto/openai_response.gorelaykit/relayconvert/internal/oai_responses/to_oai_chat_resp_test.gorelaykit/relayconvert/internal/oai_responses/to_oai_chat_stream_resp.go
|
Additional real-world context: I encountered this while using GPT-5.6 Luna through NewAPI's ChatCompletions-to-Responses compatibility mode in WorkBuddy. A After applying this patch, I repeated the same WorkBuddy test with a large |
Assert argument deltas retain the correct tool index when parallel calls are interleaved, while continuation metadata remains omitted. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
id,type, and functionnameonly on the first Responses-to-Chat tool-call chunkindexwith argument deltas onlytypefield instead of serializing it asnullWhy
The Responses-to-Chat streaming converter currently repeats the same call ID and type on every function-argument delta. Although the chunks keep the same tool index, some OpenAI-compatible clients interpret each repeated ID as a new tool call. For a large tool payload, one logical call can therefore become many calls; only the first fragment has a function name and later fragments fail as unnamed tools.
This is distinct from the duplicate-index issue fixed in #6225: the tool index is stable, but call metadata is still repeated on every continuation chunk.
OpenAI-style streaming only needs the call metadata on the initial chunk. Subsequent chunks can safely contain the stable index and argument delta.
Validation
cd relaykit && GOMAXPROCS=2 go test -p 2 ./...Summary by CodeRabbit
Bug Fixes
Tests