Skip to content

fix(ollama): stop dropping free-form object tool arguments - #157564

Merged
obviyus merged 5 commits into
openclaw:mainfrom
Hmache:fix/ollama-freeform-tool-args
Sep 25, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
Hmache:fix/ollama-freeform-tool-args

Conversation

@Hmache

@Hmache Hmache commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #157039
Supersedes #157435.

What Problem This Solves

Fixes: native Ollama tool calls lose free-form object arguments, causing Tool Search dispatch to fail repeatedly.

User Impact

User impact: free-form tool input survives native Ollama schema conversion, including nested Tool Search arguments. Closed objects and the root object fallback keep their existing behavior. No configuration changes are required.

Why This Change Was Made

The request normalizer added properties: {} to open objects. Keep the repair in the Ollama request producer, preserving explicitly open objects, pattern-based records, and nested objects with implicit additional properties. The extracted inference and recursive normalization logic is unchanged apart from the empty-properties predicate. The Tool Search transport regression now uses the actual id plus nested args response contract.

Evidence

Real Ollama inference through the built Gateway

Tested head 1071871aa7a9105862e381737071cf2eb0774789 against Ollama 0.34.4, qwen2.5:3b, in a throwaway CPU-only Docker container (8 CPUs, 8 GiB, loopback-only port). Image digest: sha256:8262851b2846b87c649eddf3e76beb270c52f4d1bc94559f47efde16b0841551. A transparent loopback recording proxy forwarded requests and streamed responses unchanged; unlike the fixture below, it generated no model responses. A registered plugin tool recorded its received arguments independently.

Same prompt on both sides:

Use proof_record exactly once now. Set payload to this JSON object exactly, preserving all keys and values: {"message":"OLLAMA_PROOF_OK","count":7}. After recording it, reply DONE. Do not just describe the tool call.

Side / attempt Actual outcome
Main normalizer / 1 Gateway timed out at 300.821 s, no tool execution. The upstream model eventually returned populated arguments after the Gateway deadline; this is not counted as a successful turn.
Main normalizer / 2 After setting num_thread: 8 to match the container CPU quota, real tool call delivered {"payload":{"count":7,"message":"OLLAMA_PROOF_OK"}}; final DONE, 192.372 s.
Main normalizer / 3 Same populated tool arguments; final DONE, 3.411 s.
PR / 1 Same populated tool arguments; final DONE, 3.475 s.
PR / 2 Same populated tool arguments; final DONE, 3.250 s.
PR / 3 Same populated tool arguments; final DONE, 3.208 s.

Scope: the real model emitted tool calls on both sides. Qwen2.5 3B did not reproduce the reporter's empty-argument inference behavior: both successful baseline turns preserved the payload despite the injected empty property map. The candidate's three successful real inference turns establish after-fix compatibility and actual tool execution, not a live red/green reproduction of that model-specific failure. The source/schema regression and deterministic Tool Search red/green comparison below remain separate evidence.

Observed native wire excerpt (description omitted only for brevity):

{
  "before_payload_schema": {"type":"object","additionalProperties":true,"properties":{}},
  "after_payload_schema": {"type":"object","additionalProperties":true},
  "real_after_tool_calls": [
    {"id":"call_7fdun0ne","function":{"name":"proof_record","arguments":{"payload":{"count":7,"message":"OLLAMA_PROOF_OK"}}}},
    {"id":"call_l5jkfqoy","function":{"name":"proof_record","arguments":{"payload":{"count":7,"message":"OLLAMA_PROOF_OK"}}}},
    {"id":"call_d2fnvsic","function":{"name":"proof_record","arguments":{"payload":{"count":7,"message":"OLLAMA_PROOF_OK"}}}}
  ],
  "tool_received_each_time": {"payload":{"count":7,"message":"OLLAMA_PROOF_OK"}},
  "gateway_each_after_turn": {"status":"ok","assistantTurns":2,"toolSummary":{"calls":1,"tools":["proof_record"],"failures":0},"final":"DONE"}
}

Deterministic Tool Search regression and closed-object control

A built Gateway was exercised through node openclaw.mjs agent --agent main --message ... --json, using isolated state and a loopback native /api/chat NDJSON fixture. The baseline used the main normalizer in the otherwise identical candidate checkout, then the candidate normalizer was restored and rebuilt. The fixture records the exact request and models the reporter's schema-sensitive response: it emits empty nested arguments only when the request gained properties: {}. This section is deterministic Gateway/transport/tool-dispatch proof, separate from the real inference runs above.

Scenario Observed result
Main normalizer, Tool Search Wire args schema gained properties: {}. Three tool_call responses carried args: {}; all three failed target-input validation with command: must have required property 'command'. Four provider requests, no successful tool execution. The fixture then ended the bounded reproduction.
Fixed normalizer, Tool Search Wire args retained patternProperties: {"^.*$": {}} with no properties. Response {id: "openclaw:core:exec", args: {command: "printf OLLAMA_PROOF_OK"}} reached the dispatcher; real exec returned OLLAMA_PROOF_OK, exit code 0. Two provider requests, one successful dispatch, final OLLAMA_PROOF_COMPLETE.
Closed-object negative control, before and after A registered plugin tool with additionalProperties: false, required string value, and declared properties received {value: "OLLAMA_PROOF_OK"} in both runs. Serialized schemas were identical; both turns completed in two provider requests.

Focused command: node scripts/run-vitest.mjs extensions/ollama/src/tool-schema.runtime.test.ts extensions/ollama/src/tool-schema.transport.test.ts extensions/ollama/src/stream-runtime.test.ts --maxWorkers=1: 203 passed, 16.83 seconds wall including preparation. With the main normalizer restored, the two schema regression files produced 6 failures and 3 passes: free-form cases failed on injected empty properties, while root fallback, closed-object, and recursive normalization controls passed. The isolated runtime build (scripts/build-all.mts gatewayWatch) passed.

The transport fixture makes no claim to test model inference. Its assertions protect the outgoing schema and parsed nested argument contract; the Gateway exercise separately verifies real dispatch and tool execution.

After merging current main for the unrelated build repair, all four Ollama files remained unchanged. At 1071871aa7a9105862e381737071cf2eb0774789, the focused suite again passed 203 tests (22.96 seconds wall), the built Gateway again completed the Tool Search/exec turn in two provider requests with one successful dispatch, and the runtime build passed.

normalizeOllamaToolSchema always added an empty `properties: {}` to any
object-typed tool schema, including free-form schemas that declare
`additionalProperties: true` or `patternProperties` (TypeBox's
Type.Record()) and intentionally have no fixed properties. Ollama reads
the resulting closed-looking schema and returns `{}` for tool_call.args,
so tools like exec, and every Tool Search `tool_call` dispatch, silently
lose their arguments.

Only inject `properties: {}` when the schema is not free-form. Move
normalizeOllamaToolSchema and its inferOllamaSchemaType helper into a
sibling extensions/ollama/src/tool-schema.runtime.ts module with focused
unit tests plus a real-transport loopback test, since stream.runtime.ts
and stream-runtime.test.ts are already over the line-cap ratchet.

Squashed from openclaw#157435.

Closes openclaw#157039

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FfpR5spYH3ffvwiPCmJtkg
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 24, 2026, 8:41 PM ET / September 25, 2026, 00:41 UTC (Revision 4).

ClawSweeper review

What this changes

The Ollama plugin now preserves free-form object tool parameters in native chat requests and adds schema and transport regression coverage.

Merge readiness

✅ Ready for maintainer review

Current main and the latest release still contain the reported Ollama schema behavior. This PR remains a useful, focused fix; the updated proof now shows populated arguments reaching a registered tool through a real Ollama server on the reviewed head.

Priority: P1
Reviewed head: 1071871aa7a9105862e381737071cf2eb0774789

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused patch now has real after-fix Ollama execution proof and meaningful boundary regressions, with no actionable defect found.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The changed Ollama request normalizer feeds the built Gateway’s native chat path. The captured PR body reports three real Ollama 0.34.4 turns on this head with populated arguments received by a registered tool, plus a separate deterministic before/after Tool Search dispatch comparison. That model also succeeded on baseline, so the real runs establish after-fix execution rather than a live red/green reproduction. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed Ollama request normalizer feeds the built Gateway’s native chat path. The captured PR body reports three real Ollama 0.34.4 turns on this head with populated arguments received by a registered tool, plus a separate deterministic before/after Tool Search dispatch comparison. That model also succeeded on baseline, so the real runs establish after-fix execution rather than a live red/green reproduction. No stored-data contract changes.
Evidence reviewed 8 items Current main still needs the fix: The current-main normalizer adds an empty properties map to every object schema without declared properties, including the reported free-form shape.
Latest release has the same behavior: The v2026.9.6 source retains the empty-properties insertion; the fix is not already shipped there.
Introduced repair: The introduced predicate preserves open and pattern-based object schemas while retaining the root fallback; the stream calls this normalizer when serializing tool parameters.
Findings None None.
Security None None.

How this fits together

OpenClaw sends agent tool definitions through its Ollama plugin to Ollama’s native chat API. The plugin parses returned tool calls before OpenClaw dispatches them to tools.

flowchart LR
  A[Agent tool definitions] --> B[Ollama plugin]
  B --> C{Free-form object?}
  C -->|Yes| D[Preserve open schema]
  C -->|No| E[Normalize closed schema]
  D --> F[Native Ollama chat]
  E --> F
  F --> G[Parsed tool call]
  G --> H[Tool dispatch]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +12, Tests +266. Total +278 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 107 95 +12
Tests 2 266 0 +266
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 373 95 +278

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #157039
Summary: This PR is the candidate fix for the linked Ollama argument-loss report and replaces an earlier unmerged submission.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep the Ollama-specific correction and its root and closed-object controls, then land it through the normal exact-head review and merge gates.

Do we have a high-confidence way to reproduce the issue?

Yes. Current source shows the schema mutation, and the linked issue supplies a controlled native Ollama comparison; this read-only review did not execute a failing current-main turn.

Is this the best way to solve the issue?

Yes. Repairing the Ollama request producer addresses the malformed wire schema without adding configuration or a competing schema owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 37b47bf9652d.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The changed Ollama request normalizer feeds the built Gateway’s native chat path. The captured PR body reports three real Ollama 0.34.4 turns on this head with populated arguments received by a registered tool, plus a separate deterministic before/after Tool Search dispatch comparison. That model also succeeded on baseline, so the real runs establish after-fix execution rather than a live red/green reproduction. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed Ollama request normalizer feeds the built Gateway’s native chat path. The captured PR body reports three real Ollama 0.34.4 turns on this head with populated arguments received by a registered tool, plus a separate deterministic before/after Tool Search dispatch comparison. That model also succeeded on baseline, so the real runs establish after-fix execution rather than a live red/green reproduction. No stored-data contract changes.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Affected native Ollama users can lose required tool arguments and enter repeated failed Tool Search dispatches.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed Ollama request normalizer feeds the built Gateway’s native chat path. The captured PR body reports three real Ollama 0.34.4 turns on this head with populated arguments received by a registered tool, plus a separate deterministic before/after Tool Search dispatch comparison. That model also succeeded on baseline, so the real runs establish after-fix execution rather than a live red/green reproduction. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed Ollama request normalizer feeds the built Gateway’s native chat path. The captured PR body reports three real Ollama 0.34.4 turns on this head with populated arguments received by a registered tool, plus a separate deterministic before/after Tool Search dispatch comparison. That model also succeeded on baseline, so the real runs establish after-fix execution rather than a live red/green reproduction. No stored-data contract changes.

Evidence

What I checked:

  • Current main still needs the fix: The current-main normalizer adds an empty properties map to every object schema without declared properties, including the reported free-form shape. (extensions/ollama/src/stream.runtime.ts:644, 37b47bf9652d)
  • Latest release has the same behavior: The v2026.9.6 source retains the empty-properties insertion; the fix is not already shipped there. (extensions/ollama/src/stream.runtime.ts:644, eb377ac59e6c)
  • Introduced repair: The introduced predicate preserves open and pattern-based object schemas while retaining the root fallback; the stream calls this normalizer when serializing tool parameters. (extensions/ollama/src/tool-schema.runtime.ts:98, 1071871aa7a9)
  • Tool Search contract: OpenClaw’s tool-call dispatcher accepts a required id and optional nested free-form args. Its documentation distinguishes this feature from Codex-native tool search. (src/agents/tool-search.ts:399, 1071871aa7a9)
  • Earlier finding addressed: The current transport regression supplies and asserts an id with nested args, addressing the prior review’s invalid-argument finding. (extensions/ollama/src/tool-schema.transport.test.ts:147, 1071871aa7a9)
  • Updated real behavior proof: The captured PR body reports three after-fix turns through a built Gateway and real Ollama 0.34.4 server, each returning populated tool arguments that a registered tool received. Its successful baseline turns also worked with that model, so this is after-fix execution proof rather than a live reproduction of the reporter’s model-specific failure. The separate schema-sensitive fixture shows a deterministic before/after dispatch difference.

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • juyaohuidt: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • holny: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-24T21:00:20.498Z sha a75bec5 :: needs real behavior proof before merge. :: [P2] Send valid nested arguments in the Tool Search transport test
  • reviewed 2026-09-24T21:20:04.175Z sha d057160 :: needs real behavior proof before merge. :: [P2] Send valid nested arguments in the Tool Search transport test
  • reviewed 2026-09-24T23:49:15.329Z sha 1071871 :: needs real behavior proof before merge. :: none

@obviyus

obviyus commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 25, 2026
@obviyus

obviyus commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 25, 2026
@obviyus
obviyus merged commit 4bfac2b into openclaw:main Sep 25, 2026
127 of 128 checks passed
@obviyus

obviyus commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Merged as 4bfac2b. Thank you @Hmache for the fix and @markomiric for reporting #157039 and isolating the schema trigger.

The Ollama request normalizer now preserves free-form objects without changing closed-object behavior. Built-Gateway fake-server before/after proof showed three empty-argument dispatch failures with the main normalizer versus populated arguments, successful real exec, and completion after the fix; the closed-object control was unchanged. Real Ollama 0.34.4 with qwen2.5:3b then delivered populated free-form arguments to a registered tool in all three candidate attempts. That small model also preserved arguments in the two completed baseline attempts (the first timed out), so the live trace establishes compatibility rather than a live reproduction of the reporter's model-specific failure. All attempts and the native request/response excerpt are documented above.

203 focused tests passed, exact-head CI was green, and hosted ClawSweeper marked the merged head ready. The temporary Ollama container, model volume, and image have been removed.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
…157564)

Closes openclaw#157039
Supersedes openclaw#157435.

## What Problem This Solves

Fixes: native Ollama tool calls lose free-form object arguments, causing Tool Search dispatch to fail repeatedly.

## User Impact

User impact: free-form tool input survives native Ollama schema conversion, including nested Tool Search arguments. Closed objects and the root object fallback keep their existing behavior. No configuration changes are required.

## Why This Change Was Made

The request normalizer added `properties: {}` to open objects. Keep the repair in the Ollama request producer, preserving explicitly open objects, pattern-based records, and nested objects with implicit additional properties. The extracted inference and recursive normalization logic is unchanged apart from the empty-properties predicate. The Tool Search transport regression now uses the actual `id` plus nested `args` response contract.

## Evidence

### Real Ollama inference through the built Gateway

Tested head `1071871aa7a9105862e381737071cf2eb0774789` against **Ollama 0.34.4, qwen2.5:3b**, in a throwaway CPU-only Docker container (8 CPUs, 8 GiB, loopback-only port). Image digest: `sha256:8262851b2846b87c649eddf3e76beb270c52f4d1bc94559f47efde16b0841551`. A transparent loopback recording proxy forwarded requests and streamed responses unchanged; unlike the fixture below, it generated no model responses. A registered plugin tool recorded its received arguments independently.

Same prompt on both sides:

> Use proof_record exactly once now. Set payload to this JSON object exactly, preserving all keys and values: {"message":"OLLAMA_PROOF_OK","count":7}. After recording it, reply DONE. Do not just describe the tool call.

| Side / attempt | Actual outcome |
| --- | --- |
| Main normalizer / 1 | Gateway timed out at 300.821 s, no tool execution. The upstream model eventually returned populated arguments after the Gateway deadline; this is not counted as a successful turn. |
| Main normalizer / 2 | After setting `num_thread: 8` to match the container CPU quota, real tool call delivered `{"payload":{"count":7,"message":"OLLAMA_PROOF_OK"}}`; final `DONE`, 192.372 s. |
| Main normalizer / 3 | Same populated tool arguments; final `DONE`, 3.411 s. |
| PR / 1 | Same populated tool arguments; final `DONE`, 3.475 s. |
| PR / 2 | Same populated tool arguments; final `DONE`, 3.250 s. |
| PR / 3 | Same populated tool arguments; final `DONE`, 3.208 s. |

**Scope:** the real model emitted tool calls on both sides. Qwen2.5 3B did **not** reproduce the reporter's empty-argument inference behavior: both successful baseline turns preserved the payload despite the injected empty property map. The candidate's three successful real inference turns establish after-fix compatibility and actual tool execution, not a live red/green reproduction of that model-specific failure. The source/schema regression and deterministic Tool Search red/green comparison below remain separate evidence.

Observed native wire excerpt (description omitted only for brevity):

```json
{
  "before_payload_schema": {"type":"object","additionalProperties":true,"properties":{}},
  "after_payload_schema": {"type":"object","additionalProperties":true},
  "real_after_tool_calls": [
    {"id":"call_7fdun0ne","function":{"name":"proof_record","arguments":{"payload":{"count":7,"message":"OLLAMA_PROOF_OK"}}}},
    {"id":"call_l5jkfqoy","function":{"name":"proof_record","arguments":{"payload":{"count":7,"message":"OLLAMA_PROOF_OK"}}}},
    {"id":"call_d2fnvsic","function":{"name":"proof_record","arguments":{"payload":{"count":7,"message":"OLLAMA_PROOF_OK"}}}}
  ],
  "tool_received_each_time": {"payload":{"count":7,"message":"OLLAMA_PROOF_OK"}},
  "gateway_each_after_turn": {"status":"ok","assistantTurns":2,"toolSummary":{"calls":1,"tools":["proof_record"],"failures":0},"final":"DONE"}
}
```

### Deterministic Tool Search regression and closed-object control

A built Gateway was exercised through `node openclaw.mjs agent --agent main --message ... --json`, using isolated state and a loopback native `/api/chat` NDJSON fixture. The baseline used the main normalizer in the otherwise identical candidate checkout, then the candidate normalizer was restored and rebuilt. The fixture records the exact request and models the reporter's schema-sensitive response: it emits empty nested arguments only when the request gained `properties: {}`. This section is deterministic Gateway/transport/tool-dispatch proof, separate from the real inference runs above.

| Scenario | Observed result |
| --- | --- |
| Main normalizer, Tool Search | Wire `args` schema gained `properties: {}`. Three `tool_call` responses carried `args: {}`; all three failed target-input validation with `command: must have required property 'command'`. Four provider requests, no successful tool execution. The fixture then ended the bounded reproduction. |
| Fixed normalizer, Tool Search | Wire `args` retained `patternProperties: {"^.*$": {}}` with no `properties`. Response `{id: "openclaw:core:exec", args: {command: "printf OLLAMA_PROOF_OK"}}` reached the dispatcher; real `exec` returned `OLLAMA_PROOF_OK`, exit code 0. Two provider requests, one successful dispatch, final `OLLAMA_PROOF_COMPLETE`. |
| Closed-object negative control, before and after | A registered plugin tool with `additionalProperties: false`, required string `value`, and declared properties received `{value: "OLLAMA_PROOF_OK"}` in both runs. Serialized schemas were identical; both turns completed in two provider requests. |

Focused command: `node scripts/run-vitest.mjs extensions/ollama/src/tool-schema.runtime.test.ts extensions/ollama/src/tool-schema.transport.test.ts extensions/ollama/src/stream-runtime.test.ts --maxWorkers=1`: **203 passed**, 16.83 seconds wall including preparation. With the main normalizer restored, the two schema regression files produced **6 failures and 3 passes**: free-form cases failed on injected empty properties, while root fallback, closed-object, and recursive normalization controls passed. The isolated runtime build (`scripts/build-all.mts gatewayWatch`) passed.

The transport fixture makes no claim to test model inference. Its assertions protect the outgoing schema and parsed nested argument contract; the Gateway exercise separately verifies real dispatch and tool execution.

After merging current main for the unrelated build repair, all four Ollama files remained unchanged. At `1071871aa7a9105862e381737071cf2eb0774789`, the focused suite again passed 203 tests (22.96 seconds wall), the built Gateway again completed the Tool Search/exec turn in two provider requests with one successful dispatch, and the runtime build passed.

Co-authored-by: Ayaan Zaidi <[email protected]>
roboclaw-bot added a commit that referenced this pull request Sep 25, 2026
Backport #157564: 4bfac2b
Backport #157881: 0b234fc
Backport #158240: df5e316

Preserve native Ollama free-form schema parameters, project Twitch Disabled
to explicit deny-all, and retain TUI session ownership across delayed state.
No new policy, dependencies or version changes.

Co-authored-by: Hmache Abdellah <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vyctorbrzezowski <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: jalehman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: ollama P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Ollama native provider empties free-form object tool args (toolSearch tool_call.args always {})

2 participants