Repository navigation
fix(openrouter): send strict:false so optional tool inputs stay optional - #175267
Conversation
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Allow the strict field on public OpenRouter endpoints so the existing host policy and direct SDK path serialize strict:false. Preserve required fields, custom proxy defaults, explicit compatibility opt-outs, and native OpenAI strict behavior. Add serialized-request regression coverage through the OpenRouter plugin and host, and document the default. Fixes #165735. Design reference: #165905. Co-authored-by: alkor2000 <[email protected]>
d3bdfea to
9a20387
Compare
|
Codex review: needs maintainer review before merge. What this changesThis PR enables explicit strict:false tool definitions on public OpenRouter endpoints while preserving required fields, proxy defaults, and compatibility opt-outs. Example: A browser tool on https://openrouter.ai/api/v1 requires action and permits optional targetId.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it fixes a source-confirmed provider workflow failure that remains on main and in the latest release; no actionable patch defect was found. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe shared Chat Completions compatibility owner combines endpoint capabilities with explicit model overrides, then the tool serializer emits the provider request. flowchart LR
A[Model and endpoint] --> B[Compatibility defaults]
B --> C[Explicit overrides]
C --> D[Strict tool policy]
D --> E[Tool serializer]
E --> F[OpenRouter]
Technical reviewBest possible solution: Land the endpoint-scoped correction in the existing compatibility owner while retaining explicit overrides and browser validation. Do we have a high-confidence way to reproduce the issue? Source deterministically shows the omitted field on current main and the latest release; the reporter and PR author supply controlled downstream comparisons, which were not rerun during this read-only review. Is this the best way to solve the issue? The patch repairs the existing endpoint policy at its shared owner and preserves explicit opt-outs without weakening tool validation or introducing another request path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d2fe433535d5. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests +175, Docs +6. Total +182 across 3 files. Added test files: 1. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 Reviewed October 17, 2026, 3:30 AM ET / 07:30 UTC. |
|
Merged via squash.
|
The OpenRouter serialization fixture captured its host before loading the plugin. Loading can install the agent transport host, so cleanup restored an older host while leaving the one-shot installer cached. Later simple completion tests then lost endpoint inference and sent generic OpenAI reasoning_effort fields to GLM and DeepSeek routes. Capture the host after plugin registration and before the test override. Keep all serialized-request assertions and production thinking policy. The failure appeared after #175673 and reproduces with the two suites combined; reverting #175673 makes the same pair pass. The fixture lifecycle bug originated in #175267. Both standalone controls pass, confirming the shared-worker dependency. The repaired pair passes all 22 cases, the owning root-other typecheck and scoped lint pass, and P2 review is clean.
…nal (openclaw#175267) Allow the strict field on public OpenRouter endpoints so the existing host policy and direct SDK path serialize strict:false. Preserve required fields, custom proxy defaults, explicit compatibility opt-outs, and native OpenAI strict behavior. Add serialized-request regression coverage through the OpenRouter plugin and host, and document the default. Fixes openclaw#165735. Design reference: openclaw#165905. Co-authored-by: alkor2000 <[email protected]>
The OpenRouter serialization fixture captured its host before loading the plugin. Loading can install the agent transport host, so cleanup restored an older host while leaving the one-shot installer cached. Later simple completion tests then lost endpoint inference and sent generic OpenAI reasoning_effort fields to GLM and DeepSeek routes. Capture the host after plugin registration and before the test override. Keep all serialized-request assertions and production thinking policy. The failure appeared after openclaw#175673 and reproduces with the two suites combined; reverting openclaw#175673 makes the same pair pass. The fixture lifecycle bug originated in openclaw#175267. Both standalone controls pass, confirming the shared-worker dependency. The repaired pair passes all 22 cases, the owning root-other typecheck and scoped lint pass, and P2 review is clean.
…ring reader - Direct Completions requests send strict: false wherever resolved compat supports the field (#175267: OpenRouter treats an omitted field as strict). - The strict-rejection classifier reads error fields with normalization-core readStringValue (coercion-helpers guard).
What Problem This Solves
On OpenRouter, OpenAI models fill in optional tool arguments with invented values. OpenClaw omitted the
strictfield on OpenRouter tool definitions, and the OpenAI models behind OpenRouter then treat every schema property as required. A browser call to list tabs can arrive with empty target, URL, and selector fields and unwanted timeout or screenshot options, which the tool rejects or misinterprets. Reported in #165735.Why This Change Was Made
The host already resolves
strict: falsefor these routes, but the transport compatibility defaults marked public OpenRouter endpoints as not supporting the strict field, so the value was dropped before serialization. Public OpenRouter endpoints now allow the field, sostrict: falseand the schema's realrequiredlist reach the provider. Custom proxy endpoints, an explicitsupportsStrictMode: false, Z.AI, and native OpenAI behavior are unchanged.Design follows #165905 by @alkor2000, re-implemented and live-proven here. The commit preserves
Co-authored-by: alkor2000 <[email protected]>.User Impact
Agents using OpenAI models through OpenRouter stop inventing optional tool arguments, so tools such as
browserreceive only the inputs the model actually chose.Evidence
Coordinator live proof used OpenClaw's managed request builder and production host strict policy, a real OpenRouter connection, and a browser tool with required
actionplus five optional parameters. Two OpenAI models were exercised four times each:strictomitted,required: ["action"]strict: false,required: ["action"]test/plugins/openrouter-tool-schema.integration.test.tscovers managed and direct serialization, custom proxies, explicit opt-out, and native OpenAI.9a20387eadb585fbb2b657f4c42fbc68a895100b; the native watcher returnedGREEN. Current-head security review also passed. No CI job was rerun and no tests were weakened.Fixes #165735.