Hmbown/CodeWhale · error

Failed to persist steer

Error message

Failed to persist steer: {error}; cleanup also failed: {cleanup_error}

What it means

Raised in the steer path when persisting the steer item/turn update fails (`store.load_turn`, `save_item`, or `save_turn`) AND the compensating cleanup (`store.remove_item` of the queued steer item) also fails. Both errors are chained into a single anyhow message so the operator sees the write failure and the orphaned-record failure together.

Solutions

  1. Fix the underlying storage problem named by `{error}` first (disk space, permissions, corrupt store).
  2. Manually remove the orphaned steer item (`{cleanup_error}` shows removal failed) from the thread store.
  3. Retry the steer once the store is healthy; the failed steer was rolled back only if cleanup succeeded.
  4. If the turn became non-InProgress, re-check turn status — the steer may be obsolete anyway.
Defensive patterns

Strategy: try-catch

Try / catch

match runtime.steer_turn(&thread_id, &turn_id, text).await {
    Err(e) if e.to_string().contains("cleanup also failed") => {
        // storage fault: free space / repair store, remove orphaned steer item, retry
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling the steer API while the persistence closure returns Err (e.g. store write error, turn no longer InProgress race lost) and `store.remove_item(&item.id)` for the queued steer item also returns Err.

Common situations: Disk full / I/O failure during a steer; the turn reached terminal status between the pre-checks and the write, and cleanup then hit the same storage fault; contention on the store's turn mutation lock from another process.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/3b0113d8a4d8c9b3. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/runtime_threads.rs:10470

                if turn.status != RuntimeTurnStatus::InProgress {
                    bail!("Turn {turn_id} is no longer in progress and cannot be steered");
                }
                self.store.save_item(&item)?;
                // `steer_count` counts steers the model actually received, so
                // it rises in the settlement path, not here.
                if !turn.item_ids.iter().any(|id| id == &item.id) {
                    turn.item_ids.push(item.id.clone());
                }
                self.store.save_turn(&turn)?;
                Ok(turn)
            })();
            let turn = match persistence {
                Ok(turn) => turn,
                Err(error) => {
                    let cleanup = self.store.remove_item(&item.id);
                    return match cleanup {
                        Ok(()) => Err(error),
                        Err(cleanup_error) => Err(anyhow!(
                            "Failed to persist steer: {error}; cleanup also failed: {cleanup_error}"
                        )),
                    };
                }
            };
            // The reserved send has no await/failure point. From here the
            // engine and durable record agree even if the API caller drops.
            let outcome_rx = permit.send_with_outcome(prompt.clone());
            touch_lru(&mut active.lru, thread_id);
            queued_turn = turn.clone();
            self.spawn_steer_settlement(turn, item, prompt, outcome_rx)
        };

        // The settler owns the verdict; this is only an observation of it.
        // Steering a streaming turn settles in milliseconds, so the caller
        // almost always gets the truth in-band. Behind a long tool call the
        // engine will not look at its mailbox for minutes, and an API request
        // must not hang that long — so the wait is bounded and the caller

View on GitHub (pinned to 73e0f67d83)