Skip to main content

Overview

Execution retrospective lets an agent “rewind” its conversation to an earlier checkpoint when it realizes it has been going in circles or took a wrong path. Inspired by kimi-cli’s D-Mail mechanism, this capability injects visible [CHECKPOINT N] markers before each step. When the agent calls execution_retrospective(checkpoint_id, guidance), the message context is truncated to before that checkpoint and the guidance is injected as a message from the agent’s “future self”. Key properties:
  • Only the message buffer is rewound — execution history (steps, token usage) is preserved
  • Side effects are NOT undone — file changes, API calls remain; guidance should account for them
  • Checkpoint markers are visible to the LLM — the agent can reference them by ID
  • onRewind callback — extension point for user-defined self-improvement (logging, memory, prompt tuning)
This significantly reduces wasted steps by:
  • Cutting dead-end exploration from the context window
  • Providing focused guidance to the agent’s “past self”
  • Preserving full execution history for observability
Key concepts:
  • UseExecutionRetrospective: Capability that adds checkpoint markers, rewind logic, and system prompt instructions
  • RetrospectivePolicy: Configuration (maxRewinds, systemPromptInstructions)
  • onRewind: User callback invoked on every rewind with the result and agent state
  • AgentEventConsoleObserver: Shows checkpoint injection, tool calls, and step progression

Example