Repository navigation
Conversation
Strict OpenAI-compatible providers (e.g. vLLM, scnet) reject requests containing `tool_choice` without a corresponding `tools` array with HTTP 400. OpenClaw unconditionally injected `tool_choice` even when `tools` was correctly omitted, violating the OpenAI API spec. Two code paths are fixed: 1. WebSocket path (openai-ws-stream.ts): Guard `tool_choice` injection in `extraParams` with `tools.length > 0`. 2. HTTP path (extra-params.ts): Add a final `onPayload` wrapper (`createToolChoiceGuardWrapper`) that strips `tool_choice` and `parallel_tool_calls` from any openai-completions/openai-responses payload that lacks a non-empty `tools` array. Fixes openclaw#44110.
Greptile SummaryThis PR fixes a spec violation where The fix covers two code paths:
The wrapper ordering is correct: Test coverage is thorough — both paths are tested with absent tools, empty tools array, and non-empty tools array, and existing tests that rely on Confidence Score: 5/5
Last reviewed commit: 740b40d |
Use `parameters` instead of `inputSchema` to match the Tool<TSchema> type, and cast via `as unknown` to satisfy strict type checking.
When active-memory plugin invokes sub-agents with toolsAllow, the tools get filtered to [] in the embedded runner context. Strict OpenAI-compatible providers (DashScope/GLM, Kimi, vLLM) reject tools: [] with HTTP 400. Adds wrapStreamFnStripEmptyTools() as a payload interceptor that: - Strips tools entirely when array is empty - Strips tool_choice when tools is absent Consolidates openclaw#59898, openclaw#66710, openclaw#47947 into a single guard. Fixes openclaw#53174.
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. This PR should close as superseded by the newer open #70790, which explicitly consolidates this PR's empty-tools/tool_choice fix with related embedded-runner empty-tools work. Current main does not yet implement the full requested guard, and the WebSocket path has since been refactored, so the best path is to carry useful tests from this PR into the canonical follow-up rather than keep this stale partial PR open. Best possible solution: Close this stale partial PR as superseded by #70790, then review or revise the canonical PR against current main and carry over this PR's useful WebSocket and HTTP regression tests where they still apply. What I checked:
So I’m closing this here and keeping the remaining discussion on the canonical linked item. Codex review notes: model gpt-5.5, reasoning high; reviewed against 2ccdbc7dd93b. |
When active-memory plugin invokes sub-agents with toolsAllow, the tools get filtered to [] in the embedded runner context. Strict OpenAI-compatible providers (DashScope/GLM, Kimi, vLLM) reject tools: [] with HTTP 400. Adds wrapStreamFnStripEmptyTools() as a payload interceptor that: - Strips tools entirely when array is empty - Strips tool_choice when tools is absent Consolidates openclaw#59898, openclaw#66710, openclaw#47947 into a single guard. Fixes openclaw#53174.
Summary
Strict OpenAI-compatible providers (e.g. vLLM, scnet) reject requests containing
tool_choicewithout a correspondingtoolsarray with HTTP 400. OpenClaw unconditionally injectedtool_choice: "auto"even whentoolswas correctly omitted, violating the OpenAI API spec.Two code paths are fixed:
openai-ws-stream.ts): Guardtool_choiceinjection inextraParamswithtools.length > 0extra-params.ts): Add a finalonPayloadwrapper (createToolChoiceGuardWrapper) that stripstool_choiceandparallel_tool_callsfrom anyopenai-completions/openai-responsespayload that lacks a non-emptytoolsarrayRoot cause
This produced payloads like
{"model":"...","messages":[...],"tool_choice":"auto"}(notoolsfield), which strict providers reject.Reproduction
Test plan
tool_choiceis omitted when tools are emptytool_choiceIS forwarded when tools are presenttool_choicestripping (absent tools, empty tools array, non-empty tools)parallel_tool_callsis also stripped when tools absentparallel_tool_callsand Moonshottool_choicetests to include tools in payloads (since the guard now strips them when tools are absent)openai-ws-stream.test.ts+pi-embedded-runner-extraparams.test.ts)Fixes #44110.