Repository navigation
fix(ollama): keep OpenAI-compatible tool_call arguments as strings - #97355
moguangyu5-design wants to merge 0 commit into
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close: this PR is a later duplicate of the same Ollama Cloud/OpenAI-compatible tool-call argument regression already owned by the older, open, cleanly mergeable, proof-positive canonical PR at #96474. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Land #96474 as the proof-positive canonical fix, optionally port any desired assertion from this PR there, then close duplicate candidate branches. So I’m closing this here and keeping the remaining discussion on #96474. Review detailsBest possible solution: Land #96474 as the proof-positive canonical fix, optionally port any desired assertion from this PR there, then close duplicate candidate branches. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main stringifies Chat Completions tool-call arguments and then the Ollama compat wrapper parses them back into objects, matching the linked issue's captured second-turn 400 payload shape. Is this the best way to solve the issue? No as a landing branch. The code direction is right, but #96474 is the better solution path because it has the same production deletion plus captured SDK HTTP-path proof and native sibling coverage. Security review: Security review cleared: The diff only changes Ollama TypeScript payload shaping and tests; it adds no dependency, workflow, secret, permission, package, or supply-chain surface. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 08d15ec32db3. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
1900405 to
2c7e989
Compare
What Problem This Solves
Fixes #96441. When using Ollama Cloud models via the OpenAI-compatible endpoint (e.g.
ollama/glm-5.2:cloud), the second agent turn fails with:OpenClaw converts assistant
tool_calls.function.argumentsback from a JSON string into an object when injecting thenum_ctxoption. The OpenAI API spec requiresargumentsto be a string, and Ollama Cloud's Go server enforces that strictly.Why This Change Was Made
The generic OpenAI-completions formatter already stringifies
tool_calls.function.arguments. The Ollama-compatnum_ctxwrapper was the only place that re-parsed those strings into objects, which regressed in 2026.6.9. Removing that normalization restores spec-compliant behavior for OpenAI-compatible Ollama endpoints while leaving the native/api/chatpath untouched (it still objectifies arguments as required by Ollama's native format).User Impact
Users of Ollama Cloud models can now have multi-turn conversations that include tool calls without hitting a 400 error on the second turn.
Evidence
extensions/ollama/src/stream-runtime.test.tsthat passes an assistant message with stringifiedtool_calls.function.argumentsthroughcreateConfiguredOllamaCompatStreamWrapperand asserts the arguments stay a string.extensions/ollama/src/stream-runtime.test.tsandextensions/ollama/src/stream.test.ts): 117 tests pass.oxlinton the changed files: 0 warnings, 0 errors.oxfmton the changed files.