Skip to content

Commit 13fc30b

Browse files
committed
feat(agents): checkpoint after turns and recover lost sessions from them
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 <[email protected]>
1 parent 9e5e4ca commit 13fc30b

10 files changed

Lines changed: 463 additions & 37 deletions

File tree

‎crates/buzz-acp/src/activity.rs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ impl ActivityRecorder {
4545
let before = self.tools.len();
4646
self.tools.retain(|_, (_, turn)| turn != &event.turn_id);
4747
details["unfinished_tools"] = (before - self.tools.len()).into();
48+
if let Some(duration_ms) = event.payload["duration_ms"].as_u64() {
49+
details["duration_ms"] = duration_ms.into();
50+
}
4851
}
4952
event.kind.as_str()
5053
}
@@ -252,6 +255,22 @@ mod tests {
252255
assert!(recorder.record(&e).is_none());
253256
}
254257

258+
#[test]
259+
fn turn_completion_reports_only_its_duration() {
260+
let mut recorder = ActivityRecorder::new();
261+
let mut completed = event(json!({"duration_ms": 4200, "prompt": "synthetic secret"}));
262+
completed.kind = "turn_completed".into();
263+
let record = recorder.record(&completed).unwrap();
264+
assert_eq!(record["details"]["duration_ms"], 4200);
265+
assert_eq!(record["details"]["unfinished_tools"], 0);
266+
assert!(!record.to_string().contains("synthetic secret"));
267+
let mut legacy = event(json!({}));
268+
legacy.kind = "turn_completed".into();
269+
assert!(recorder.record(&legacy).unwrap()["details"]
270+
.get("duration_ms")
271+
.is_none());
272+
}
273+
255274
#[test]
256275
fn active_tool_tracking_is_bounded() {
257276
let mut recorder = ActivityRecorder::new();

0 commit comments

Comments
 (0)