Repository navigation
Description
Bug type
Regression (worked before, now fails)
Beta release blocker
No
Summary
When using any Ollama Cloud model (e.g. ollama/glm-5.2:cloud), the first agent turn succeeds (model returns a tool call, tool executes). The second turn — where OpenClaw sends conversation history including the previous tool call back to the provider — fails with:
400 json: cannot unmarshal object into Go struct field .messages.tool_calls.function.arguments of type string
OpenClaw sends tool_calls.function.arguments as a JSON object instead of a string. The OpenAI API spec requires a string. Ollama's Go server enforces this strictly and rejects the request.
This is a regression introduced in 2026.6.9. Version 2026.6.8 does not exhibit this bug with the same config and same model.
Steps to reproduce
- Configure ollama/glm-5.2:cloud as primary model (OpenClaw 2026.6.9 or 2026.6.10)
- Send a message that triggers a tool call: "What is config.gateway.port? Use the config tool to check."
- First turn succeeds — model returns tool call, OpenClaw executes the config.get tool
- Second turn fails with 400 — OpenClaw sends the tool call history back with arguments as a JSON object
Expected behavior
tool_calls.function.arguments should be sent as a JSON string per the OpenAI API spec. This is what 2026.6.8 does correctly.
Actual behavior
tool_calls.function.arguments is sent as a JSON object, causing Ollama's Go server to reject with 400.
OpenClaw version
OpenClaw 2026.6.9
Operating system
MacOS 26.5.1
Install method
npm global
Model
Ollama GLM-5.2 Cloud (also confirmed: Ollama GLM-5.1 Cloud, Ollama MiniMax M3 Cloud — all Ollama Cloud models affected)
Provider / routing chain
openclaw → ollama (localhost:11434) → ollama cloud proxy
Additional provider/model setup details
Local Ollama 0.30.10, but :cloud models proxy through Ollama's cloud servers so local version is irrelevant. The error is returned by Ollama's cloud-side Go server, not the local instance.
Non-Ollama providers work fine: zhipu-ai/glm-5.2 (same GLM-5.2 model, direct from Z.ai API) succeeds on the second turn with tool calls. This suggests Ollama's Go server is stricter about enforcing the OpenAI spec (string-only for arguments) while other providers accept both string and object.
Root cause hypothesis: In openai-completions-vbhA-xck.js, line 917 does arguments: JSON.stringify(tc.arguments) which should produce a string. However, the wire payload has an object. Something between this stringify and the HTTP request — possibly in the OpenAI SDK v6.39.1 or a provider-specific adapter — is re-parsing the string back to an object. This code path worked correctly in 2026.6.8.
Related issue: #69735 (inverse problem — arguments not deserialized from string to object on the response side). The fix direction for that issue may have introduced this regression.
Logs, screenshots, and evidence
### HTTP interceptor capture
A local HTTP proxy between OpenClaw and Ollama captured the actual request body on the failing second turn:
msg[4].tool_calls[0]: name=gateway, type=dict, value={"action": "config.get", "path": "gateway.port"}
type=dict proves arguments is a JSON object on the wire, not a string.
### Cross-version comparison (same config, same model)
| OpenClaw Version | Provider | Model | Tool call 2nd turn |
|---|---|---|---|
| 2026.6.8 | ollama (cloud) | glm-5.2:cloud | ✅ Works |
| 2026.6.9 | ollama (cloud) | glm-5.2:cloud | ❌ 400 |
| 2026.6.10 | ollama (cloud) | glm-5.2:cloud | ❌ 400 |
| 2026.6.10 | ollama (cloud) | glm-5.1:cloud | ❌ 400 |
| 2026.6.10 | ollama (cloud) | minimax-m3:cloud | ❌ 400 |
| 2026.6.10 | zhipu-ai (direct) | glm-5.2 | ✅ Works |
The error hash is identical across all Ollama Cloud models: sha256:4c32d4487e51
### Gateway log (error)
2026-06-24T12:28:54.613+01:00 warn agent/embedded {"event":"embedded_run_agent_end","isError":true,"error":"LLM request failed: provider rejected the request schema or tool payload.","failoverReason":"format","model":"glm-5.2:cloud","provider":"ollama","rawErrorPreview":"400 json: cannot unmarshal object into Go struct field .messages.tool_calls.function.arguments of type string","rawErrorHash":"sha256:4c32d4487e51","providerRuntimeFailureKind":"schema"}Impact and severity
Affected: All Ollama Cloud model users who use tool calls (config.get, exec, read, write, etc.)
Severity: High — tool calls silently fail on the second turn, making the agent unable to perform any tool-based operation beyond a single turn
Frequency: 100% of multi-turn conversations involving tool calls with Ollama Cloud models
Consequence: Agent cannot perform config queries, file operations, or any tool-based task that requires sending conversation history back to the provider. Only simple non-tool messages work.
Additional information
- Workaround: Roll back to 2026.6.8, or use a non-Ollama provider (e.g. zhipu-ai) for tool-calling conversations
- Simple messages (no tool calls) work fine on all versions including 2026.6.10
- The CLI version on PATH was 2026.6.6 (Hermes bundled) while gateway was 2026.6.9/10 — this is a separate issue but worth noting the version mismatch warning that appears in logs
- Ollama was updated from 0.24.0 to 0.30.10 during testing — did not resolve the issue (as expected, since :cloud models proxy through Ollama's cloud servers not the local instance)
Not a duplicate of #46679, #50689, or #57103. Those issues (March 2026, all closed) reported the inverse problem: OpenClaw sent arguments as a JSON string when the Ollama NATIVE API (/api/chat) expected an object. The fix for those issues (JSON.parse string → object) overcorrected and broke the OpenAI-COMPATIBLE API path (/v1/chat/completions), which per the OpenAI spec requires arguments as a string. This bug affects api: "openai-completions", not api: "ollama" (native).
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 24, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 24, 2026, 9:43 AM ET / 13:43 UTC.
Summary
Keep open: current main and the latest release still apply native-Ollama object normalization to OpenAI-compatible Ollama payloads, matching the reporter's captured 400 on second-turn tool-call replay.
Reproducibility: yes. source-level reproduction is high confidence: the issue provides a captured failing payload and current code shows the Ollama OpenAI-compatible wrapper converting string tool-call arguments back to objects before send. I did not run a live Ollama Cloud credential test in this read-only pass.
Root-cause cluster
Relationship:
canonicalCanonical: #96441
Summary: This issue is the canonical remaining report for the OpenAI-compatible Ollama Cloud inverse of earlier native Ollama string/object replay bugs.
Members:
same_root_cause: fix: deserialize string tool-call arguments before sending to Ollama #52253 - The merged PR added the string-to-object replay normalization hook that now appears over-applied to OpenAI-compatible Ollama payloads.partial_overlap: [Bug]:Ollama tool_call arguments not deserialized — tool invocations lose parameters #69735 - It covered the opposite direction, deserializing Ollama tool-call arguments for downstream/native handling, and is already closed.partial_overlap: Ollama native API: tool_calls arguments sent as JSON string breaks multi-turn tool calling #46679 - It covered native/api/chatexpecting object arguments, not the OpenAI-compatible Cloud path expecting strings.partial_overlap: Ollama tool call arguments serialized as string instead of object — breaks tool loop #50689 - It reported the native Ollama object-argument replay failure later fixed by the same normalization family.partial_overlap: [bug]: Under the Ollama native provider, the arguments of the tool call are incorrectly stringified when returned, leading to a gradual failure or confusion of parameters in multi-turn tool calling. #57103 - It was closed as implemented for native and prior OpenAI-compatible normalization, but this issue supplies newer evidence that Cloud Chat Completions rejects the object form.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step
This is a narrow provider payload-shape repair with a clear code path, clear regression tests, and no product decision blocker.
Review details
Best possible solution:
Split the Ollama native and OpenAI-compatible replay contracts: keep object coercion only for native
/api/chat, and preserve string arguments for Ollama Cloud/OpenAI-compatible Chat Completions while retainingnum_ctxinjection.Do we have a high-confidence way to reproduce the issue?
Yes, source-level reproduction is high confidence: the issue provides a captured failing payload and current code shows the Ollama OpenAI-compatible wrapper converting string tool-call arguments back to objects before send. I did not run a live Ollama Cloud credential test in this read-only pass.
Is this the best way to solve the issue?
Yes, the best fix is narrow: stop applying native Ollama object coercion to OpenAI-compatible Chat Completions payloads, and add regression coverage proving both API contracts remain distinct.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
/api/chatobject arguments for the closed inverse Ollama issues while keeping/v1/chat/completionsarguments as strings.Codex review notes: model internal, reasoning high; reviewed against f0be8e7b6ee8.
Label changes
Label changes:
P1: This is a reported latest-release regression that breaks multi-turn tool use for Ollama Cloud users after the first tool call.impact:session-state: The failure is in replaying prior assistant tool-call history back into the next model turn.impact:auth-provider: The affected surface is provider-specific Ollama Cloud/OpenAI-compatible request shaping.issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.clawsweeper:queueable-fix: Current issue advisory state selects this label.clawsweeper:fix-shape-clear: Current issue advisory state selects this label.Label justifications:
P1: This is a reported latest-release regression that breaks multi-turn tool use for Ollama Cloud users after the first tool call.impact:session-state: The failure is in replaying prior assistant tool-call history back into the next model turn.impact:auth-provider: The affected surface is provider-specific Ollama Cloud/OpenAI-compatible request shaping.Evidence reviewed
Acceptance criteria:
What I checked:
tool_calls[0].function.argumentsas a dict/object and the provider returningcannot unmarshal object ... of type string.function.arguments: JSON.stringify(tc.arguments), so the OpenAI-compatible base payload starts as a string. (src/llm/providers/openai-completions.ts:1084, f0be8e7b6ee8)wrapOllamaCompatNumCtxruns throughstreamWithPayloadPatch, injectsnum_ctx, and then callsnormalizeOllamaCompatMessageToolArgson the outgoing payload before the underlying sender uses it. (extensions/ollama/src/stream.ts:250, f0be8e7b6ee8)normalizeOllamaCompatMessageToolArgswalksmessages[*].function_call.argumentsandmessages[*].tool_calls[*].function.arguments, replacing each value withensureArgsObject(...), which parses JSON strings into objects. (extensions/ollama/src/stream.ts:739, f0be8e7b6ee8)normalizeOllamaCompatMessageToolArgsfrom the OpenAI-compatible wrapper and still coercestool_calls[*].function.argumentsthroughensureArgsObject, so this is not fixed by the latest release. (extensions/ollama/src/stream.ts:773, aa69b12d0086)function.argumentsand legacyfunction_call.argumentsas strings in JSON format.Likely related people:
extensions/ollama/src/stream.ts)extensions/ollama/src/stream.ts)extensions/ollama/src/stream.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.fix(ollama): preserve tool_calls arguments as JSON strings in OpenAI-…
fix(ollama): keep tool_calls.function.arguments as JSON string on out…