Skip to content

fix(openrouter): send strict:false so optional tool inputs stay optional - #175267

Merged
steipete merged 1 commit into
mainfrom
codex/openrouter-strict-false
Oct 17, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/openrouter-strict-false

Conversation

@steipete

@steipete steipete commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

On OpenRouter, OpenAI models fill in optional tool arguments with invented values. OpenClaw omitted the strict field 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: false for 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, so strict: false and the schema's real required list reach the provider. Custom proxy endpoints, an explicit supportsStrictMode: 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 browser receive 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 action plus five optional parameters. Two OpenAI models were exercised four times each:

Build Serialized tool Model A Model B
main strict omitted, required: ["action"] 4/4 calls invent optional arguments 4/4 calls invent optional arguments
this patch strict: false, required: ["action"] 0/4 extra arguments 0/4 extra arguments
  • test/plugins/openrouter-tool-schema.integration.test.ts covers managed and direct serialization, custom proxies, explicit opt-out, and native OpenAI.
  • Coordinator standalone serialization controls: 16 passed; scoped typecheck, lint, formatting, and whitespace checks passed. The earlier formal Vitest attempt stalled during preparation/loading on the saturated host; it is not claimed as a pass.
  • Coordinator Codex autoreview: scoped-clean, no accepted/actionable findings. Reused at Peter's explicit direction.
  • Conflict repair rebased the patch onto main and retained both main's Jev documentation and the strict-mode note. Production and test changes are unchanged; current-head PR CI supplies broad proof.
  • Exact-head CI run 39012889511 passed for 9a20387eadb585fbb2b657f4c42fbc68a895100b; the native watcher returned GREEN. Current-head security review also passed. No CI job was rerun and no tests were weakened.

Fixes #165735.

@steipete
steipete marked this pull request as ready for review October 17, 2026 06:59
@clawsweeper

clawsweeper Bot commented Oct 17, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T07:17:12.019340Z 9a20387 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S labels Oct 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
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]>
@steipete
steipete force-pushed the codex/openrouter-strict-false branch from d3bdfea to 9a20387 Compare October 17, 2026 07:14
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The serialized definition omits strict; the reported tabs call includes unwanted optional selectors.
  • After: The definition includes strict:false and required:["action"], allowing a call containing only {"action":"tabs"}.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch is source-consistent and covered at the serialization boundary; the live result is summarized rather than independently inspectable.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate does not apply to this maintainer-authored PR; its body reports managed-builder live OpenRouter comparisons, while the added tests capture real SDK serialization with synthetic responses.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Browser tab-listing calls receive unwanted optional arguments and fail validation on the affected OpenRouter route.
Reason: The reported failure matches the serializer path, and the maintainer-authored change supplies the owner decision for this narrow endpoint correction.

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
Reviewed head: 9a20387eadb585fbb2b657f4c42fbc68a895100b

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The live comparison is summarized without raw request/response artifacts, and the new regression's failing-base run is not recorded for this implementation.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Shared strict-mode compatibility default changes intended behavior with a stated reason (50d85dc: Centralize conservative OpenAI-compatible defaults; the original patch provides no OpenRouter-specific omission requirement.)
  • OpenRouter tool-capability and Jev documentation keeps the original intent (fix(openrouter): unsupported models incorrectly receive tool definitions #129659: Respect advertised tool capabilities; the new note preserves that policy and the adjacent Jev section.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 1759f4d adds packages/ai/src/transports/openai-completions-compat.ts:161 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1759f4d5e656; files: packages/ai/src/transports/openai-completions-compat.ts)
  • Vincent Koc: Raw commit 68502c9 adds src/agents/openai-completions-compat.ts:86 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 68502c90d1fb; files: src/agents/openai-completions-compat.ts)

PR surface

Source +1, Tests +175, Docs +6. Total +182 across 3 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 175 0 +175
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 183 1 +182

Root-cause cluster

Relationship: same_root_cause
Canonical: #165735
Summary: The report and both PRs concern the same strict-field omission in public OpenRouter tool definitions.

Members:

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

Labels

Label changes:

  • add P1: The linked report establishes repeated production browser-tool validation failures and costly retries on a supported provider route.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: The linked report establishes repeated production browser-tool validation failures and costly retries on a supported provider route.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach redacted live request/response output showing strict:false and the resulting action-only browser arguments.

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 execution lanes are retired.

Reviewed October 17, 2026, 3:30 AM ET / 07:30 UTC.

@steipete
steipete merged commit e96ea4b into main Oct 17, 2026
131 of 133 checks passed
@steipete
steipete deleted the codex/openrouter-strict-false branch October 17, 2026 08:31
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Oct 17, 2026
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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
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.
obviyus added a commit that referenced this pull request Nov 27, 2026
…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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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]: OpenRouter: omitting strict: false produces invalid browser arguments

1 participant