Key Points
This source-code review (dated 2026-04-18) compares kimi-cli (Python/asyncio) and crush (Go) across seven nested fault-tolerance layers that together determine an AI coding agent's sustained working capability. The central thesis: endurance comes from coordinated recovery, not any single feature.
Layer-by-Layer Findings
- Layer 1 — Tool-Level Fault Tolerance: Comparable. Both surface tool errors as LLM-visible results; both fail-open on hook failures (
toolset.py:190-218vsrunner.go:101-155). - Layer 2 — LLM Retry: Gap partially closed. kimi-cli uses
@tenacity.retrywith exponential backoff + jitter, precise status-code classification (429/500/502/503/504/timeout/empty), a three-stage connection recovery (401 OAuth refresh, provider rebuild viaRetryableChatProvider, exhaustion marker), and independent retry for compaction operations (kimisoul.py:842-854, 960-1134). crush now shipserrorx.Classify()with 15 FailoverReason types, exponential backoff (1s→2s→4s, max 3), andShouldCompress-driven auto-recovery — but lacks connection-level recovery, exhaustion markers, and compaction-op retry. - Layer 3 — Checkpoint + D-Mail Time Travel: Unique to kimi-cli. Every step appends a
{"role":"_checkpoint","id":N}entry tocontext.jsonl;revert_to(checkpoint_id)rotates files and replays line-by-line to any historical checkpoint. Tools can dispatch a D-Mail to a past checkpoint, which raisesBackToTheFuturein_step(), caught by_agent_loop(), triggeringrevert_to()+ message injection + loop continuation.asyncio.shieldprotects_grow_context()from Ctrl+C damage (kimisoul.py:721, 908-931, 889;context.py:135-200). - Layer 4 — Auto-Compaction: Gap substantially narrowed. kimi-cli uses
SimpleCompactionwith dual-trigger (should_auto_compact: proportion OR reserved-space), checkpoint anchor after compaction, and independent retry (kimisoul.py:701-718, 960-1047). crush usesStructuredCompressorwith three trigger points (preflight, per-turn, error-recovery), structured summaries (Goal/Progress/KeyDecisions/RelevantFiles/RemainingWork), FocusTopic guidance, incremental compression via PreviousSummary,pruneOldToolResultspreprocessing, and tool-pair sanitization — but lacks checkpoint anchor and independent compaction retry. - Layer 5 — Ralph Loop / FlowRunner: Unique to kimi-cli.
ralph_loop()builds a cyclic graph (BEGIN → execute → LLM self-evaluates CONTINUE/STOP → loop).max_ralph_iterations=-1yields effectively infinite loops (kimisoul.py:1175-1249). Plan/Yolo modes inject constraint reminders every N turns to prevent behavioral drift. crush agents run once per user prompt and stop. - Layer 6 — Shell-Level Safety Net: Design gap remains. kimi-cli's
while TrueREPL never exits;MaxStepsReachedis a soft limit prompting "Send another message to continue" thenreturn False; 7 fine-grained error categories (LLMNotSet/LLMNotSupported/401/402/403/Connection/Timeout/EmptyResponse/MaxSteps/Cancel); queued messages are drained after each turn with a 20-generation safety valve; completed background tasks auto-inject<system-reminder>to keep the agent working (shell/__init__.py:481, 810-931). crush's engine has 15FailoverReasontypes + grace call, but UI-layer classification is coarser and Cancel drops the message queue (agent.go:865-868). - Layer 7 — Session-Level Recovery: Unique to kimi-cli.
/undointeractive rollback with session fork + Reload;/forkbranches new sessions;wire.jsonlrebuilds any UI state;recover()scans background tasks on restart and marks heartbeat-expired ones lost (slash.py:725-787;session_fork.py:215-281;background/manager.py:397-458). crush has no branching, no rollback, no restart recovery. - P0 — Introduce Checkpoint mechanism (foundation for revert, Cancel preservation, D-Mail).
- P0 — Introduce Ralph Loop-style iteration (LLM self-evaluates completion and continues).
- P1 — Add connection-recovery layer + exhaustion marker + independent compaction retry (errorx framework already present).
- P1 — Soft-continue prompt after MaxStepsReached + preserve queue on Cancel.
- P2 — D-Mail / BackToTheFuture time-travel reverts.
- P2 — Fine-grained UI error classification (engine already has 15 reasons; surface them).
Gap Matrix
| Layer | kimi-cli | crush | |---|---|---| | 1. Tool errors | ✅ | ✅ (parity) | | 2. LLM retry + connection recovery + exhaustion marker | ✅ full | ⚠️ errorx retry + compress recovery; no connection rebuild, no exhaustion marker | | 3. Checkpoint + D-Mail | ✅ | ❌ | | 4. Auto-Compaction + independent retry | ✅ full | ⚠️ multi-trigger + structured incremental; no checkpoint anchor, no independent retry | | 5. Ralph Loop auto-iteration | ✅ | ❌ | | 6. Shell safety net + queue drain | ✅ | ⚠️ engine 15 reasons + grace call; UI coarse; Cancel drops queue | | 7. /undo + /fork + restart recovery | ✅ | ❌ |
Recommendations for crush Evolution
errorx + StructuredCompressor, but Checkpoints (Layer 3), Ralph Loop (Layer 5), and session-level recovery (Layer 7) remain the differentiating core of the sustained-agent experience.---
*Maintenance note: 2026-04-18 calibration update corrects Layer 2/4/6 crush assessments to reflect newly integrated errorx / StructuredCompressor capabilities.*