The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(session_store): persist workspace state across session reloads
Steven Enamakel2a2fab7838d7
diff --git a/crates/openhuman-core/src/agent/session_store/mod.rs b/crates/openhuman-core/src/agent/session_store/mod.rsindex 29ae7fd593..c775bfecb6 100644--- a/crates/openhuman-core/src/agent/session_store/mod.rs+++ b/crates/openhuman-core/src/agent/session_store/mod.rs@@ -26,7 +26,7 @@ mod workspace;pub use rebound::{rebind_all, ReboundSessionStores};pub use workspace::{current_documents_for, ledger_for, provider_for_workspace, release_workspace_defaults,- run_ledger_blocking, stores_for, stores_or_ephemeral,+ run_ledger_blocking, status_store_for, stores_for, stores_or_ephemeral,};static PROVIDER: LazyLock<RwLock<Option<Arc<dyn SessionStoreProvider>>>> =diff --git a/crates/openhuman-core/src/agent/session_store/workspace.rs b/crates/openhuman-core/src/agent/session_store/workspace.rsindex a71717dab5..c4f51b92b7 100644--- a/crates/openhuman-core/src/agent/session_store/workspace.rs+++ b/crates/openhuman-core/src/agent/session_store/workspace.rs@@ -186,6 +186,21 @@ pub fn current_documents_for(workspace_dir: &Path) -> Option<Arc<dyn DocumentSto}}+/// The calling tenant's durable run-status store for `workspace_dir`: the+/// `harness_run_status` documents of its agent scope, beside its session+/// stores. A call with no tenant gets a throwaway in-memory store.+#[must_use]+pub fn status_store_for(workspace_dir: &Path) -> tinyagents_harness::observability::DriverStatusStore {+ let docs = current_documents_for(workspace_dir).unwrap_or_else(|| {+ log::warn!("[session_store] no tenant; using a throwaway run-status store");+ let scoped = MemoryStorage::new()+ .for_scope(&tinystoragedrivers::Scope::local())+ .expect("the memory backend binds the local scope");+ Arc::clone(scoped.documents())+ });+ tinyagents_harness::observability::DriverStatusStore::new(docs)+}+/// Runs a run-ledger call from synchronous code on the shared storage bridge.////// # Errorsdiff --git a/crates/openhuman-core/src/agent/tinyagents/journal.rs b/crates/openhuman-core/src/agent/tinyagents/journal.rsindex 3e719fa573..31e2fca92c 100644--- a/crates/openhuman-core/src/agent/tinyagents/journal.rs+++ b/crates/openhuman-core/src/agent/tinyagents/journal.rs@@ -39,7 +39,7 @@//!//! - Full sub-agent / graph run lineage (`parent_run_id` / `root_run_id`//! threading) — wired in 05.2/05.3. This slice threads `thread_id` (from the-//! sub-agent task scope) so `FileStatusStore::list_by_thread` answers.+//! sub-agent task scope) so `DriverStatusStore::list_by_thread` answers.//!//! [`EventSink::with_stream_id`]: tinyagents_harness::events::EventSink::with_stream_id@@ -50,12 +50,11 @@ use std::sync::{Arc, Mutex};use tinyagents_harness::events::{EventSink, HarnessRunStatus};use tinyagents_harness::ids::{ComponentId, HarnessPhase, RunId, ThreadId};use tinyagents_harness::observability::{- process_env_secrets, AgentObservation, FanOutSink, FileStatusStore, HarnessEventJournal,+ process_env_secrets, AgentObservation, DriverStatusStore, FanOutSink, HarnessEventJournal,HarnessStatusStore, JournalSink, RedactingSink, StoreEventJournal,};use tinyagents_harness::store::{AppendStore, Store};-use tinyagents_session::transcript::import::ops::open_session_stores;/// Best-effort live request → durable tinyagents journal stream map. The web/// progress bridge uses this at turn end to shadow-project spans from the@@ -125,7 +124,7 @@ async fn journal_stores() -> anyhow::Result<(Arc<dyn AppendStore>, Arc<dyn Store/// non-fatal.pub(crate) struct TurnJournal {run_id: RunId,- status_store: Arc<FileStatusStore>,+ status_store: Arc<DriverStatusStore>,event_sink: Arc<JournalSink>,/// The in-flight status snapshot, mutated in place to `completed`/`failed`.status: Mutex<HarnessRunStatus>,@@ -179,7 +178,7 @@ impl TurnJournal {/// `tinyagents_harness::observability::mint_run_id`). That shared id is what makes the persisted `event_id`s the/// restart-stable `{run_id}-evt-{offset}` a late-attach replay reconstructs the/// timeline from. `thread_id` (when known — e.g. the sub-agent task scope)-/// records the run under a thread so `FileStatusStore::list_by_thread` answers.+/// records the run under a thread so `DriverStatusStore::list_by_thread` answers.////// Returns a [`TurnJournal`] handle the caller uses to stamp the terminal/// status after the run, or `None` when the store could not be opened (the run@@ -219,7 +218,7 @@ pub(crate) async fn attach_turn_journal(// Status store: durable, Store-backed. Seed an initial `running` snapshot,// recording the thread (when known) so list_by_thread answers at run start.- let status_store = Arc::new(FileStatusStore::over(kv));+ let status_store = Arc::new(status_store);let mut status = HarnessRunStatus::new(run_id.clone(), ComponentId::new(model.to_string()));if let Some(thread_id) = thread_id {status = status.with_thread(thread_id);diff --git a/crates/openhuman-core/src/agent/tinyagents/reaper.rs b/crates/openhuman-core/src/agent/tinyagents/reaper.rsindex 5b66fbb538..819a2aa312 100644--- a/crates/openhuman-core/src/agent/tinyagents/reaper.rs+++ b/crates/openhuman-core/src/agent/tinyagents/reaper.rs@@ -1,16 +1,13 @@//! Startup reconciliation for orphaned agent runs.//!//! The sweep itself (`tinyagents_harness::observability::reap_orphaned_runs`)-//! lives upstream; this host adapter only opens the workspace's durable status+//! lives upstream; this host adapter only opens the tenant's durable status//! store. It is the one *writer* over the status seam that//! [`crate::agent::tinyagents::journal`] exposes; the replay/status controllers//! ([`super::replay`]) stay strictly read-only.use std::path::Path;-use tinyagents_harness::observability::FileStatusStore;-use tinyagents_session::transcript::import::ops::open_session_stores;-/// Reap every run left non-terminal by a previous process, returning the number/// of runs moved to `Cancelled`. Best-effort; never blocks boot.///@@ -38,13 +35,9 @@ async fn reap_unless_shared(workspace: &Path, shared: bool) -> usize {"[agent] startup run sweep workspace={}",workspace.display());- // With a host session store the status records live in its stores: sweep- // the ones this process's own (default-agent) work wrote there.- if let Some(stores) = crate::agent::session_store::current() {- let store = FileStatusStore::over(stores.kv);- return tinyagents_harness::observability::reap_orphaned_runs(&store).await;- }- let store = FileStatusStore::new(open_session_stores(workspace).kv);+ // The status records live in the storage backend, in the calling+ // tenant's scope: sweep the ones this process's own work wrote there.+ let store = crate::agent::session_store::status_store_for(workspace);tinyagents_harness::observability::reap_orphaned_runs(&store).await}diff --git a/crates/openhuman-core/src/agent/tinyagents/replay/ops.rs b/crates/openhuman-core/src/agent/tinyagents/replay/ops.rsindex f7c9f36045..dbece604f7 100644--- a/crates/openhuman-core/src/agent/tinyagents/replay/ops.rs+++ b/crates/openhuman-core/src/agent/tinyagents/replay/ops.rs@@ -1,15 +1,14 @@//! Read-only business logic for the agent replay/status RPC surface//! (workstream 05.x): a workspace-to-store adapter over the upstream readers in//! `tinyagents_harness::observability::replay`. Every function opens the same-//! `{workspace}/tinyagents_store/{kv,journal}` stores the turn journal writes+//! journal and run-status stores (in the storage backend) the turn journal writes//! and never writes, mutates, or bypasses any security/approval/sandbox gate.use std::path::Path;use tinyagents_harness::events::HarnessRunStatus;use tinyagents_harness::observability::replay::{self, RunEventsPage};-use tinyagents_harness::observability::{FileStatusStore, StoreEventJournal};-use tinyagents_session::transcript::import::ops::open_session_stores;+use tinyagents_harness::observability::StoreEventJournal;/// Paged late-attach replay reader over the durable journal under `workspace`.pub(crate) async fn read_run_events_page(@@ -18,7 +17,7 @@ pub(crate) async fn read_run_events_page(offset: u64,limit: u64,) -> anyhow::Result<RunEventsPage> {- let journal = StoreEventJournal::new(open_session_stores(workspace).journal);+ let journal = StoreEventJournal::new(crate::agent::session_store::stores_or_ephemeral(workspace).journal);replay::read_run_events_page(&journal, run_id, offset, limit).await.map_err(|e| {@@ -31,7 +30,7 @@ pub(crate) async fn read_run_status(workspace: &Path,run_id: &str,) -> anyhow::Result<Option<HarnessRunStatus>> {- let store = FileStatusStore::new(open_session_stores(workspace).kv);+ let store = crate::agent::session_store::status_store_for(workspace);replay::read_run_status(&store, run_id).await.map_err(|e| anyhow::anyhow!("[agent] replay read_run_status failed run_id={run_id}: {e}"))@@ -43,7 +42,7 @@ pub(crate) async fn list_active_runs(thread_id: Option<&str>,root_run_id: Option<&str>,) -> anyhow::Result<Vec<HarnessRunStatus>> {- let store = FileStatusStore::new(open_session_stores(workspace).kv);+ let store = crate::agent::session_store::status_store_for(workspace);replay::list_active_runs(&store, thread_id, root_run_id).await.map_err(|e| anyhow::anyhow!("[agent] replay list_active_runs failed: {e}"))