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
feat(core): persist task ledger, session, and cost state as documents
Steven Enamakel330e1a1aa035
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rsindex 8c159f1d66..cfae03c032 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger.rs@@ -70,7 +70,11 @@ fn task_stores() -> &'static TaskStoreRegistry<LedgerKey> {/// The cache key for this call: the storage scope joins it when a backend is/// installed, so two agents on one workspace never share a ledger.fn ledger_key(workspace_dir: &Path) -> Option<LedgerKey> {- if crate::storage::installed().is_none() {+ #[cfg(test)]+ let pinned = super::task_ledger_documents::overridden();+ #[cfg(not(test))]+ let pinned = false;+ if crate::storage::installed().is_none() && !pinned {return Some((workspace_dir.to_path_buf(), None));}match crate::storage::current_scope() {diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger_documents.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger_documents.rsindex 0b174260ea..7429e2cec7 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger_documents.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/task_ledger_documents.rs@@ -43,9 +43,34 @@ fn collections() -> Vec<CollectionSpec> {/// The repo for this call, when the host configured a backend.pub(super) fn current() -> AnyResult<Option<Repo>> {+ #[cfg(test)]+ if let Some(repo) = TEST_OVERRIDE.with(|slot| slot.borrow().clone()) {+ return Ok(Some(repo));+ }Repo::current(DOMAIN, collections)}+/// Whether a test pinned a document store for this thread.+#[cfg(test)]+pub(super) fn overridden() -> bool {+ TEST_OVERRIDE.with(|slot| slot.borrow().is_some())+}++/// Runs `f` with `repo` standing in for the installed backend, on this thread+/// only, so tests exercise the dispatch without the process-wide slot.+#[cfg(test)]+pub(super) fn with_override<T>(repo: Repo, f: impl FnOnce() -> T) -> T {+ TEST_OVERRIDE.with(|slot| *slot.borrow_mut() = Some(repo));+ let out = f();+ TEST_OVERRIDE.with(|slot| *slot.borrow_mut() = None);+ out+}++#[cfg(test)]+thread_local! {+ static TEST_OVERRIDE: std::cell::RefCell<Option<Repo>> = const { std::cell::RefCell::new(None) };+}+/// A [`TaskStore`] that keeps every task as a document.pub(super) struct DocumentTaskStore {inner: InMemoryTaskStore,diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rsindex ce5acb2db7..3144a6d31e 100644--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rs+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/store_documents.rs@@ -65,6 +65,7 @@ thread_local! {}/// The session list over one scoped document handle.+#[derive(Clone)]pub(super) struct Docs(Repo);impl Docs {diff --git a/crates/openhuman-core/src/integrations/composio/file_store_documents.rs b/crates/openhuman-core/src/integrations/composio/file_store_documents.rsindex e5b06b3088..413260de0a 100644--- a/crates/openhuman-core/src/integrations/composio/file_store_documents.rs+++ b/crates/openhuman-core/src/integrations/composio/file_store_documents.rs@@ -67,6 +67,7 @@ fn id_of(path: &Path) -> Result<String> {}/// The composio state over one scoped document handle.+#[derive(Clone)]pub(super) struct Docs(Repo);impl Docs {diff --git a/crates/openhuman-core/src/platform/cost/tracker_documents.rs b/crates/openhuman-core/src/platform/cost/tracker_documents.rsindex 31ab233f36..674e9bcb3c 100644--- a/crates/openhuman-core/src/platform/cost/tracker_documents.rs+++ b/crates/openhuman-core/src/platform/cost/tracker_documents.rs@@ -62,6 +62,7 @@ thread_local! {}/// The cost ledger over one scoped document handle.+#[derive(Clone)]pub(super) struct CostDocs(Repo);impl CostDocs {