Repository navigation
fix(runtime): make the empty-truncation cap raise reachable in sessions - #216
Conversation
A session run starts at the resolved cap, which was also the raise limit, so max_output_tokens >= ceiling always held: RR8.1's raise-once never fired and the error called the configured cap the "model ceiling". Compiled plans now carry a separate output ceiling (catalog limit, bounded by policy); the raise doubles toward it and the error names it. A turn that streamed a complete tool call and was then cut dropped the call and was resent unchanged up to three times; while the cap can still grow it now takes the same raise, otherwise it continues as before. Refs: ENG-973
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: 53a812bcf7
ℹ️ 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".
…he plan; honest empty-turn count Review (Codex, #216): - The raised retry cap was sent, but model_turns.model_json and model_turn_completed kept the claim-time cap. Each Prepared now updates the per-turn model record to the cap actually sent. Regression: a_raised_output_cap_is_what_the_retried_turn_records (fails without). - output_ceiling is outside the digest, so lowering only a managed policy.max_output_tokens revalidated the old plan. It joins the live bindings (RuntimeSwitches) beside jev_approval. The ceiling test now lowers the managed file and expects the new ceiling (fails without). - A call-then-cut turn consumed the raise and then counted as a reasoning-only turn in the terminal diagnostic. A separate count of genuinely empty turns drives the message. Regression: the_reasoning_diagnostic_counts_only_turns_that_produced_nothing. Also merges #215 into this branch. Refs: ENG-973
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a1a9c4c04
ℹ️ 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".
Conflicts: the plan/runtime/binding fields #214 changed (jev_approval -> approval_delegate_identity) beside this PR's output_ceiling. Kept both. Review (Codex, #216): - The reasoning-only streak was reset only on truncation paths, so empty -> completed tool turn -> empty reported two consecutive empty turns. A completed turn now resets it. Regression a_completed_tool_turn_resets_the_reasoning_only_streak (reports 2 without). - When managed policy set the raise ceiling, the error called it the model ceiling and recommended raising max_output_tokens, which cannot help. The ceiling is now OutputCeiling { tokens, policy_bound }, and the message names the policy and the remedies that work. Regression a_policy_bound_ceiling_names_the_policy_not_max_output_tokens. - configuration.md and architecture.md now say the one recovery retry may exceed the configured max_output_tokens (never a managed policy value), and that the policy value is the hard ceiling. Refs: ENG-973
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 451b1efab0
ℹ️ 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".
| if streamed_visible_output { | ||
| reasoning_only_truncations = 0; | ||
| } else { | ||
| reasoning_only_truncations = | ||
| reasoning_only_truncations.saturating_add(1); |
There was a problem hiding this comment.
Reset the empty-turn streak after visible provider faults
When an empty truncation consumes the raise, a subsequent recoverable provider fault streams text, and the retry is then empty and truncated, this counter remains at 1 because the turn_fault branch appends the visible partial reply and continues before either reset below. The final increment therefore reports two consecutive turns with no visible output and attributes both to reasoning even though the intervening turn produced text. Fresh evidence beyond the earlier completed-tool-turn report is this recoverable-fault path; reset the streak there whenever the partial turn had text or a completed call, and cover the empty → visible fault → empty sequence.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Won't fix for v0.1.5: it only affects the number in the terminal error message ("N consecutive turns") after a recoverable provider fault that streamed text. It has no effect on control flow, retries or spend.
| let output_ceiling = snapshot | ||
| .providers() | ||
| .get(snapshot.model().provider()) | ||
| .and_then(|provider| provider.models().get(snapshot.model().model())) | ||
| .and_then(qq_config::ModelMetadata::max_output_tokens) |
There was a problem hiding this comment.
Validate the recovery ceiling against codec limits
For Google Generate Content or Bedrock, if model metadata declares a ceiling above i32::MAX while the configured initial cap remains representable (for example, 4 billion versus 1.5 billion), this stores the unrepresentable catalog value. resolved_model_for_snapshot validates only the initial resolved cap, so the plan loads successfully, but the first empty truncation can double the request to 3 billion and the Google/Bedrock adapter then rejects the retry during its i32 conversion instead of performing the promised recovery. Validate the recovery ceiling against the selected wire codec when constructing the plan.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Won't fix: it needs catalog metadata declaring an output limit above 2³¹ tokens, which no real model has. The initial cap is already validated; a follow-up can clamp the ceiling to the codec's range if such metadata ever appears.
| empty_output_retries += 1; | ||
| max_output_tokens = max_output_tokens | ||
| .saturating_mul(2) | ||
| .min(model_max_output_tokens); | ||
| .min(output_ceiling); |
There was a problem hiding this comment.
Restore the configured cap after the recovery retry
When the raised retry completes with a tool call, every subsequent post-tool turn in the same run still uses the doubled cap because this run-local value is never restored. That contradicts the public contract in docs/guide/configuration.md:69, which limits the exception to “that one retry,” and can multiply latency or spend across a long tool loop despite the operator's lower per-turn setting. Fresh evidence beyond the earlier documentation finding is that the mutation persists after the retry completes; scope the raised value to the recovery request or document and enforce the broader exception.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Acknowledged. The raised cap persisting for the rest of the run after a recovery is real, but it only happens after an all-reasoning truncation, and it stays bounded by the model limit, managed policy and run budgets. Follow-up: either restore the configured cap after the retry or reword the guide to "for the rest of that run".
| max_output_tokens = max_output_tokens | ||
| .saturating_mul(2) | ||
| .min(model_max_output_tokens); | ||
| .min(output_ceiling); |
There was a problem hiding this comment.
Keep the recovery retry within the context window
When the current input fits the model window only with the configured cap—for example, a 15k-token irreducible prompt with a 16k cap and a 32k window—an empty first turn blindly raises the next request to 32k. On the retry, the context planner rejects input + max_output_tokens before polling the provider, and there is no in-run compaction boundary because the empty turn added no usable transcript, so the new recovery path fails without ever sending its retry even though a smaller increase would fit. Limit the raised cap to the remaining context capacity, or decline the raise with the output-truncation diagnostic when no larger request can fit.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Won't fix for v0.1.5: when the input fits only at the configured cap, the run fails either way (the reasoning-only turn can't produce output at that cap). This changes which error is shown, not the outcome. Follow-up: clamp the raise to the remaining context capacity so the truncation diagnostic is the one reported.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
1 similar comment
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…#217) * fix(tools): refuse symlinked init targets and bound ignore-file reads qq init --project --force followed a symlinked .qq or .qq/config.ron and truncated the link's target; both are now refused with InitError::Symlink. Ignore files (.gitignore, .ignore, .qqignore) were read whole whatever their size, and a FIFO in their place blocked the walk at open. Only a regular file of at most 256 KiB is read now; anything else counts as absent. search_walk bench before/after (10k files, 20 iterations): content_rare 5306/5055 us, definition_full 21847/21697 us, tree_depth2 5350/5235 us; no regression from the added stat. Refs: ENG-974 * fix(tools): make the init symlink refusal and the ignore-file type check atomic with the open Review (Codex, #217): both checks ran before the open, so a writer in the directory could swap in a symlink (init --force would then truncate the target) or a FIFO (the walk would block at open) in between. - qq init opens the target relative to an O_NOFOLLOW|O_DIRECTORY handle on its directory, with O_NOFOLLOW (and O_EXCL unless --force); ELOOP/ENOTDIR map to InitError::Symlink. Root enables rustix's fs feature on unix (no new crate or version: Cargo.lock gains only the qq -> rustix edge). - Ignore files open O_NOFOLLOW|O_NONBLOCK and the type and size are checked on the opened descriptor. Regressions (each fails on the old check-then-open code): the_open_itself_refuses_links_swapped_in_after_the_check, an_ignore_file_swapped_for_a_fifo_or_link_after_listing_is_not_read. search_walk bench unchanged within noise (tree_depth2 5069 us, content_rare 5396 us). Also merges #216 into this branch. Refs: ENG-974 * fix(tools): refuse ignore-file symlinks through cap-primitives' follow option Pre-push review: the O_NOFOLLOW|O_NONBLOCK flags were passed as raw custom flags. cap-primitives' manual path resolution (macOS, or Linux without openat2) reads ELOOP as a symlink to follow unless its own follow option is No, so a symlinked .gitignore could still be read there. Set follow(No) and nonblock through cap-primitives' options instead. Refs: ENG-974
Stack ENG-968 (v0.1.5 readiness), 5 of 9. Merge in order; diff shown is this layer only.
Bug
RR8.1 (#198) raises the cap once on an all-reasoning truncation, but session runs start at the resolved cap, which was also the raise limit:
max_output_tokens >= ceilingalways held, so the raise never fired and the error called the configured cap (e.g. 16384) the "model ceiling". Separately, a turn that streamed a complete tool call and was then cut dropped the call and was resent byte-identically up to 3 times.Fix
Plans carry a separate
output_ceiling(catalog limit, bounded bypolicy.max_output_tokens;Nonewhen unknown). The raise doubles toward it; the error names it. A call-then-cut turn takes the raise while the cap can grow, otherwise continues as before. Not in the digest; no protocol/store change.Tests
a_session_shaped_run_raises_an_empty_truncated_cap_toward_the_catalog_ceilinga_tool_call_then_cut_turn_changes_the_resend_when_it_cana_plan_carries_the_catalog_output_ceiling_bounded_by_policyPerf: one comparison per truncated turn; no hot-path change. Docs:
architecture.md§ run loop. Linear: ENG-973 (related ENG-870).Verification (top of stack)
cargo test --workspace1970 passed / 0 failed / 7 ignored;cargo clippy --workspace --all-targets --all-features -- -D warningsclean;cargo fmt --all -- --checkclean;cargo test -p qq-provider --no-default-features --features test-supportpassed.