Skip to content

fix: preserve requested output limits for custom models - #146479

Merged
steipete merged 1 commit into
mainfrom
codex/unknown-output-token-cap
Sep 12, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/unknown-output-token-cap

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: custom Anthropic and Mistral requests can fail with invalid output-token limits when model metadata omits its maximum output size.

User Impact

User impact: an explicitly requested output limit works even when the model's output ceiling is unknown. Known ceilings still apply, and omitted limits retain their existing behavior.

Why This Change Was Made

Preserve the explicit request limit when there is no model ceiling to clamp against, including Anthropic manual-thinking requests.

Evidence

Five regression cases failed before repair; all 150 tests in the affected provider and shared-option suites pass afterward. Authenticated Anthropic requests passed with both known and omitted model ceilings, retaining the explicit 360-token request limit. Independent review found no actionable issues. The original defect also caused an authenticated Anthropic exec reviewer to return HTTP 400 for an invalid max_tokens value.

@clawsweeper

clawsweeper Bot commented Sep 12, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M maintainer Maintainer-authored PR labels Sep 12, 2026
@steipete
steipete marked this pull request as ready for review September 12, 2026 21:18
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 12, 2026, 5:27 PM ET / 21:27 UTC.

ClawSweeper review

What this changes

Preserves explicit Anthropic and Mistral output-token limits when custom-model metadata omits its ceiling, with regression coverage and documentation.

Merge readiness

✅ Ready for maintainer review

The repair remains necessary on fetched main and the latest release. The introduced changes preserve existing known-limit behavior, and no actionable correctness or security defect was found.

Priority: P2
Reviewed head: 1d02161a598ada651874760b2bd20f07c1385983

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful regression cases, reported live validation, and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied maintainer status exempts this PR from the external-contributor proof gate. Its body nevertheless reports authenticated Anthropic requests through the changed provider entrypoint preserving 360 tokens with known and unknown ceilings; those runs were not independently repeated.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied maintainer status exempts this PR from the external-contributor proof gate. Its body nevertheless reports authenticated Anthropic requests through the changed provider entrypoint preserving 360 tokens with known and unknown ceilings; those runs were not independently repeated.
Evidence reviewed 7 items Current-main defect remains: Fetched main still applies Math.min(requestedMaxTokens, model.maxTokens); an explicit finite request with an undefined model ceiling produces NaN.
Latest-release check: The v2026.9.4 source also contains the unsafe clamp. The release file was read through GitHub REST after local blob retrieval failed.
Bounded production repair: The introduced production changes provide a fallback only for an absent model ceiling. Anthropic uses the resolved request limit as its manual-thinking capacity; known ceilings and the existing thinking-disable path remain intact.
Findings None None.
Security None None.

How this fits together

OpenClaw’s provider adapters translate model metadata and request options into provider API requests. Their output-limit calculation controls the response budget and Anthropic’s manual-thinking budget.

flowchart LR
  A[Model metadata] --> C[Resolve output limit]
  B[Requested output limit] --> C
  C --> D[Anthropic thinking budget]
  C --> E[Mistral request]
  D --> F[Anthropic request]
  E --> G[Provider response]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source 0, Tests +57, Docs +2. Total +59 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 2 2 2 0
Tests 4 129 72 +57
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 133 74 +59

Review metrics

None.

Technical review

Best possible solution:

Keep output-limit normalization in the existing shared helper and fit Anthropic manual thinking within the available model or explicit request capacity.

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

Yes, source establishes the trigger: an explicit output limit and an undefined model ceiling reach Math.min and produce NaN on current main. Execution was not repeated in this read-only review.

Is this the best way to solve the issue?

Yes, the patch repairs the existing calculation without adding another policy owner, configuration option, or migration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9b59fe4ef7da.

Labels

Label changes:

  • add P2: Repairs invalid provider request limits for custom models with missing output metadata, a bounded provider compatibility defect.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied maintainer status exempts this PR from the external-contributor proof gate. Its body nevertheless reports authenticated Anthropic requests through the changed provider entrypoint preserving 360 tokens with known and unknown ceilings; those runs were not independently repeated.

Label justifications:

  • P2: Repairs invalid provider request limits for custom models with missing output metadata, a bounded provider compatibility defect.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied maintainer status exempts this PR from the external-contributor proof gate. Its body nevertheless reports authenticated Anthropic requests through the changed provider entrypoint preserving 360 tokens with known and unknown ceilings; those runs were not independently repeated.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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.

@steipete
steipete merged commit 5720083 into main Sep 12, 2026
183 checks passed
@steipete
steipete deleted the codex/unknown-output-token-cap branch September 12, 2026 22:07
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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.

1 participant