Repository navigation
fix(ollama): Ollama Cloud tool calls fail after first turn - #96473
harjothkhara wants to merge 2 commits into
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. This branch is a correct-looking duplicate candidate for the Ollama Cloud second-turn tool-call regression, but #96474 now owns the same production fix with positive captured HTTP-path proof and a clean live mergeability check. 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 consolidating any desired tests first, then close duplicate candidate paths for the same Ollama Cloud regression. 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 consolidating any desired tests first, then close duplicate candidate paths for the same Ollama Cloud regression. Do we have a high-confidence way to reproduce the issue? Yes. The linked issue provides a captured failing Ollama Cloud payload and current source shows the OpenAI-compatible wrapper converting Chat Completions string arguments back into objects before send. Is this the best way to solve the issue? No as a landing branch. The code shape is the narrow fix, but #96474 is the better canonical path because it carries the same production deletion with positive captured HTTP-path proof. Security review: Security review cleared: The diff only removes Ollama TypeScript runtime payload mutation and adds tests; it does not touch dependencies, workflows, secrets, permissions, packaging, or code-execution infrastructure. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against f29dbd3ebd1c. |
|
ClawSweeper applied the proposed close for this PR.
|
Closes #96441
What Problem This Solves
Fixes an issue where users running Ollama Cloud models with tools would complete the first tool call but fail on the next turn when OpenClaw replayed the prior assistant tool call back through the OpenAI-compatible Chat Completions path.
The failure showed up as Ollama rejecting the request with
400 json: cannot unmarshal object into Go struct field .messages.tool_calls.function.arguments of type string.Why This Change Was Made
OpenAI-compatible Chat Completions payloads require assistant tool-call and legacy function-call
argumentsto remain JSON strings. The Ollama OpenAI-compatiblenum_ctxwrapper now only injectsoptions.num_ctxand no longer applies the native Ollama/api/chatobject-argument normalization to replayed Chat Completions messages.Native Ollama response/request argument parsing remains separate and still handles object arguments for the native API path.
User Impact
Ollama Cloud users can continue multi-turn tool-calling conversations after the first tool call instead of hitting a provider schema error on replay. Native Ollama
/api/chatbehavior is unchanged.Evidence
Duplicate/competing PR check:
96441across all states returned no PRs before branching.Real behavior proof:
createConfiguredOllamaCompatStreamWrapperapplies its patches.tool_calls[*].function.argumentsand legacyfunction_call.argumentsas JSON strings through the Ollama OpenAI-compatible wrapper.options.num_ctx.Validation commands:
node scripts/run-vitest.mjs extensions/ollama/src/stream-runtime.test.ts— 1 file, 101 tests passed.node scripts/run-vitest.mjs extensions/ollama/src/stream.test.ts extensions/ollama/src/stream-runtime.test.ts— 2 files, 116 tests passed.node scripts/run-vitest.mjs extensions/ollama/index.test.ts extensions/ollama/src/stream.test.ts extensions/ollama/src/stream-runtime.test.ts— 3 files, 173 tests passed..agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --parallel-tests "node scripts/run-vitest.mjs extensions/ollama/index.test.ts extensions/ollama/src/stream.test.ts extensions/ollama/src/stream-runtime.test.ts"— clean, no accepted/actionable findings; tests exited 0.AI assistance disclosure:
openaiChat Completions types), tests, and autoreview output before opening.