xai-org/grok-build · error
a successful full-replace sample stashes its CompactOutput
Error message
a successful full-replace sample stashes its CompactOutput
What it means
During two-pass compaction, when a compact summary was produced the code needs the sampler's stashed `CompactOutput` from the last successful full-replace sample and unwraps with expect. The invariant: if `compact_summary` is Some, a successful full-replace sample must have been recorded; the panic signals that bookkeeping broke.
Source
Thrown at crates/codegen/xai-grok-shell/src/session/compaction.rs:1315
user_context.as_deref(),
use_short_prompt,
&sampling_config.model,
trigger,
compact_summary
.as_deref()
.or(telemetry.last_rejected_summary.as_deref()),
last_error.as_ref(),
telemetry.attempts,
telemetry.attempt_details,
started_at,
);
}
let compact_output = match compact_summary {
Some(_) => match two_pass_output {
Some(tp) => tp,
None => sampler
.take_last_success()
.expect("a successful full-replace sample stashes its CompactOutput"),
},
None => {
let span = tracing::Span::current();
span.record("compaction_attempts", telemetry.attempts as i64);
span.record(
"compaction_degenerate_rejections",
telemetry.degenerate_rejections as i64,
);
span.record(
"compaction_input_overflow_rejections",
input_overflow_rejections as i64,
);
span.record(
"compaction_deterministic_rejections",
telemetry.deterministic_rejections as i64,
);
span.record(
"compaction_transient_rejections",View on GitHub (pinned to bc7f02eddd)
Solutions
- Trace why the sampler recorded no success: log each full-replace sample attempt and its accept/reject outcome.
- Ensure compact_summary is only set when a successful full-replace sample was stashed (make the coupling explicit in code).
- Check degenerate-rejection logic — a rejected sample shouldn't coexist with a set compact_summary.
- Propagate a CompactionError instead of panicking so the session can fall back to no-compaction.
Example fix
// before
.expect("a successful full-replace sample stashes its CompactOutput")
// after
.ok_or_else(|| CompactionError::SamplerStateInconsistent)? Defensive patterns
Strategy: type-guard
Validate before calling
// only consume the sampler when a success was actually recorded
if compact_summary.is_some() && two_pass_output.is_none() && !sampler.has_last_success() {
return Err(CompactionError::SamplerStateInconsistent);
} Type guard
fn sampler_ready(sampler: &Sampler) -> bool {
sampler.has_last_success()
} Try / catch
let out = sampler.take_last_success().ok_or_else(|| {
tracing::error!("summary present without a successful full-replace sample");
CompactionError::SamplerStateInconsistent
})?; Prevention
- Set compact_summary only in the same code path that stashes the sample success
- Log every sample accept/reject to keep sampler state observable
- Add a test where all full-replace samples degenerate and assert no summary is produced
When it happens
Trigger: `compact_summary` is Some but `two_pass_output` is None and `sampler.take_last_success()` returns None — i.e. the summary was derived without a corresponding successful full-replace sample being stashed in the sampler.
Common situations: Sampler rejection bookkeeping drift after a refactor of the sample/summary flow; compaction runs where all full-replace samples degenerated yet a summary was still produced; interplay between retry attempts and sampler state on repeated compaction calls.
Related errors
- just created
- set on the use_leader path
- Task panicked: {}
- send_with_retry_escaping_pool ran at least one attempt
- failed to build shared blocking HTTP client
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/dfd97c0302e06c18.
Report an issue: GitHub.