Repository navigation
feat(runtime): lift the output cap to the model ceiling where reasoning shares it (RR8.3) - #200
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48637f0e89
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
48637f0 to
8062cc6
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8062cc6848
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
8062cc6 to
2a4cdfb
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2a4cdfbc1a
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
2a4cdfb to
d5a2eb7
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d5a2eb72e5
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e798b17fbe
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ng shares it (RR8.3) The compiled 16 384 default is sized for visible output. On Anthropic Messages, Bedrock Converse, and Anthropic models behind an OpenAI-compatible gateway, extended thinking is billed inside the same max_tokens, so a set reasoning_effort spent the whole cap on hidden reasoning and the run saw an empty truncation. With effort set on such a route, the wire cap now resolves to the catalog ceiling unless the operator configured max_output_tokens themselves (any non-compiled provenance). Run budgets still bound spend. Also the original RR8 item: a per-session max_output_tokens persisted below the current default (2 048 / 4 096 from older releases) is treated as unset. Tests: reasoning_effort_lifts_the_default_output_cap_where_thinking_shares_it (Anthropic wire, gateway id, no effort, explicit override/config, Responses wire, no catalog ceiling), a_persisted_output_limit_below_the_default_is_treated_as_unset. Linear: ENG-955
…piled default session cap as unset (RR8.3 review) Four review findings on the effort-aware output cap: - A managed `policy.max_output_tokens` validated the configured value but the lift then replaced it with the catalog ceiling. The lifted cap is now clamped to the policy ceiling. - `reasoning_effort: none` disables thinking; there is no hidden budget to make room for, so it no longer triggers the lift (like `Default`). - The TUI and headless paths materialise the compiled default (16 384) into every new session's `ModelSelection`, which the loader then saw as a `Runtime` override and refused to lift. That value is treated as unset at load, exactly like the older 2 048 / 4 096 defaults, so the lift applies to ordinary sessions. Any other persisted value is still an operator's choice. - Bedrock Converse is removed from the documented lift: effort is unsupported on that wire and rejected at load, so the branch could never run. Linear: ENG-955
….3 review 2) Treating a persisted 16 384 as unset discarded an explicit `--max-output-tokens 16384` (and, via the legacy list, 4 096 / 2 048). The value-based filter is withdrawn for the current default. Instead the source of the problem is fixed: the TUI pickers, the configured-model default, the legacy worker selection, and the headless path no longer materialise the compiled default into `ModelSelection.max_output_tokens`. A new session row pins the cap only when its provenance is not `Compiled`, so the row records a choice, never the default of its day, and the reasoning-aware lift applies to ordinary sessions. Legacy 2 048 / 4 096 rows are still treated as unset. `ClientSnapshot::provenance` is exposed for the client catalog path. Test: a_new_session_pins_the_output_cap_only_when_it_was_chosen. Linear: ENG-955
…ap (RR8.3 review 3) The lifted wire cap fed the session storage backstop, which reserves 32 bytes per output token against a 4 MiB store: a 128 000-token ceiling reserved 4 161 568 bytes and left 32 KiB for the whole prompt, so every effort-enabled Anthropic session would have been rejected as an irreducible storage overflow before its first request. The reserve is now capped at what the 16 384 default yields; the enlarged wire cap exists for hidden reasoning, which is never persisted as transcript. Window arithmetic still sees the real cap. Test: a_lifted_wire_cap_does_not_consume_the_storage_backstop. Also: `max_output_tokens: Clear` restores the compiled default and now restores compiled provenance too, instead of recording the clearing layer as an operator's cap. Test: clearing_max_output_tokens_restores_compiled_provenance. protocol.md's description of the resolved cap notes the exception. Linear: ENG-955
e798b17 to
53c470a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 53c470acab
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let output_tokens = u64::from(input.max_output_tokens); | ||
| let storage_reserve_bytes = output_tokens | ||
| .saturating_mul(CONSERVATIVE_OUTPUT_BYTES_PER_TOKEN) | ||
| .min(MAX_OUTPUT_STORAGE_RESERVE_BYTES) |
There was a problem hiding this comment.
Reserve space for persisted Anthropic reasoning replay
When an effort-enabled Anthropic turn produces more than 512 KiB of hidden thinking replay after the prompt/history has consumed the remaining 4 MiB allowance, this clamp admits the request even though completed thinking is serialized into ProviderEvent::Replay, attached to the assistant message, and counted and persisted at turn commit. reserve_context_capacity can therefore fail only after the provider has completed and incurred cost, leaving the completed turn unpersisted. Fresh evidence beyond the earlier visible-output-reserve discussion is that this supposedly storage-free hidden reasoning is itself persisted as opaque continuation replay, so its storage must be represented in admission.
AGENTS.md reference: AGENTS.md:L79-L82
Useful? React with 👍 / 👎.
| Field::Missing => {} | ||
| Field::Set(_) => self.provenance.max_output_tokens = Some(source.clone()), | ||
| Field::Clear => { | ||
| self.provenance.max_output_tokens = Some(SourceIdentity::virtual_source( |
There was a problem hiding this comment.
Retain the clearing layer in max-output provenance
When a project, inline, or managed layer uses max_output_tokens: Clear, replacing its source with a synthetic compiled source makes qq config explain max_output_tokens report compiled defaults instead of the layer that actually cleared the earlier cap. Fresh evidence beyond the earlier reasoning-lift fix is the user-facing diagnostic regression: the repository documents config explain as identifying which layer set a value, and other cleared fields explicitly retain the clearing source. Track set-versus-clear separately for lift decisions while preserving the real provenance here.
Useful? React with 👍 / 👎.
| qq_provider::ReasoningEffort::Default | qq_provider::ReasoningEffort::None | ||
| ) | ||
| }) && (api == ProviderApi::AnthropicMessages | ||
| || anthropic_model_behind_a_gateway( |
There was a problem hiding this comment.
Restrict gateway lifting to Chat Completions
When a custom or LiteLLM route uses OpenAiResponses with an Anthropic-looking ID such as us.anthropic.claude-…, this helper is evaluated without checking the resolved API and raises the compiled 16,384 cap to the catalog ceiling. That contradicts this change's explicit Responses-wire behavior—the new test says those routes retain the default—but the fixture uses test-model and therefore misses this branch. Require ProviderApi::OpenAiChatCompletions for gateway detection while retaining the direct AnthropicMessages case.
Useful? React with 👍 / 👎.
| (Some(model_limit), true) => snapshot | ||
| .policy() | ||
| .max_output_tokens() | ||
| .map_or(model_limit, |ceiling| model_limit.min(ceiling)), |
There was a problem hiding this comment.
Carry the reasoning-aware allowance into compaction
When this branch lifts a high/max-effort Anthropic session, automatic, manual, and in-run compaction still begin summarizer requests at the fixed 8,192-token allowance while forwarding the same reasoning effort. The motivating provider behavior can consume even 16,384 tokens entirely on hidden reasoning: in-run summarization immediately fails on the empty truncation, while the other compaction path can only double once to 16,384 before failing. The session therefore becomes unable to compact once its history fills even though ordinary turns were repaired; carry the reasoning-aware allowance into summarization or suppress the effort there.
Useful? React with 👍 / 👎.
RR8.3: effort-aware output ceiling
Spec: docs/plans/run-reliability.md (RR8) Linear: ENG-955 Stack: 3/4, on ENG-954
What changed
resolved_model_for_snapshot: when a reasoning effort is set and the route's thinking is billed insidemax_tokens(Anthropic Messages, or an Anthropic model behind an OpenAI-compatible gateway — recognised by catalog canonical id or the vendor segment of the gateway id such asus.anthropic.claude-…), the wire cap resolves to the catalog ceiling instead of the compiled 16 384 default.max_output_tokens(any non-Compiledprovenance: config layer or runtime override) is honoured verbatim. Responses-wire models are unchanged. Run budgets still bound spend: the cap stops being a wire parameter that strangles reasoning and stays a cost ceiling.LEGACY_DEFAULT_MAX_OUTPUT_TOKENS = [2 048, 4 096]) records the default of its day, not a choice, and is treated as unset at load; any other persisted value is kept. New rows never persist the compiled default (see review round). The lift is bounded by a managedpolicy.max_output_tokens, andreasoning_effort: nonedoes not trigger it.How verified
reasoning_effort_lifts_the_default_output_cap_where_thinking_shares_it: Anthropic wire → 128 000; gateway id → 128 000; no effort → default; override 4 096 / config 8 192 honoured; Responses wire → default; no catalog ceiling → default;none→ default; managed policy 32 000 binds.a_persisted_output_limit_below_the_default_is_treated_as_unset(2 048/4 096 → None; 123, 16 384, 32 768 kept).a_new_session_pins_the_output_cap_only_when_it_was_chosen(compiled default → None; override 16 384 / 4 096 kept).Docs
docs/design/architecture.md§ resolved model.Compatibility
max_tokenssent for effort-pinned Anthropic routes that relied on the compiled default.ResolvedModel.max_output_tokensrecords the effective value as before. No protocol/schema change.Follow-ups
effort: max(not run here).Evidence
Operator store, read-only: two
provider_output_truncatedruns onlitellm/us.anthropic.claude-fable-5-1(2026-09-23, 2026-09-25). Every failing turn persistedassistant_content_json = []withoutput_tokens = 16384; every continuation request hadinput_tokens = 2uncached (byte-identical resend). Route-wide since 09-10: 3 935 turns, 49 truncated, 31 empty, ≈ 671 k output tokens and ≈ 2 h wall producing nothing.Review round (Codex)
policy.max_output_tokens.reasoning_effort: noneno longer triggers the lift.Runtimeoverride and refused to lift, so the feature did not apply to ordinary sessions. Round one filtered the value at load, which would have discarded an explicit--max-output-tokens 16384; that is withdrawn. Instead pickers, the configured default, the worker selection and the headless path materialisemax_output_tokensintoModelSelectiononly when its provenance is notCompiled(chosen_max_output_tokens), so a row records a choice, never the default of its day. Legacy 2 048 / 4 096 rows are still treated as unset.effortfield one commit early and did not compile standalone; the hunk moved to feat(delegation): choose a sub-agent's reasoning effort from its roster role (RR8.4) #201.a_lifted_wire_cap_does_not_consume_the_storage_backstop.max_output_tokens: Clearrestores compiled provenance instead of reading as an operator pin. protocol.md notes the cap exception.route_directcopying the fallback cap (opt-in Jev routing, out of scope); nestedgateway/bedrock/anthropic.…ids (hypothetical).Gates (run on the stack tip and on this branch's tip)
cargo fmt --all -- --check✅cargo clippy --workspace --all-targets --all-features -- -D warnings✅ (every branch tip)cargo test --workspace✅ all passing at the stack tip; each intermediate tip compiles and passesqq/qq-core/qq-provideron its own.cargo test -p qq-provider --no-default-features --features test-support✅ 184 passed.qq-clientbuild ✅