Hmbown/CodeWhale · error
Failed to persist compaction
Error message
Failed to persist compaction: {persistence_error} What it means
Raised in the compaction preparation path when the durable store fails to persist the compaction turn record or update the thread pointer (`save_turn`/`save_thread`), and the subsequent cleanup (`cleanup_unaccepted_turn_records`) succeeds. The active-turn slot and route identity are rolled back; the store is left consistent, so the compaction can simply be retried.
Solutions
- Read `{persistence_error}` — fix the storage root cause (free disk space, fix permissions, repair store).
- Retry the compaction once storage is healthy; state was fully rolled back.
- If the store is corrupt, back it up and rebuild the thread store.
- Check for competing processes locking the codewhale data directory.
Defensive patterns
Strategy: retry
Try / catch
match runtime.compact_thread(&thread_id, req).await {
Err(e) if e.to_string().contains("Failed to persist compaction")
&& !e.to_string().contains("cleanup also failed") => {
// state rolled back cleanly; fix storage then retry
}
r => r?,
} Prevention
- Ensure free disk space before long compaction-heavy sessions.
- Keep the data directory writable and on healthy storage.
- Avoid competing processes on the same data directory.
- Repair or rebuild a corrupt store promptly.
When it happens
Trigger: Calling `compact_thread` when the persistence closure returns Err (disk full, store lock contention, corrupt store) while cleanup of the unaccepted turn records succeeds.
Common situations: Disk full during a compaction; SQLite/file-store corruption after a crash; another process holding the thread mutation lock; read-only data directory.
Related errors
- Failed to persist compaction
- Failed to persist steer
- Failed to persist turn
- Failed to persist turn
- cannot be empty
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/143e976aee4057cf.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/runtime_threads.rs:10649
});
state.route_identity = route_identity;
state.route_model = route_model;
let persistence_result = (|| -> Result<()> {
self.store.save_turn(&turn)?;
current_thread.latest_turn_id = Some(turn_id.clone());
current_thread.updated_at = now;
self.store.save_thread(¤t_thread)
})();
if let Err(persistence_error) = persistence_result {
let cleanup_error = self
.cleanup_unaccepted_turn_records(&turn_id, None, None)
.err();
state.active_turn = None;
state.route_identity = previous_active_route.0;
state.route_model = previous_active_route.1;
return match cleanup_error {
None => Err(anyhow!("Failed to persist compaction: {persistence_error}")),
Some(cleanup_error) => Err(anyhow!(
"Failed to persist compaction: {persistence_error}; cleanup also failed: {cleanup_error}"
)),
};
}
self.register_runtime_usage_sink(&turn_id);
let policy = RuntimePolicyProjection::from_persisted(
¤t_thread.mode,
current_thread.permission_posture.as_deref(),
current_thread.auto_approve,
);
engine.publish_turn_authority(
policy.mode,
current_thread.allow_shell,
current_thread.trust_mode,
policy.auto_approve(),
policy.permission,View on GitHub (pinned to 73e0f67d83)