Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Code Agent Dissection (10): When the Agent Crashes, How Does It Recover? Where Is Conversation History Stored?

说明与用途

MyCodeAgent 使用 JSONL 事件流在进程崩溃后恢复对话历史和工具状态,消除数据丢失和文件编辑不完整的问题。

问题

Agent conversation history is lost on crash and tool calls may leave files in an inconsistent state.

结果

Using an event‑stream transcript, MyCodeAgent restores conversation history and tool state after crashes, eliminating data loss and inconsistent file edits.

工作流

  • 1. Agent emits events (message, state_transition, tool_lifecycle, checkpoint, terminal).
  • 2. RuntimeRunner forwards events to CompositeRuntimeEventSink.
  • 3. CompositeRuntimeEventSink writes events to two sinks: TraceRuntimeEventSink (debug) and TranscriptRuntimeEventSink.
  • 4. TranscriptRuntimeEventSink records events via TranscriptRecorder.
  • 5. TranscriptRecorder appends each event to a JSONL file using TranscriptStore.append_event().
  • 6. TranscriptStore repairs any incomplete trailing line before writing.
  • 7. On restart, the agent reads the transcript file, replays events to rebuild HistoryManager and tool state.

证据

Once the process crashes — network timeout, OOM, Ctrl+C — all that history is gone.

来源

MyCodeAgent solves both problems with Transcript: continuously writing all key facts to an append‑only JSONL file, then rebuilding runtime state from the file after a crash.

来源

  • 记录日期: 2026-09-06T21:36:54.176Z