Skip to content

[Feature]: Official seam for mid-turn AgentState checkpointing (crash recovery finer than call-end) #3620

Open

Description

@richuV

Problem

Today AgentState is checkpointed at turn boundaries (call-end). If the host process is killed mid-turn (SIGKILL, container eviction), durable recovery only reaches the last completed model call — every tool execution and iteration since then is lost, even though tool results were already produced and emitted as events.

This is the gap every coding-agent harness hits: long agentic turns (many tool calls, minutes of work) are exactly the turns most likely to be interrupted, and exactly the ones where losing progress is most expensive.

What exists vs. what is missing

  • saveIfVersion / slotVersions / conflictPolicy (2.0.4) provide the CAS primitives for safe concurrent state writes.
  • But there is no official middleware/hook that checkpoints mid-turn progress — e.g., after each tool-result boundary — without racing the harness's own call-end save. A host-side middleware that writes AgentState mid-turn conflicts with the harness's phase write and risks losing the race under CAS.
  • In-session event journals help transport replay, but they are not a durable recovery surface for "resume from last tool result" semantics.

Requested seam

An official mid-turn checkpoint point — for example:

  1. A documented onToolResultEnd (or iteration-boundary) checkpoint hook that is serialized with the harness's own state save, using the 2.0.4 CAS primitives; or
  2. A CrashCheckpoint-style middleware in core/harness (not just in a CLI example) that phases in-flight tool results into durable state between model calls.

The goal: after SIGKILL, a fresh runtime recovers to the most recent completed tool result, not just the previous call-end boundary.

Note

We currently mitigate host-side by checkpointing the durable transcript at tool-result boundaries (batch + interval cadence) — recovery reads back "completed up to last tool result". That workaround is tracked for removal once an official mid-turn checkpoint seam exists, since AgentState remains the authoritative recovery surface.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions