Bound automatic compaction input to model capacity - #1160
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Warning Your free Security trial is over. An organization admin can activate billing to continue. Comment |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e3c854e298
ℹ️ 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 automatic_content_byte_target = u64::from(definition.context_window_tokens()) | ||
| .checked_sub(u64::from(definition.max_output_tokens())) | ||
| .and_then(NonZeroU64::new) |
There was a problem hiding this comment.
Bound the rendered compaction request, not raw content
When a frontier contains many small entries—or content requiring JSON escaping—this target does not actually bound the model input: bounded_safe_boundary counts only stored payload bytes, while load_context_compaction_range serializes every selected entry with IDs, type metadata, field names, delimiters, and escaping, and the request also adds the nonempty compaction system prompt. The selected prefix can therefore render far beyond context_window_tokens - max_output_tokens, causing the provider to reject the sole automatic compaction attempt and leaving the oversized queued turn unrecoverable. Compute the boundary from the rendered/token-counted request or reserve all serialization and prompt overhead.
AGENTS.md reference: AGENTS.md:L116-L120
Useful? React with 👍 / 👎.
| total.saturating_add(member.content_bytes.max(1)) | ||
| }); | ||
| let midpoint_weight = total_weight.div_ceil(2); | ||
| let target_weight = total_weight.div_ceil(2).min(content_byte_target); |
There was a problem hiding this comment.
Ensure one compaction can make the successor fit
When a session history is sufficiently larger than twice the model's input capacity, capping the summarized prefix at content_byte_target leaves a suffix that exceeds the same capacity even if the summary call itself fits and returns a minimal summary. The counted activation path then renders the successor, detects that it is still oversized, and returns ContextStillExceeded because this turn has already used its single automatic compaction; the queued turn is permanently stalled. The boundary strategy must either guarantee that the retained suffix plus summary can fit or support multiple bounded chunks before consuming the turn's sole attempt.
AGENTS.md reference: AGENTS.md:L252-L257
Useful? React with 👍 / 👎.
Rust coverage (report only)Report only. This measurement has no threshold, gates no merge, and
What this number does not measure
Per crate, least-covered first
25 files with the most uncovered lines
Measured at |
Codecov Report❌ Patch coverage is
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
This prevents a large accumulated transcript from making its own automatic summary request exceed the selected model's capacity.
Meaningfully changed lines: 112 (excluding lockfiles).
Numeric bounds added: none. The target is derived from the already configured per-model context window and maximum output reservation.
Validation
cargo fmt --all -- --checkpostgres-integrationCI is the authoritative complete-bar backstop.
Absorption ledger
eeee1c5b5in the inherited live stack.4cdc5dfbcin the inherited live stack.546600143in the inherited live stack.Stack base: #1159 (
agent/daemon-live-restore-call-lexing).