Skip to content

fix: no-tools models still send tool history and 400 - #148106

Merged
steipete merged 5 commits into
openclaw:mainfrom
jimmy00415:fix/completions-no-tools-history
Oct 11, 2026
Merged

steipete merged 5 commits into
openclaw:mainfrom
jimmy00415:fix/completions-no-tools-history

Conversation

@jimmy00415

@jimmy00415 jimmy00415 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: continuing a tool-using session with a Chat Completions model configured with compat.supportsTools: false still sends tool protocol and fails with HTTP 400 on strict OpenAI-compatible servers.

User Impact

Users can switch an existing session to a no-tools local model and continue with the earlier tool names, arguments, IDs, and results intact as assistant text. This also works with strictMessageKeys and requiresStringContent. Stored transcripts are unchanged; no new configuration or migration is required.

Why This Change Was Made

The typed message converter now handles no-tools replay before strict message shaping can discard identities. Collapsing results while constructing the final messages preserves runtime-context cache exclusions without a second parser or index-remapping pass. The existing request owner applies the same tools decision to definitions and replay; direct-provider requests retain their explicit-tools policy.

This finishes @jimmy00415's repair and preserves the contributor commits and credit. Current main was merged into the branch, without rebasing or force-pushing. The obsolete test file removed by main's test audit stays removed; focused replay coverage replaces only this PR's regression cases.

Production: +39/-12, net +27; tests: +209/-53, net +156; docs: +2. The contributor's approximately 200-line post-processing helper is removed. The remaining production growth is the small typed serialization branch; making it LOC-neutral would require unrelated deletion.

Evidence

Real local-model proof through pnpm openclaw --profile compat-transport agent --local, using the shared Chat Completions transport and Ollama qwen3:8b behind a loopback strict recording proxy:

  1. On main e5ee13e2d2d460c94dd4694e9df3c7da329db211, session compat-tools-two-reads called read for synthetic notes.txt and readme.md; both returned distinct token values and Qwen reported them correctly.
  2. Switch that same session to the no-tools route with both strict compatibility flags: HTTP 400, with two remaining tool-role messages.
  3. With this repair, continue that same session: HTTP 200, finish=stop, no tool protocol, and Qwen correctly states which file contained each value. The request retains both call IDs, paths, and paired results:
[tool call id=callmw2u3tq3 name=read] {"path":"notes.txt","optional":true}
[tool call id=calllu52e2fv name=read] {"path":"readme.md","optional":true}
[tool result id=callmw2u3tq3 name=read] NOTES_TOKEN=amber-17
[tool result id=calllu52e2fv name=read] README_TOKEN=violet-29

The proxy forwards accepted requests to the real model; its rejection is a deterministic strict-server contract, not a claim that Ollama itself rejects those fields. The exercised entry point is the embedded agent CLI, not a Gateway WebSocket client. All state, config, files, and ports were isolated. Tool Search was disabled in the fixture after Qwen confused its wrapper with read; the no-tools continuation also removes the explicit read allowlist, which correctly cannot be satisfied by a no-tools model.

Validation:

  • Regressions against unchanged main production: 5 fail for the original defect, 14 pass, 11.07s wall time.
  • Replay, cache, and converter tests: 58/58 pass, 17.29s wall time. After fixture typing cleanup, both affected files pass 19/19, 13.59s; the final replay file passes 5/5, 5.31s (node scripts/run-vitest.mjs <files> --maxWorkers=1). Tests use no clocks, timers, server boots, or mocks. The selected CI run took 512 seconds; it finished with the separate failure described below.
  • Full pnpm build passes (9m 32.7s); production and package test typechecks, scoped lint, formatting, and git diff --check pass. Gateway-only dependency preparation omitted the lint plugin workspace; a normal frozen install supplied it before the successful lint run.
  • Max-lines, line-cap, assertion-safety, test-timeout-race, test-mock-exports, config-doc, and plugin-inventory checks pass.
  • pnpm prompt:snapshots:gen produces no changes: 0 snapshot-token delta.
  • Independent Codex autoreview: scoped-clean, no actionable P0–P2 findings.

Prior-head investigation (34f24801d212fd1f5edcd0bc52acb66b8c0067e7):

  • ClawSweeper review: no actionable findings; live proof sufficient. Its only hold requests attribution of the separate CI failure.
  • CI run 38113846721 finished red. All jobs passed or skipped except checks-node-changed-compact-large-42 and the aggregate openclaw/ci-gate. The failed job fails normalizeRpcAttachmentsToChatAttachments > converts ArrayBuffer content to base64 ([] instead of an attachment). That job took 222 seconds.
  • The attachment owner and test are byte-identical across reproduced main, merged main parent, and this head. On unchanged main production, the focused test passes on macOS Node 26.11.1 (33.11s), the full original-order file passes 88/88 (33.33s), and the focused test also passes on the available Node 24.21.0 (78.78s including worker compilation). CI used Linux Node 24.19.0. This is an unproven inherited/environment-specific failure, not a reproduced baseline red; no causal patch change was found. No speculative attachment change or blind rerun was made.

Per maintainer direction, current main was merged once and pushed with ci:no-fail-fast already set. Current head: 60758f3533bfa44f10cf7f7b5f1580bc2a1cb6c4; main parent: cf534960545d3fa8c020450da474d67c269ceb00. The reviewed transport production and test files are byte-identical to the prior head. Refreshed replay/cache proof: 19/19 pass in 4.98s; refreshed autoreview: scoped-clean. Current-head CI run 38120809338 completed successfully: all 47 jobs passed, including openclaw/ci-gate. ClawSweeper reviewed the exact current head with no findings and no before-merge items. The separate original-base attribution lease never acquired a runner and was stopped; no same-base Linux execution is claimed. The prior failure remains recorded above, but no inherited-failure exception is needed for this green head. READY for the lead; no merge is requested by this worker.

Please keep Allow edits from maintainers enabled.

Custom OpenAI-compatible backends that set compat.supportsTools=false already omit the tools array, but prior tool_calls and tool-result roles stayed in the replayed messages. Those providers reject the follow-up turn. Flatten that protocol to plain assistant text.

Co-authored-by: Cursor <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 14, 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 P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR converts historical tool calls and results into labeled assistant text for managed Chat Completions models configured without tool support.

Example: Continue the same qwen3:8b session with supportsTools=false after reading notes.txt and readme.md.

  • Before: The strict recording proxy rejects two remaining tool-role messages with HTTP 400.
  • After: The request returns HTTP 200, and the model correctly associates amber-17 with notes.txt and violet-29 with readme.md.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A useful shared-owner repair with applicable shipped-entry-point proof, meaningful regressions, no actionable findings, and successful current-head checks.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied embedded-agent CLI trace exercises the managed Chat Completions owner against real Ollama qwen3:8b through a strict recording proxy, changing the same-session continuation from HTTP 400 to HTTP 200 while preserving both file-result associations under strict keys and string content.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An existing tool-using session cannot continue on a configured no-tools model because strict servers reject historical tool protocol.
Reason: The focused repair fulfills an existing compatibility setting without adding configuration or rewriting persisted history.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a current-main replay defect, resolves the earlier findings, and has sufficient behavior proof and successful checks for the reviewed head.

Priority: P2
Reviewed head: 60758f3533bfa44f10cf7f7b5f1580bc2a1cb6c4

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared Chat Completions builder consumes session history and model compatibility settings, converts messages, applies strict shaping and cache markers, and sends the resulting provider request.

flowchart LR
  A[Session history] --> B[Transcript normalization]
  C[Model compatibility] --> D[Shared request builder]
  B --> E[Typed message conversion]
  D --> E
  E --> F[Strict shaping and cache markers]
  F --> G[Chat Completions server]
Loading

Technical review

Best possible solution:

Land the repair in the existing typed converter while preserving stored transcripts and direct-provider behavior.

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

Current-main source establishes the conflicting definitions and replay decisions, and supplied CLI output records the strict-server failure; this review ran no target code.

Is this the best way to solve the issue?

Conversion at the existing typed owner preserves identities before strict shaping and avoids a second parser or cache-index remapping pass.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Assistant and tool-result replay changes intended behavior with a stated reason (0297f0e: The package-unification baseline established package-owned transcript normalization; subsequent replay preparation preserved serialized arguments, tool order, and thinking contracts.)
  • Shared direct and managed request assembly keeps the original intent (a9676bd: The merged consolidation deliberately retained separate direct explicit-tools and managed compatibility policies.)
  • Cache exclusions and history anchors keeps the original intent (b7848ca: One cache-marker owner preserves stable request boundaries and excludes transient runtime carriers.)
  • Tool-result image ownership keeps the original intent (499c137: Batch-local ordinal captions distinguish parallel image ownership even when names or bounded identifiers collide.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a9676bd adds packages/ai/src/transports/openai-completions-params.ts:445 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a9676bd2b95d; files: packages/ai/src/transports/openai-completions-params.ts)
  • SunnyShu: Raw commit 499c137 adds packages/ai/src/openai-completions-messages.ts:272 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 499c137d0c12; files: packages/ai/src/openai-completions-messages.ts)
  • Dallin Romney: Raw commit cd9913f adds packages/ai/src/openai-completions-messages.ts:120 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: cd9913f1b110; files: packages/ai/src/openai-completions-messages.ts)

PR surface

Source +27, Tests +156, Docs +2. Total +185 across 5 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 39 12 +27
Tests 2 209 53 +156
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 250 65 +185

Review metrics

Metric Value Why it matters
Production versus test LOC Production +39/-12, net +27; tests +209/-53, net +156. Production growth adds typed serialization within the existing owner; tests protect distinct replay, strict-shaping, direct-policy, image, and cache contracts.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Continuing a tool-using session on a configured no-tools Chat Completions model fails, with a limited affected workflow.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (7 earlier review cycles)
  • reviewed 2026-09-14T09:17:54.937Z sha 3d56d70 :: needs real behavior proof before merge. :: [P2] Preserve tool inputs and result associations in the text replay | [P2] Remap cache exclusions when collapsing tool-result messages
  • reviewed 2026-09-16T07:19:25.570Z sha e96dcd9 :: blocked before merge. :: none
  • reviewed 2026-10-05T17:07:58.098Z sha e96dcd9 :: blocked before merge. :: [P2] [P2] Flatten tool history before stripping strict message keys
  • reviewed 2026-10-11T05:18:57.081Z sha 34f2480 :: needs changes before merge. :: none
  • reviewed 2026-10-11T05:40:11.979Z sha 34f2480 :: needs changes before merge. :: none
  • reviewed 2026-10-11T07:15:12.447Z sha 34f2480 :: blocked before merge. :: none
  • reviewed 2026-10-11T07:26:40.754Z sha 60758f3 :: needs maintainer review before merge. :: none

Reviewed October 11, 2026, 3:39 AM ET / 07:39 UTC (Revision 8).

supportsTools: false already flattened tool protocol to text, but dropped arguments/ids and left cacheOptOutIndexes pointing at collapsed rows. Keep call/result associations and remap exclusions.
Co-authored-by: Cursor <[email protected]>
@jimmy00415

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 16, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. labels Oct 5, 2026
steipete and others added 2 commits October 10, 2026 21:46
Merge current main into the contributor branch. Convert tool history to labeled assistant text while IDs, arguments, result names, and final cache positions remain available. Preserve direct-provider tool policy and remove the post-processing flattener.

Co-authored-by: Jimmy CHEN <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M and removed size: S labels Oct 11, 2026
@clawsweeper clawsweeper Bot removed the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Oct 11, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 11, 2026
@steipete steipete added the ci:no-fail-fast Keep all selected CI matrix jobs running after failures on the next PR run. label Oct 11, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 11, 2026
@steipete steipete self-assigned this Oct 11, 2026
@steipete
steipete merged commit c55ca8c into openclaw:main Oct 11, 2026
129 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
* fix: no-tools models still send tool history and 400

Custom OpenAI-compatible backends that set compat.supportsTools=false already omit the tools array, but prior tool_calls and tool-result roles stayed in the replayed messages. Those providers reject the follow-up turn. Flatten that protocol to plain assistant text.

* fix: keep no-tools replay arguments and cache exclusions

supportsTools: false already flattened tool protocol to text, but dropped arguments/ids and left cacheOptOutIndexes pointing at collapsed rows. Keep call/result associations and remap exclusions.

* test: type no-tools replay fixtures without casts

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Jimmy CHEN <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:no-fail-fast Keep all selected CI matrix jobs running after failures on the next PR run. docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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.

2 participants