Skip to content

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

docs(embed): document per-agent isolation, removal and what agents still share (#7032)

oxoxDev611d1277b458
diff --git a/crates/openhuman-embed/README.md b/crates/openhuman-embed/README.md
index 88c9597b0d..26750a9331 100644
--- a/crates/openhuman-embed/README.md
+++ b/crates/openhuman-embed/README.md
@@ -275,40 +275,80 @@ caches (cost log, prompt templates, migration markers). The desktop app, CLI
and TUI install `openhuman_rpc::session_store`, the classic on-disk layout behind
the same port. See `tests/session_store.rs`.
-### Still runtime-wide
-
-These are read from the runtime's boot config by every agent today. They
-are documented rather than hidden; each is a candidate follow-up in the core.
-
-- `autonomy.auto_approve` / `auto_approve_all` and the memory guard's
- autonomy tier come from the runtime's boot config (`security::live_policy`),
- not the agent's. Path and command policy _do_ use the agent's own tier.
-- The approval gate is on or off process-wide; parked approvals are not
- labelled with the agent id. A per-agent "no approvals" is `Access::full()`,
- whose `TrustedAutomation` origin the gate honours per turn.
-- The sub-agent catalogue is runtime-wide (built-ins plus
- `<workspace>/agents/*.toml`). Embedded agents cannot be `delegate_*`
- targets of one another. Do not reuse built-in ids (`orchestrator`,
- `summarizer`, …) for your agents.
-- Sub-agents an agent spawns and the experience store re-read the runtime's
- on-disk config rather than the agent's overlay. (The turn journal goes to
- the agent's own stores under a host session store; without one it uses the
- process-default workspace.)
-- Sub-agent run-ledger rows, cron jobs and the cost log stay in the
- workspace even with a host session store.
-- Agents sharing a workspace share the dynamic (`mcp_registry_*`) MCP
- registry; `[[mcp_client.servers]]` declared through `AgentSpec::mcp` are
- per agent. The host-seeded documentation server is visible to every agent.
-- `install_skill` / `create_skill` still write to `~/.openhuman`. With
- `include_user_skills(false)` (the default) an agent does not _discover_ the
- operator's skills, but an install by the agent lands there.
-- One API key (or session) is shared by all agents.
+### Per agent
+
+Every agent on a runtime is isolated from its siblings on the same workspace:
+
+- Policy and approvals: the autonomy tier, `auto_approve`, `auto_approve_all`
+ and the approval gate switch come from the agent's `Access`
+ (`auto_approve`, `auto_approve_all`, `approval_gate`). Parked approvals
+ carry the agent id; `Agent::approvals()` lists and decides only that
+ agent's requests, and a chat reply routes by agent and thread.
+- Sub-agents: `AgentSpec::subagents` declares workers only that agent can
+ delegate to. Built-in ids (`orchestrator`, `planner`, …) are reserved.
+ Detached sub-agents keep the agent's provider route.
+- MCP: each agent has its own MCP host and dynamic registry under
+ `<workspace>/agents/<id>/`, plus the servers its spec declares.
+- Transcripts: `<workspace>/agents/<id>/session_raw/`. Conversations written
+ before this layout into `<workspace>/session_raw/` stay readable and are
+ copied into the agent's directory when resumed; the shared file is never
+ changed.
+- Skills: `install_skill` and `create_skill` write user-scope bundles into
+ `<workspace>/agents/<id>/skills/` and `workflows/`, which only that agent
+ discovers. The operator's `~/.openhuman` is untouched.
+- Cron: jobs an agent creates live in `<workspace>/agents/<id>/cron/jobs.db`
+ and run under that agent's context, provider and policy.
+- Memory sources are synced per live agent, under its own context.
+- Turn tables, plan mode, reasoning effort, turn citations, budget signals,
+ the request journal, sub-agent dedupe and the `run_workflow` guard live in
+ the agent's context, so two agents can use the same thread or session id
+ at the same time.
+
+### Lifecycle
+
+`RuntimeBuilder::max_agents` caps live agents (default
+`DEFAULT_MAX_AGENTS`, 1024); `Runtime::agent` returns
+`AgentError::AgentLimit` past it. `Runtime::remove_agent(id)` denies the
+agent's parked approvals (resolution `agent_removed`), refuses new turns and
+ends the ones in flight with `CoreError::AgentRemoved` (waiting up to ten
+seconds for them to unwind), then drops its state slots and MCP host and
+deregisters its context, which leaves its cron jobs dormant. The id is
+reusable once it returns; `.purge()` also deletes the agent's home.
+Dropping the last handle to an agent tears it down the same way with
+resolution `agent_dropped`. Cancellation is cooperative: a tool already
+executing, or a sub-agent the turn detached, may finish after removal.
+
+### Still process-owned
+
+- The event bus, keyring and credential store, and the API key (or
+ session): one per runtime, shared by every agent.
- `IntegrationClient` (backend-proxied Composio/search/media tools) accepts
the runtime's TinyHumans API key or an app-session JWT through
`security::credentials::session_support::resolve_backend_credential`.
API keys use `x-api-key`; session JWTs use `Authorization: Bearer`.
With the backend transport installed and the integration feature and runtime
gates enabled, an API-key-only runtime can register integration tools.
+- The approval gate engine and its store. Rows are labelled and decided per
+ agent, but the store is one file per workspace.
+- Sub-agent run-ledger rows. They are keyed by unique run ids; an owner
+ column would need a schema change in the vendored `tinyagents-session`.
+- The host-installed session store (`openhuman_rpc::session_store`) keeps
+ its single-operator layout; the per-agent transcript layout applies to the
+ core's file fallback and to embedded agents.
+- Background-delivery busy flags and skill run cancellation, which are keyed
+ by unique session and run ids.
+- A per-turn `Turn::route` override reaches that turn only; detached
+ sub-agents use the agent's own route.
+
+### Out of scope
+
+- A per-agent cost log. It is accounting rather than behaviour isolation,
+ `Turn::meter` already reports per turn, and a per-agent budget is a
+ separate request.
+- Embedded agents delegating to one another. Peer delegation is a
+ cross-agent trust decision that TinyHiveMind owns.
+- An API to add a memory source to a running agent. `AgentSpec` memory
+ sources are taken when the agent is created; nothing needs more yet.
Other invariants worth knowing before wiring any entry point:
diff --git a/crates/openhuman-embed/src/agent/layout.rs b/crates/openhuman-embed/src/agent/layout.rs
index fc77ad224f..2f03d49949 100644
--- a/crates/openhuman-embed/src/agent/layout.rs
+++ b/crates/openhuman-embed/src/agent/layout.rs
@@ -8,11 +8,14 @@
//! config.toml, auth-profiles.json, core.token runtime-wide
//! workspace/
//! session_db/sessions.db runtime-wide run ledger
-//! agents/<id>/{SOUL.md, skills/} the agent's home
+//! agents/<id>/{SOUL.md, skills/, workflows/} the agent's home
//! agents/<id>/session_raw/<stem>.jsonl its transcripts
+//! agents/<id>/cron/jobs.db its cron jobs
//! agents/<id>/action/ its default action_dir
//! ```
//!
+//! Its MCP host keeps its store in the agent home too.
+//!
//! Transcripts an agent wrote to the shared `workspace/session_raw/` before
//! this layout are still read, and are copied into the agent's directory
//! before they are written to again.
diff --git a/crates/openhuman-embed/src/agent/mod.rs b/crates/openhuman-embed/src/agent/mod.rs
index e1329521b2..13606e317f 100644
--- a/crates/openhuman-embed/src/agent/mod.rs
+++ b/crates/openhuman-embed/src/agent/mod.rs
@@ -243,9 +243,9 @@ impl Agent {
&self.inner.layout.skills
}
- /// Where this agent's transcripts are written: the workspace's shared
- /// `session_raw/` (files are keyed by agent name), or
- /// `session_raw/`, keyed by agent id.
+ /// `<workspace>/agents/<id>/session_raw/` — where this agent's transcripts
+ /// are written. Conversations it wrote earlier into the workspace's shared
+ /// `session_raw/` stay readable and are copied here when resumed.
pub fn transcripts_dir(&self) -> &Path {
&self.inner.layout.transcripts
}
diff --git a/crates/openhuman-embed/src/runtime/README.md b/crates/openhuman-embed/src/runtime/README.md
index 89fd92db13..714046292d 100644
--- a/crates/openhuman-embed/src/runtime/README.md
+++ b/crates/openhuman-embed/src/runtime/README.md
@@ -26,12 +26,11 @@ keyring and credential store, the RPC bearer, the background `ServiceSet`,
the compiled `DomainSet`, and the API key. An agent owns everything the core
reads through its own ambient context: its `Config` (provider route, model,
MCP servers, autonomy tier, `action_dir`), its `AgentDefinition` (system
-prompt, tool scope, sandbox mode), its skills root, and its narrowed
-`DomainSet` and `ToolGroups`. A handful of settings, such as
-`autonomy.auto_approve` and the memory guard's autonomy tier, are still read
-from the runtime's boot config by every agent regardless of its own
-overlay; see the crate README's "still runtime-wide" list before assuming an
-agent-level override reaches them.
+prompt, tool scope, sandbox mode), its skills root, its narrowed
+`DomainSet` and `ToolGroups`, its approval settings and parked approvals,
+its sub-agents, its MCP host, its cron jobs and its per-turn state. The
+crate README's "Still process-owned" list names what agents share, and its
+"Lifecycle" section covers `max_agents` and `Runtime::remove_agent`.
## One runtime per process
diff --git a/crates/openhuman-embed/src/runtime/mod.rs b/crates/openhuman-embed/src/runtime/mod.rs
index 288e25ffdd..184e6db58e 100644
--- a/crates/openhuman-embed/src/runtime/mod.rs
+++ b/crates/openhuman-embed/src/runtime/mod.rs
@@ -44,11 +44,10 @@
//! `action_dir`), its [`AgentDefinition`](openhuman_core::agent::harness::definition::AgentDefinition)
//! (system prompt, tool scope, sandbox mode), its profile (allowlists,
//! dedicated memory and transcripts), its skills root, its narrowed
-//! `DomainSet` and [`ToolGroups`].
+//! `DomainSet` and [`ToolGroups`], its approval settings, sub-agents, MCP
+//! host, cron jobs and per-turn state.
//!
-//! Some settings are still read from the runtime's boot config by every
-//! agent; see the crate README's "still runtime-wide" list. They are
-//! documented rather than hidden.
+//! The crate README's "Still process-owned" list names what agents share.
//!
//! # One runtime per process
//!