Repository navigation
fix: no-tools models still send tool history and 400 - #148106
Conversation
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]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +27, Tests +156, Docs +2. Total +185 across 5 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (7 earlier review cycles)
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]>
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
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]>
|
Merged via squash.
|
* 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]>
What Problem This Solves
Fixes: continuing a tool-using session with a Chat Completions model configured with
compat.supportsTools: falsestill 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
strictMessageKeysandrequiresStringContent. 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:e5ee13e2d2d460c94dd4694e9df3c7da329db211, sessioncompat-tools-two-readscalledreadfor syntheticnotes.txtandreadme.md; both returned distinct token values and Qwen reported them correctly.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:
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.pnpm buildpasses (9m 32.7s); production and package test typechecks, scoped lint, formatting, andgit diff --checkpass. Gateway-only dependency preparation omitted the lint plugin workspace; a normal frozen install supplied it before the successful lint run.pnpm prompt:snapshots:genproduces no changes: 0 snapshot-token delta.Prior-head investigation (
34f24801d212fd1f5edcd0bc52acb66b8c0067e7):checks-node-changed-compact-large-42and the aggregateopenclaw/ci-gate. The failed job failsnormalizeRpcAttachmentsToChatAttachments > converts ArrayBuffer content to base64([]instead of an attachment). That job took 222 seconds.Per maintainer direction, current main was merged once and pushed with
ci:no-fail-fastalready 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, includingopenclaw/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.