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
Merge upstream/main into storage-scope-propagation
Steven Enamakel481497ca24e7
diff --cc crates/openhuman-core/src/core/runtime/context.rsindex 5970b2d498,4bf3711273..b29a51dc69--- a/crates/openhuman-core/src/core/runtime/context.rs+++ b/crates/openhuman-core/src/core/runtime/context.rs@@@ -428,7 -371,8 +371,8 @@@ impl CoreContext})),}};+ let agent = self.agent.derive(&mut overlay);- Arc::new(CoreContext {+ crate::storage::agents::registered(Arc::new(CoreContext {host_kind: self.host_kind,workspace_binding: RwLock::new(shared_binding),domains,@@@ -438,7 -382,8 +382,8 @@@backend_transport: self.backend_transport.clone(),turn_origin: self.turn_origin.clone(),session_agent: overlay.session_agent.or_else(|| self.session_agent.clone()),+ agent,- })+ }))}/// The agent a host session store scopes work under this context to, if@@@ -738,8 -689,6 +689,8 @@@ pub async fn init_stores(cfg: &crate::c}}- #[path = "context_agent.rs"]- mod agent_scope;++#[path = "context_for_agent.rs"]++mod for_agent;#[path = "context_turn_origin.rs"]mod turn_origin_scope;diff --cc crates/openhuman-core/src/core/runtime/context_for_agent.rsindex 0000000000,0000000000..8f07ab2f7dnew file mode 100644--- /dev/null+++ b/crates/openhuman-core/src/core/runtime/context_for_agent.rs@@@ -1,0 -1,0 +1,31 @@@++use super::*;++++impl CoreContext {++ /// This context, acting for `agent`: the same configuration, workspace++ /// binding, domains and transport, with the session agent replaced.++ ///++ /// For background work that visits an agent's records when no live++ /// context of that agent is at hand (`crate::storage::agents`): the agent++ /// was registered by an earlier process, or its host dropped it. A live++ /// agent context is always preferred, since it carries the agent's own++ /// configuration.++ pub fn for_agent(self: &Arc<Self>, agent: &str) -> Arc<CoreContext> {++ let binding = self++ .workspace_binding++ .read()++ .map(|handle| Arc::clone(&*handle))++ .unwrap_or_else(|poisoned| Arc::clone(&*poisoned.into_inner()));++ Arc::new(CoreContext {++ host_kind: self.host_kind,++ workspace_binding: RwLock::new(binding),++ domains: self.domains,++ tool_groups: self.tool_groups.clone(),++ embedder_config: self.embedder_config.clone(),++ user_skill_roots: self.user_skill_roots,++ backend_transport: self.backend_transport.clone(),++ turn_origin: self.turn_origin.clone(),++ session_agent: Some(agent.to_string()),++ agent: Default::default(),++ })++ }++}diff --cc crates/openhuman-core/src/storage/README.mdindex f659c2bcf3,14e34a43d4..d07737d256--- a/crates/openhuman-core/src/storage/README.md+++ b/crates/openhuman-core/src/storage/README.md@@@ -71,31 -71,6 +71,31 @@@ on `storage-mongodb`master key they fail closed. The config encryption key stays on theprocess keyring, because `config.toml` is loaded before any agent acts.+## Background work and agent scopes++Work done inside an agent's turn runs under that agent's `CoreContext`+(`session_agent`, set for embed agents and SaaS user agents), so with a+backend installed its records land in that agent's scope. Background work+runs under the process default context and on its own would only see+`local`. `storage::agents` closes the gap:++- `registered(context)`: `CoreContext::derive_with` records every agent+ context it builds (live, by agent id), and the agent id is written to the+ backend's `local` scope (`storage_agents`) so a restarted process still+ knows it.+- `for_each_scope(label, step)`: runs `step` for `local`, then under each+ known agent's context — its live one, or the default context acting for it+ (`CoreContext::for_agent`). `for_each_agent` skips `local`.+- `within_agent(agent, fut)` / `context_for(agent)`: re-enter an agent's+ scope when background work learned whose record it is handling.+- Users: the cron scheduler (`cron::scheduler::tick_agents`), the task-source++Users: the cron scheduler (`cron::scheduler::tick_live_agents`), the task-source+poller, the flows boot sweep and schedule-trigger reconcile, the run reaper,+and the device tunnel (a paired device's frames run as the agent that paired+it, `security::devices::owner`). Without a backend these run once, as+before. In SaaS mode agent ids are not recorded and `local` is skipped;+per-user background work there is `user_agents::background`.+## BoundariesThe ports, drivers, scopes and conformance suites are tinystoragedrivers';