Skip to content

feat(agents): checkpoint after turns and recover lost sessions from them - #6

Draft
tee8z wants to merge 1 commit into
dev-2884-agent-managerfrom
dev-2884-agent-turn-checkpoints
Draft

tee8z wants to merge 1 commit into
dev-2884-agent-managerfrom
dev-2884-agent-turn-checkpoints

Conversation

@tee8z

@tee8z tee8z commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

A Spot node lost without warning sends no SIGTERM, so the harness never runs its save on stop. The session then ends with checkpoint=missing, and the thread's work is gone. With this PR, the harness also saves a checkpoint in the background after completed turns. When a lost Pod left no termination receipt, the reaper uses the newest checkpoint in the session's own S3 (Amazon Simple Storage Service) prefix.

sequenceDiagram
  participant H as buzz-acp harness
  participant C as buzz-agent-checkpoint save
  participant S3 as S3 checkpoint bucket
  participant R as buzz-sandbox-reaper
  participant SB as Sandbox
  H->>C: start in the background after a completed turn
  C->>S3: upload under developer prefix + generation/
  C-->>H: receipt with the checkpoint key
  H->>H: write the key to /dev/termination-log
  Note over H: Node lost without warning, no save on stop, no receipt in the Pod status
  R->>R: classify the Sandbox as Lost (bound, no Pod for 60s or more)
  R->>S3: ListObjectsV2 of developer prefix + generation/
  S3-->>R: newest key directly under the prefix, by LastModified
  R->>SB: tombstone with ended-reason=lost and checkpoint=key
  Note over SB: Checkpoint-mode recovery restores this key
Loading
  • buzz-acp/src/checkpoint.rs: TurnCheckpoints runs one save at a time and starts at most one per BUZZ_ACP_CHECKPOINT_AFTER_TURN_SECS (default 600, 0 disables). It runs only with BUZZ_ACP_CHECKPOINT_ON_STOP.
  • Before the save on stop, the harness waits up to 60s for a running background save, then cancels it. A failed, timed-out, or cancelled save kills the helper's whole process group.
  • turn_completed observer events and activity records now carry duration_ms.
  • buzz-sandbox-reaper: the new Evidence::Listed(key) applies only to a Sandbox that got past binding and has no receipt. A Completed session with Listed evidence still waits out the 24h hold.
  • All sessions of one developer share one IAM role. A compromised session can write into that developer's prefixes, but not into another developer's prefix (see docs/remote-agents.md).

Stack

Position 19 of 20 in the DEV-2884 Buzz stack. Base: #4. Next: #7.

Validation

Run in a detached worktree at this commit (CARGO_TARGET_DIR shared, CARGO_BUILD_JOBS=4):

  • cargo test -p buzz-acp -p buzz-sandbox-reaper: 1,131 passed, 0 failed, 3 ignored. This includes the new TurnCheckpoints, evidence::latest, and a_lost_session_records_its_newest_turn_checkpoint tests.
  • cargo clippy -p buzz-acp -p buzz-sandbox-reaper --all-targets -- -D warnings: pass.

Limits

  • No cluster, Spot interruption, or S3 bucket was used. The reaper tests use a fake store, and the harness tests use a fake save.
  • A background save does not stop the adapters, so another agent slot can be mid-turn while the save reads the workspace.
  • Buzz AGENTS.md requires a human to test the change before it leaves draft.

@tee8z
tee8z added this pull request to stack #5 October 9, 2026 17:30
@tee8z
tee8z force-pushed the dev-2884-agent-turn-checkpoints branch from f2ed1c9 to 6fb2cd2 Compare October 19, 2026 15:09
@tee8z
tee8z force-pushed the dev-2884-agent-turn-checkpoints branch from 6fb2cd2 to 2e95424 Compare October 19, 2026 17:36
@tee8z
tee8z force-pushed the dev-2884-agent-turn-checkpoints branch from 2e95424 to 936a933 Compare October 19, 2026 20:52
@tee8z
tee8z removed this pull request from stack #5 October 19, 2026 20:53
@tee8z
tee8z added this pull request to stack #22 October 19, 2026 20:56
@tee8z tee8z self-assigned this Oct 19, 2026
A node lost without warning sends no SIGTERM, so the checkpoint on stop
never runs. The harness now also saves in the background after completed
turns (one at a time, at most once per BUZZ_ACP_CHECKPOINT_AFTER_TURN_SECS,
default 600), and the save on stop waits for or cancels a running one. A
cancelled or failed save kills its helper's whole process group.

When a Pod left no termination receipt, the reaper records the newest
checkpoint directly under the session's own prefix instead of `missing`.

turn_completed activity records now carry duration_ms for long-turn alerts.

Signed-off-by: Tee8z <tee8z@protonmail.com>
@tee8z
tee8z force-pushed the dev-2884-agent-turn-checkpoints branch from 936a933 to a153820 Compare October 19, 2026 23:28
@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant