Hmbown/CodeWhale · error
a fresh automatic compaction id cannot be pre-canceled
Error message
a fresh automatic compaction id cannot be pre-canceled
What it means
When auto-compaction starts, a freshly generated compaction id is expected to never appear in the pre-canceled set, so the code asserts that a cancel-check on it is false. Firing would mean id generation collided or cancellation state leaked across turns — an internal logic bug.
Source
Thrown at crates/tui/src/core/engine/turn_loop.rs:724
billed_input_tokens,
) {
Some(self.prepare_compaction_envelope(auto_compaction_config))
} else {
None
};
if let Some(prepared) = prepared
&& crate::compaction::should_compact_with_billed(
&self.session.messages,
self.session.system_prompt.as_ref(),
&prepared,
billed_input_tokens,
)
{
let compaction_id = format!("compact_{}", &uuid::Uuid::new_v4().to_string()[..8]);
let compaction_cancel = self
.claim_compaction(&compaction_id)
.expect("a fresh automatic compaction id cannot be pre-canceled");
self.emit_compaction_started(
compaction_id.clone(),
true,
"Auto context compaction started".to_string(),
)
.await;
let auto_messages_before = self.session.messages.len();
let auto_tokens_before = self.estimated_input_tokens();
let turn_cancel = self.cancel_token.clone();
let (compaction_result, turn_was_canceled) = tokio::select! {
biased;
_ = turn_cancel.cancelled() => (None, true),
_ = compaction_cancel.cancelled() => (None, false),
result = compact_messages_safe(
client.as_ref(),
&self.session.messages,
self.session.system_prompt.as_ref(),
&prepared,View on GitHub (pinned to 0c42157ee5)
Solutions
- Verify canceled-compaction ids are cleared per turn
- Check for uuid collisions or reuse of a stale compaction id
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/tui/src/core/engine/turn_loop.rs:724 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/a98f8274a67cf531.
Report an issue: GitHub.