fix(openai-chat): let opted-out providers pin parallel_tool_calls:false - #1662
Conversation
When a provider sets parallelToolCalls:false, the wire bit parallel_tool_calls:false is only sent for the NVIDIA NIM baseUrl; every other opted-out openai-chat provider silently OMITS the field. That is the right default for strict OpenAI-compatible hosts that reject unknown knobs, but self-hosted gateways (Kimi/GLM-family, vLLM, etc.) that DO honor the field keep emitting concurrent tool calls in one streamed turn because they never receive it. Add an opt-in provider flag pinParallelToolCallsFalse that pins the wire bit for such gateways without hardcoding their URL. Default behavior is unchanged: the field is still omitted for every existing opted-out provider (the NVIDIA hardcode and the omit-by-default path are both preserved), and the flag has no effect unless parallelToolCalls === false. Fixes lidge-jun#1650
|
✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe change adds ChangesParallel tool-call pinning
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change enables opted-in providers to send parallel_tool_calls:false while preserving existing defaults; no actionable merge-blocking risk remains after normal checks and review. Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 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 |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request has been marked Ready for Review. |
|
Thanks for this. The provider-level opt-in is useful because it fixes a real compatibility gap without changing the safe default for every OpenAI-compatible backend. Gateways that need |
What
Add an opt-in provider flag
pinParallelToolCallsFalseso an opted-outopenai-chatprovider can actually sendparallel_tool_calls: falseon thewire, instead of silently omitting it.
Fixes #1650.
Why
In
src/adapters/openai-chat.ts, whenprovider.parallelToolCalls === falsethewire bit
parallel_tool_calls: falseis only emitted for the NVIDIA NIMbaseUrl. Every other opted-out provider omits the field entirely. For strictOpenAI-compatible hosts that reject unknown fields this omit-by-default is
correct. But self-hosted gateways in the Kimi/GLM family (and vLLM-style
backends) do honor
parallel_tool_callsand, without it, keep emittingmultiple concurrent tool calls in a single streamed turn -- which the Responses
translator then has to reject.
parallelToolCalls: falselooks like the opt-outfor this, but today it is a no-op for those providers.
Design / why opt-in
The omit-by-default behavior is deliberate and covered by existing tests
(
tests/parallel-tool-calls-optin.test.ts: afalseprovider must NOT emit thefield). Sending
parallel_tool_calls: falseunconditionally would break thosestrict hosts, so the wire bit stays gated:
pinParallelToolCallsFalse: true.parallelToolCalls === false.Default behavior for every existing provider is unchanged.
Changes
src/types.ts: add documented optionalpinParallelToolCallsFalse?: booleantoOcxProviderConfig.src/adapters/openai-chat.ts: OR the new flag into the existing NVIDIA-baseUrl condition that pins the wire bit.tests/parallel-tool-calls-optin.test.ts: cover pinned-false emits the bit, keeps emitting under a permissive request bit, and is a no-op withoutparallelToolCalls:false.Testing
bun x tsc --noEmitclean on top ofdev.bun testforparallel-tool-calls-optin,openai-chat-hardening,openai-chat-parallel-stream,chat-completions-endpoint: 126 pass, 0 fail (includes 3 new cases). Existing omit-by-default assertions still pass.Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit
New Features
parallel_tool_calls: falsewhen parallel tool calls are disabled.Bug Fixes