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(session_store): persist agent sessions to workspace
Steven Enamakelc1e163252892
diff --git a/crates/openhuman-core/src/agent/session_store/mod.rs b/crates/openhuman-core/src/agent/session_store/mod.rsindex 583fd3d4f9..bd3c8da2f6 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, default_turn_states_for, ledger_for, provider_for_workspace, release_workspace_defaults,+ attachment_stash_for, current_documents_for, default_turn_states_for, ledger_for, provider_for_workspace, release_workspace_defaults,require_ledger, status_store_for, stores_for, stores_or_ephemeral, turn_states_for, with_ledger,with_ledger_async, WorkspaceSessionStores,};diff --git a/crates/openhuman-core/src/agent/session_store/workspace.rs b/crates/openhuman-core/src/agent/session_store/workspace.rsindex 54f1d577b1..a2600b3d6d 100644--- a/crates/openhuman-core/src/agent/session_store/workspace.rs+++ b/crates/openhuman-core/src/agent/session_store/workspace.rs@@ -17,6 +17,7 @@ use std::collections::HashMap;use std::path::{Path, PathBuf};use std::sync::{Arc, LazyLock, Mutex, PoisonError};+use tinyagents_harness::multimodal::BlobAttachmentStash;use tinyagents_session::port::{AgentStores, SessionStoreProvider, TurnStates};use tinyagents_session::run_ledger::{LedgerError, LedgerResult, RunLedgerStore};use tinyagents_session::DriverSessionStores;@@ -154,6 +155,37 @@ pub fn default_turn_states_for(workspace_dir: &Path) -> Arc<dyn TurnStates> {.turn_states}+/// The calling tenant's attachment stash for `workspace_dir`: content-addressed+/// image bytes in the blob store of its agent scope, with the id index beside+/// them in its documents. `None` for a SaaS task with no scope or a backend that+/// refused the scope.+///+/// The host policy is no cap and no expiry: a conversation's attachment+/// references stay resolvable for as long as the conversation does.+#[must_use]+pub fn attachment_stash_for(workspace_dir: &Path) -> Option<BlobAttachmentStash> {+ let key = tenant_agent_key()?;+ let backend = match crate::storage::local::backend_for(workspace_dir) {+ Ok(backend) => backend,+ Err(error) => {+ log::warn!("[session_store] no storage backend for attachments: {error:#}");+ return None;+ }+ };+ match backend.for_scope(&crate::storage::scope_for_agent(&key)) {+ Ok(scoped) => Some(BlobAttachmentStash::new(+ Arc::clone(scoped.blobs()),+ Arc::clone(scoped.documents()),+ u64::MAX,+ std::time::Duration::MAX,+ )),+ Err(error) => {+ log::warn!("[session_store] attachment scope refused agent={key}: {error}");+ None+ }+ }+}+/// The calling tenant's run ledger for `workspace_dir`.////// The installed provider's when it keeps one, else the workspace default's.