Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(reaper): handle empty replay store on agent restart

Steven Enamakelb5ea0a855506
diff --git a/crates/openhuman-core/src/agent/tinyagents/reaper.rs b/crates/openhuman-core/src/agent/tinyagents/reaper.rs
index 6f8f1ac7ef..4b9edaa044 100644
--- a/crates/openhuman-core/src/agent/tinyagents/reaper.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/reaper.rs
@@ -11,8 +11,6 @@ use std::path::Path;
use tinyagents_harness::observability::FileStatusStore;
use tinyagents_session::transcript::import::ops::open_session_stores;
-pub(crate) use tinyagents_harness::observability::ORPHAN_REAP_REASON;
-
/// Reap every run left non-terminal by a previous process, returning the number
/// of runs moved to `Cancelled`. Best-effort; never blocks boot.
pub(crate) async fn reap_orphaned_runs(workspace: &Path) -> usize {
diff --git a/crates/openhuman-core/src/agent/tinyagents/reaper_tests.rs b/crates/openhuman-core/src/agent/tinyagents/reaper_tests.rs
index 4d7f2f5c45..f483b3b1dd 100644
--- a/crates/openhuman-core/src/agent/tinyagents/reaper_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/reaper_tests.rs
@@ -1,8 +1,11 @@
use super::*;
-use tinyagents_harness::ids::ComponentId;
-
-use tinyagents_harness::observability::{mint_run_id, HarnessStatusStore};
+use tinyagents_harness::events::HarnessRunStatus;
+use tinyagents_harness::ids::{ComponentId, ExecutionStatus, HarnessPhase};
+use tinyagents_harness::observability::{
+ mint_run_id, FileStatusStore, HarnessStatusStore, ORPHAN_REAP_REASON,
+};
+use tinyagents_session::transcript::import::ops::open_session_stores;
/// Build a fresh status in a non-terminal state and persist it.
async fn seed_status(store: &FileStatusStore, status_kind: ExecutionStatus) -> String {
diff --git a/crates/openhuman-core/src/agent/tinyagents/replay/ops.rs b/crates/openhuman-core/src/agent/tinyagents/replay/ops.rs
index 0475a0d46a..6025f84c2b 100644
--- a/crates/openhuman-core/src/agent/tinyagents/replay/ops.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/replay/ops.rs
@@ -7,12 +7,10 @@
use std::path::Path;
use tinyagents_harness::events::HarnessRunStatus;
-use tinyagents_harness::observability::replay;
+use tinyagents_harness::observability::replay::{self, RunEventsPage};
use tinyagents_harness::observability::{FileStatusStore, StoreEventJournal};
use tinyagents_session::transcript::import::ops::open_session_stores;
-pub(crate) use replay::{RunEventsPage, DEFAULT_EVENTS_LIMIT, MAX_EVENTS_LIMIT};
-
/// Paged late-attach replay reader over the durable journal under `workspace`.
pub(crate) async fn read_run_events_page(
workspace: &Path,
diff --git a/crates/openhuman-core/src/agent/tinyagents/replay/schemas.rs b/crates/openhuman-core/src/agent/tinyagents/replay/schemas.rs
index 77e1f54e15..dc789d7b13 100644
--- a/crates/openhuman-core/src/agent/tinyagents/replay/schemas.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/replay/schemas.rs
@@ -38,8 +38,9 @@ use tinyagents_harness::observability::AgentObservation;
use crate::core::all::{ControllerFuture, RegisteredController};
use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
+use super::ops::{list_active_runs, read_run_events_page, read_run_status};
+use tinyagents_harness::observability::replay::{DEFAULT_EVENTS_LIMIT, MAX_EVENTS_LIMIT};
use super::ops::{
- list_active_runs, read_run_events_page, read_run_status, DEFAULT_EVENTS_LIMIT, MAX_EVENTS_LIMIT,
};
const NAMESPACE: &str = "agent";
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs b/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs
index 161e6f41a1..480025b970 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs
@@ -441,7 +441,7 @@ async fn run_turn_via_tinyagents_inner(
// with it (`with_stream_id`), so every persisted observation's `event_id` is
// the restart-stable `{run_id}-evt-{offset}` a late-attach replay
// reconstructs the timeline from (05.1). The same id keys the journal + status.
- let journal_run_id = journal::mint_run_id();
+ let journal_run_id = tinyagents_harness::observability::mint_run_id();
if let Some(scope) = &subagent_scope {
if let Some(slot) = &scope.journal_run_id {
*slot