Skip to content

fix(models): replies truncate at 8192 output tokens when a model has no known output limit - #193899

Merged
roboclaw-bot merged 4 commits into
openclaw:mainfrom
VACInc:fix/default-max-output-32k
Nov 6, 2026
Merged

roboclaw-bot merged 4 commits into
openclaw:mainfrom
VACInc:fix/default-max-output-32k

Conversation

@VACInc

@VACInc VACInc commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Related: #71045, #119259, #126458, #126611

Problem and scope

Vito Cappello's fix replaces the synthesized 8192-token output budget (4096 in the custom-provider wizard) with a bounded, context-aware default of up to 32768. It addresses truncation caused by that default on the configured/discovered provider paths below. This is an intentional default-budget policy, not a complete migration to absent output-cap metadata and not proof of a historical leaderboard improvement.

One owner, resolveDefaultModelMaxTokens(contextWindow?) in src/agents/defaults.ts, is exported through plugin-sdk/provider-model-shared:

  • Unknown window: 32768.
  • Known window: min(32768, max(min(8192, window), floor(window / 2))).
  • Served windows are respected: contextTokens, llama.cpp n_ctx, vLLM max_model_len, LM Studio load length, and the local Ollama 32K num_ctx cap.
  • Explicit model, provider, request-parameter, and catalog caps continue to win.

The cutover covers config materialization, self-hosted discovery/setup, local Ollama, OpenRouter dynamic/live/Auto/capability-cache paths, Copilot, Hugging Face, DeepInfra, Baseten, Synthetic, Hermes import, generic live-catalog normalization, and the non-Azure custom-provider wizard.

User impact and accepted tradeoffs

Unknown-limit rows can request up to 32768 output tokens rather than 8192. A known 32K window gets a 16384 default; a 16K window gets 8192. Existing per-request prompt budgeting can trim these further.

Saved numeric caps are not rewritten. Old onboarding values such as 4096 or 8192 remain authoritative until the user raises or removes them. Doctor adds informational guidance, grouped by provider, without changing config, failing health, or offering an automatic repair. It skips Mistral, provider-level caps, and rows whose context-aware default is not higher. A known catalog cap may still apply after a saved cap is removed; the synthesized number is not a newly discovered factual model capability.

Known compatibility tradeoff: a strict provider with an unknown independent output ceiling can reject 32768 with a 400 where 8192 passed. Configure that model's real maxTokens when this occurs. This is explicitly accepted as part of the bounded-default policy.

Intentionally unchanged: Mistral's 8192 repair value (#53054), Doctor's historical metadata-corruption fingerprint, hosted Ollama catalog/context budgets, and Bedrock's authored-cap forwarding behavior (#97343). The materialized numeric model contract remains unchanged. Unlike the incomplete omission attempt in #126611, this does not remove the numeric field. It also does not fix every pre-existing unknown-cap constructor: unchanged inline/static paths can still use their existing context-sized fallback. No new config option, stored-data rewrite, or schema change is introduced.

Release note: Default synthesized output budget raised from 8192 to up to 32768, sized down for small context windows. Doctor points out saved 4096/8192 caps that may retain the old behavior.

Author's production-path and upgrade evidence

The original author ran official pnpm openclaw agent --local builds against a local fake OpenAI-compatible endpoint, with isolated HOME/state/config and no real provider keys:

Case Base 938a72d4c1e wire cap PR wire cap
Unknown cap 8192 32768
32K window 8192 13349
Explicit 8192 8192 8192

The 32K row materializes to 16384; existing prompt budgeting trims it to 13349 because the default prompt/tools use about 19K. The 16K-window control stopped before a provider request because the default prompt did not fit; that pre-existing prompt-size limitation is unrelated to this change. The fake endpoint streamed ok, so these cases prove serialization, not real-provider acceptance or long-generation quality.

The author also exercised published [email protected], then the branch's normal Doctor upgrade step, on the same isolated state. Saved provider-level 4096, wizard-saved 4096, and explicit 8192 remained unchanged on the wire; the unknown row changed from 8192 to 32768. All fake-provider turns returned ok, and the config's models section remained identical. This upgrade proof covers config-driven custom providers, not every discovered provider plugin.

A real doctor --non-interactive run printed saved-cap guidance, exited 0, and left the isolated config byte-identical. Detection tests cover grouping, Mistral/provider-cap skips, sanitization, note output, unchanged config, and healthy status.

Independent real-model verification

Official pnpm openclaw agent --local turns ran in secretless containers against real llama.cpp-served Qwen2.5-0.5B-Instruct Q4_K_M. Base: d4ae77eae296fd8eb1f90f7a4ebb5d77fa2e6ad9; PR runtime: 357467abf979d35435a5e22f416c2112366a24d3. The subsequent CI-only repair dd92fac1754b9af32611dfea27d1518b7d21bd4c does not change runtime budget code.

Case Serialized max_completion_tokens Server prompt/completion tokens Result
Base, cap omitted 8192 1840 / 5 stop, CLI exit 0
PR, cap omitted 32768 1844 / 4 stop, CLI exit 0
PR, explicit 8192 8192 1844 / 12 stop, CLI exit 0

All three turns were not aborted. The small model did not consistently follow the requested echo marker; its mismatches were preserved, not relabeled as exact-marker successes. This establishes config-to-wire budget propagation and normal completion, not task-solving quality.

A separate real-server ignore_eos: true control emitted exactly 8200 completion tokens with finish reason length. That is a forced-EOS budget-mechanism test, not natural long-generation or completed-tool-call evidence.

Pins: model revision 9217f5db79a29953eb74d5343926648285ec7e67; model SHA-256 74a4da8c9fdbcd15bd1f6d01d621410d31c6fc00986f5eb687824e7b93d7a9db; llama.cpp image ghcr.io/ggml-org/llama.cpp@sha256:41988e510b6fe0a0b5b9be00a9dbf91d9f0fa691da173d7b06d97d370329fe84.

No hosted-provider API, paid inference, real credentials, or historical leaderboard replay was used. Other local inference servers remain covered by discovery-shape tests, not live calls. No benchmark gain or causal explanation of aggregate ranks is claimed.

Regression coverage and review

Author-reported red-on-base / green-on-branch cases: src/config/defaults.test.ts (4 base failures/37), src/config/defaults.ollama-output-cap.test.ts (5/30), and src/plugin-sdk/provider-catalog-live-normalize.tokens.test.ts (2/6). The matrix includes unknown/large/32K/16K/4K windows, served context, explicit caps above/below defaults, provider caps, and provider caps on small windows.

The author reports passing targeted core/provider tests and extension suites for Ollama, LM Studio, llama.cpp, OpenRouter, Copilot, Hugging Face, DeepInfra, Baseten, Synthetic, Hermes, and Bedrock authored-32768 forwarding; typecheck/lint/format/import-cycle checks and SDK export checks also passed. Earlier unrelated main-tree changelog/dead-export findings are not treated as proof that this candidate's CI passes.

Independent full-range local review, including the two CI repairs: complete single pass, no actionable P0–P2 findings. Static review did not execute tests. Scoped simplification kept the repairs to two files.

CI repair, test cost, and pending proof

The original head's CI failed mock-exports and test-lines. Repair dd92fac1754b9af32611dfea27d1518b7d21bd4c preserves the real note-module exports before overriding note and adds a separate 305-line allocation. Exact positive test growth against merge base 938a72d4c1e4136d07f32156ed633f2f86a524a1 is 327 additions minus 22 deletions = 305 (302 original plus three repair lines). The allocation is needed for shared-budget, explicit/provider/window controls and non-mutating Doctor regressions. The shared scalar is unchanged.

Exact changed-file formatter: exit 0, 0.077 s. Official focused Doctor tests did not reach assertions in secretless isolation: compiled-worker preparation exited 137 on baseline (18.829 s) and patched snapshot (17.595 s); larger-memory/affinity attempts hit the shared host execution-memory budget. These are setup/resource failures, not assertion-level product failures. Focused test runtime and CI seconds remain unmeasured locally.

The isolated mock-export guard required a Git base; none was fabricated. The exact signed repair candidate has been published through the native pending-proof workflow, not declared ready to merge. Exact-head GitHub CI must validate the focused tests and both ratchets; fresh READY correction review and ordinary landing gates remain required.

@VACInc

VACInc commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 6, 2026
@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR replaces copied output-token fallbacks with one context-aware default of up to 32,768 tokens while preserving explicit limits.

Example: A custom OpenAI-compatible model named big-unknown has no configured or catalog output limit.

  • Before: The agent request sends max_completion_tokens: 8192.
  • After: The agent request sends max_completion_tokens: 32768; a saved explicit 8192 cap remains 8192.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused shared-owner change with shipped-CLI request evidence and stable-upgrade preservation; broader provider acceptance remains outside the supplied proof.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): Supplied isolated agent CLI turns exercise config materialization through the real HTTP transport, recording the new cap, small-window trimming, preserved explicit caps, and successful replies; this proves request budgets, not generation beyond 8192 tokens or hosted-provider acceptance.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Long answers and tool-call arguments can exhaust an invented output budget despite the model supporting more output.
Reason: The maintainer-authored direction increases the bounded fallback without replacing explicit limits, adding options, or changing stored formats.

Merge readiness

✅ Ready for maintainer review

This maintainer-authored PR remains useful and has no remaining actionable findings; the updated stable-release upgrade evidence resolves the previous compatibility blocker.

Priority: P2
Reviewed head: c270a232824a16f05a8d142266338a6f8a5ec8db

Before merge

None.

Findings

None.

Agent review details

How this fits together

Configuration materialization and provider discovery turn authored settings and catalog metadata into model budgets that inference transports serialize into requests.

flowchart LR
  A[Authored configuration] --> C[Model materialization]
  B[Provider discovery] --> C
  D[Shared output default] --> C
  C --> E[Request budget]
  E --> F[Provider transport]
Loading

Technical review

Best possible solution:

Use the shared context-aware fallback across existing model owners while retaining authored limits and provider-specific request contracts.

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

Current-main source supplies the 8192 fallback, and the supplied before-fix agent request trace records that value on the wire; no target code was executed during this review.

Is this the best way to solve the issue?

The shared resolver is a small, coherent solution to the chosen default-budget change, preserves numeric model contracts, and avoids the cap-omission problems discussed in #126611.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7349fd516c64.

Provenance checked

  • Generic configured-model fallback changes intended behavior with a stated reason (5ad203e: Materialize omitted custom-provider model fields with usable defaults, including 8192 output tokens.)
  • Shared self-hosted defaults keeps the original intent (c08f2aa: Centralize provider setup defaults and helper boundaries.)
  • Live provider-catalog fallbacks changes intended behavior with a stated reason (55cf952: Discover newly available models while retaining trusted metadata and conservative fallback rows.)
  • Local Ollama output budget changes intended behavior with a stated reason (b14f705: Send resolved output caps to native Ollama and bound repetitive local-model generation while preserving hosted budgets and explicit overrides.)
  • Mistral repair and Bedrock authored caps keeps the original intent (fix(bedrock): honor adaptive model max tokens #97343: Bedrock forwards configured adaptive caps while filtering known synthesized values; the separate Mistral repair keeps its historical safe fallback.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Jason (Json): Raw commit 55cf952 adds src/plugin-sdk/provider-catalog-live-normalize.internal.ts:241 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 55cf9523e015; files: src/plugin-sdk/provider-catalog-live-normalize.internal.ts)
  • Gustavo Madeira Santana: Raw commit c08f2aa adds src/agents/self-hosted-provider-defaults.ts:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: c08f2aa21a6e; files: src/agents/self-hosted-provider-defaults.ts)

PR surface

Source +73, Tests +131, Docs +2. Total +206 across 47 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 25 178 105 +73
Tests 16 154 23 +131
Docs 6 10 8 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 47 342 136 +206

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Synthesized output budgets Generic 8192 → 32768; custom onboarding 4096 → 32768; discovered local Ollama 8192 → 16384 These change request defaults; known smaller windows reduce the synthesized cap and saved numeric limits retain precedence.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: The change improves long-answer and tool-call budgets for models with missing output metadata.
  • merge-risk: 🚨 compatibility: Strict unknown-limit providers can reject larger synthesized caps; the maintainer-authored PR explicitly accepts this tradeoff.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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 execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-06T02:31:09.543Z sha 3e53bfad5c8b47bc13d837f29466d335001ea0ac :: blocked before merge. :: [P2] Preserve authored 32768-token caps in adaptive Bedrock requests
  • reviewed 2026-11-06T04:12:01.831Z sha c270a23 :: blocked before merge. :: none

Reviewed November 5, 2026, 11:25 PM ET / November 6, 2026, 04:25 UTC (Revision 3).

@VACInc
VACInc force-pushed the fix/default-max-output-32k branch from 3e53bfa to 21d9157 Compare November 6, 2026 03:43
Models with no authored, provider, or catalog output limit fell back to
8192 output tokens (4096 for custom providers added through onboarding),
which truncated long answers and large tool-call arguments.

One shared resolver now owns the invented cap: 32768, reduced to half
of a known context window below 64K so the prompt keeps room, never
below the former 8192 unless the window itself is smaller. Explicit
model and provider limits are unchanged. Self-hosted discovery and
setup, Ollama, LM Studio, llama.cpp, OpenRouter, Copilot, Hugging Face,
DeepInfra, Baseten, Synthetic, Hermes import, live catalog
normalization and the custom-provider wizard use it instead of their
own 8192 or 4096 constants.
@clawsweeper clawsweeper Bot removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 6, 2026
@VACInc

VACInc commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Nov 6, 2026
VACInc and others added 2 commits November 6, 2026 08:55
Preserve real note-module exports in the Doctor mock. Allocate the exact 305-line net regression growth for shared output-budget, explicit/provider/window controls, and non-mutating Doctor coverage without changing the shared test-line scalar.

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: VACInc <[email protected]>
@roboclaw-bot
roboclaw-bot merged commit 94e6734 into openclaw:main Nov 6, 2026
146 checks passed
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 7, 2026
…no known output limit (openclaw#193899)

* fix(models): raise the default output-token cap to 32768

Models with no authored, provider, or catalog output limit fell back to
8192 output tokens (4096 for custom providers added through onboarding),
which truncated long answers and large tool-call arguments.

One shared resolver now owns the invented cap: 32768, reduced to half
of a known context window below 64K so the prompt keeps room, never
below the former 8192 unless the window itself is smaller. Explicit
model and provider limits are unchanged. Self-hosted discovery and
setup, Ollama, LM Studio, llama.cpp, OpenRouter, Copilot, Hugging Face,
DeepInfra, Baseten, Synthetic, Hermes import, live catalog
normalization and the custom-provider wizard use it instead of their
own 8192 or 4096 constants.

* fix(doctor): report saved model output caps that pin a former onboarding default

* fix(doctor): print saved output cap notice in plain doctor

* test(models): satisfy output-budget CI guards

Preserve real note-module exports in the Doctor mock. Allocate the exact 305-line net regression growth for shared output-budget, explicit/provider/window controls, and non-mutating Doctor coverage without changing the shared test-line scalar.

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: VACInc <[email protected]>

---------

Co-authored-by: VACInc <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 10, 2026
Models without an authored, catalog, or provider output limit use the shared
context-sized 32768 default rather than an invented 8192/4096 cap. Preserve
explicit limits and add informational, non-mutating Doctor guidance for
saved former onboarding defaults.

Release adaptation: preserve release discovery/normalization and provider
factory layouts, the Mistral safe repair ceiling, Azure wizard defaults,
LM Studio served context, and existing SDK entrypoints. Port only the
Ollama cloud budget facts/helper and native num_predict ownership needed
by this change; keep explicit request and model-parameter precedence.
Do not import the broad #173844 repetition guard or #177454 refactor.
Use the baseline Doctor information renderer and factories without
unsupported docsUrl or main-only finding-storage assumptions. Add
release-native config-to-request and discovered/native output cap proof.
Carry known hosted routes through existing Ollama fallback, dynamic, and
setup builders, preserving bare local model behavior. Resolve the cloud
reference helper through the baseline provider-model-shared SDK export.

(cherry picked from commit 94e6734)

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: VACInc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 10, 2026
Follow-up to the reviewed #193899 release adaptation. Retain local-daemon remote tag identity and explicitly configured output caps through guided preparation. Five boundary cases add 49 net regression-test lines; reconcile only this change allocation from 507 to 556. Before: 4 failures; after: 68 passing tests plus final typed 16-test pass.

Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 12, 2026
Adapt #193899 and #196766 to the release model/Doctor owners. Share only
invented caps; preserve authored, provider, catalog and current Ollama cloud
limits. Recompute fresh LM Studio defaults after preferred context selection.
Doctor reports legacy saved caps without rewriting configuration.

Source: 94e6734
Companion: 3c5122a

Proof: real base regressions fail; current focused contracts total 493 passing
tests over 18 files, plus 127 provider sibling tests. Counts reuse unchanged
suite proof; no aggregate clean rerun claimed. Touched-source typecheck,
focused lint, formatting and diff checks pass. Independent full review clear;
follow-up fixture URL finding corrected and Doctor 13/13 passes.

Allocate 347 net regression lines (324+23) for context-sized defaults, explicit
limit controls, provider consumers and non-mutating Doctor behavior.

Gap: no real-agent configured-provider outbound-budget composition or live
provider/stable-upgrade proof. Release qualification remains with parent.

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: VACInc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 8cc0d68179c677a2609ff48e3fe7dda1ee4b3c04)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation extensions: amazon-bedrock extensions: baseten Extension: baseten extensions: copilot-proxy Extension: copilot-proxy extensions: deepinfra extensions: github-copilot extensions: huggingface extensions: llama-cpp extensions: lmstudio extensions: ollama extensions: openrouter extensions: synthetic gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: migrate-hermes proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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