Hmbown/CodeWhale · error
Failed to persist turn: {persistence_error}
Error message
Failed to persist turn: {persistence_error} What it means
Saving the accepted turn's durable state (user item, turn, thread) failed partway; the code then attempts cleanup of the unaccepted turn so memory and disk stay consistent, and surfaces the persistence error with the cleanup outcome.
Source
Thrown at crates/tui/src/runtime_threads.rs:6146
state.route_identity = provider_identity;
state.route_model.clone_from(&model);
let persistence_result = (|| -> Result<()> {
self.store.save_item(&user_item)?;
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, Some(&user_item_id))
.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 turn: {persistence_error}")),
Some(cleanup_error) => Err(anyhow!(
"Failed to persist turn: {persistence_error}; cleanup also failed: {cleanup_error}"
)),
};
}
self.register_runtime_usage_sink(&turn_id);
// Sending through an owned permit cannot await or fail. From this
// point the engine owns the operation and the spawned task owns
// lifecycle events, monitoring, and terminal cleanup even if the
// HTTP/client future is dropped.
engine.publish_turn_authority(
mode,
allow_shell,
trust_mode,
auto_approve,
policy.permission,
configured_sandbox_mode,View on GitHub (pinned to 0c42157ee5)
Solutions
- Check disk space and store write permissions
- Verify the thread store location is writable and not locked
- Retry the turn after fixing the storage issue
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/tui/src/runtime_threads.rs:6146 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/4bd6fe6d0924ffee.
Report an issue: GitHub.