Skip to content

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

docs(architecture): add README files for core agent and runtime modules

Steven Enamakel95849d48ab1a
diff --git a/crates/openhuman-core/src/agent/registry/README.md b/crates/openhuman-core/src/agent/registry/README.md
index 9825ca74cb..13b6a9c7c5 100644
--- a/crates/openhuman-core/src/agent/registry/README.md
+++ b/crates/openhuman-core/src/agent/registry/README.md
@@ -3,23 +3,23 @@
User-facing agent registry. Owns the `agent_registry` RPC namespace: the
merged list of shipped default agents and user-authored custom agents, their
enable/disable state, and their tool visibility policy. This is a config
-layer over the harness — the tool-calling loop and prompt/runtime
+layer over the harness: the tool-calling loop and prompt/runtime
implementation live in [`agent/harness`](../harness/), and the definitions
the harness runs come from [`agents/`](agents/) below.
## Files
-- [`types.rs`](types.rs) — wire types: `AgentRegistryConfig` (the persisted
+- [`types.rs`](types.rs): wire types. `AgentRegistryConfig` (the persisted
`entries: Vec<AgentRegistryEntry>`, stored at `Config.agent_registry`),
- `AgentRegistryEntry` (id, name, description, `source: AgentRegistrySource`
- — `Default` vs `Custom` — enabled, model, optional system prompt,
+ `AgentRegistryEntry` (id, name, description, `source: AgentRegistrySource`,
+ `Default` vs `Custom`, enabled, model, optional system prompt,
`tool_allowlist`/`tool_denylist`, `subagents: AgentSubagentPolicy`
allowlist, tags, free-form metadata), `AgentRegistryPatch` (partial
update), `AgentToolInfo` (tool-picker row). `AgentSubagentPolicy` also
deserializes from a legacy bare list of ids. `AgentRegistryEntry::validate`
enforces non-blank id/name/description and an ASCII `[A-Za-z0-9_-]` id
charset for both the entry and its subagent allowlist.
-- [`defaults.rs`](defaults.rs) — `default_agents()` loads the built-ins from
+- [`defaults.rs`](defaults.rs): `default_agents()` loads the built-ins from
[`agents::load_builtins`](agents/loader.rs) and maps each `AgentDefinition`
to a `Default`-sourced registry entry (tier becomes the single tag,
`ToolScope::Wildcard` renders as `["*"]`). `definition_from_registry_entry`
@@ -31,40 +31,40 @@ the harness runs come from [`agents/`](agents/) below.
harness's own safe worker default; see the function's doc comment for the
exact mapping and why an empty `tool_allowlist` must stay `Named(vec![])`
rather than collapsing to `Wildcard`.
-- [`ops.rs`](ops.rs) — config-backed CRUD: `list_agents`, `get_agent`,
+- [`ops.rs`](ops.rs): config-backed CRUD. `list_agents`, `get_agent`,
`upsert_custom_agent` (rejects ids that collide with a default),
`update_agent` (copies the default into config on first edit; refuses to
disable `orchestrator`), `set_agent_enabled`, `remove_agent`,
`merge_entries` (defaults overlaid with persisted config entries,
default-first), `available_tools`, `find_custom_in_config` (synchronous,
- matches only *enabled* `Custom` entries — used by the agent factory on a
- harness-registry miss). Reads/writes through
+ matches only *enabled* `Custom` entries, used by the agent factory on a
+ harness-registry miss). It reads and writes through
`config::rpc::load_config_with_timeout` and `Config::save`. Tool listing
(`available_tools`) builds the `tools_agent` built-in and reads its
- `tool_specs()` — its tool scope is the full catalog, unlike the
+ `tool_specs()`; its tool scope is the full catalog, unlike the
orchestrator's curated subset.
-- [`schemas.rs`](schemas.rs) — `ControllerSchema`/`RegisteredController`
+- [`schemas.rs`](schemas.rs): `ControllerSchema`/`RegisteredController`
definitions for namespace `agent_registry`: `list`, `get`,
`available_tools`, `create_custom`, `upsert_custom`, `update`,
`set_enabled`, `remove`. Registered through
`all_agent_registry_registered_controllers` in `core/all.rs`.
-- [`rpc.rs`](rpc.rs) — request/response payload types and the `*_rpc` handler
- functions schemas.rs wires up, delegating into `ops.rs`.
-- [`tools.rs`](tools.rs) — backwards-compatible re-export of
+- [`rpc.rs`](rpc.rs): request/response payload types and the `*_rpc` handler
+ functions that `schemas.rs` wires up, delegating into `ops.rs`.
+- [`tools.rs`](tools.rs): backwards-compatible re-export of
`agent::orchestration::tools::*`; nothing in the tree imports it any more.
-- [`agents/`](agents/) — the built-in agent archetypes and their loader.
+- [`agents/`](agents/): the built-in agent archetypes and their loader.
## `agents/`
Each built-in agent owns a subfolder with an `agent.toml` (id, `when_to_use`,
-model, tool scope, sandbox mode, iteration cap, tier, `omit_*` flags —
-parsed directly into `AgentDefinition`), a `prompt.md` holding the static
-archetype body, and a `prompt.rs` that `include_str!`s that body and exposes
+model, tool scope, sandbox mode, iteration cap, tier, `omit_*` flags, parsed
+directly into `AgentDefinition`), a `prompt.md` holding the static archetype
+body, and a `prompt.rs` that `include_str!`s that body and exposes
`pub fn build(&PromptContext) -> anyhow::Result<String>`, appending
-runtime-dependent sections (rendered tool list, user files, workspace) to it. `researcher` additionally
-owns a `graph.rs` for a bespoke `AgentGraph`; every other archetype uses
-`AgentGraph::Default`. The per-archetype contract is documented on
-[`agents/mod.rs`](agents/mod.rs).
+runtime-dependent sections (rendered tool list, user files, workspace) to it.
+`researcher` additionally owns a `graph.rs` for a bespoke `AgentGraph`; every
+other archetype uses `AgentGraph::Default`. The per-archetype contract is
+documented on [`agents/mod.rs`](agents/mod.rs).
[`agents/loader.rs`](agents/loader.rs) owns the `BUILTINS` slice and
`load_builtins`, which parses each `agent.toml`, installs
@@ -97,7 +97,7 @@ The 29 archetypes in this directory:
| `goals_agent` | Background: keeps `MEMORY_GOALS.md` fresh from session context |
| `help` | Answers "how does OpenHuman work" questions from the bundled GitBook docs |
| `image_agent` | Image generation/edit specialist |
-| `integrations_agent` | Drives a single Composio toolkit (gmail, notion, github, …) per spawn; no chat agent delegates to it — the orchestrator searches for and calls connected actions itself |
+| `integrations_agent` | Drives a single Composio toolkit (gmail, notion, github, and so on) per spawn; no chat agent delegates to it, the orchestrator searches for and calls connected actions itself |
| `mcp_agent` (feature `mcp`) | Calls tools on an already-connected MCP server |
| `morning_briefing` | Proactive scheduled daily summary (tasks, calendar, email, skills) |
| `orchestrator` | Default user-facing `chat`-tier agent; direct-first, delegates only when it materially helps |
@@ -105,7 +105,7 @@ The 29 archetypes in this directory:
| `presentation_agent` (feature `documents`) | Builds decks from evidence; owns grounding/citations/image verification |
| `profile_memory_agent` | Profile, persona, preferences, people-graph specialist |
| `researcher` | Web/docs crawler that compresses findings to dense markdown; has a custom `graph.rs` |
-| `scheduler_agent` | Reminders, recurring jobs, cron — time/cron tools only, no live calendar reads |
+| `scheduler_agent` | Reminders, recurring jobs, cron: time/cron tools only, no live calendar reads |
| `settings_agent` | App/core config, health/model diagnostics, service lifecycle, security policy |
| `skill_creator` | Creates/updates SKILL.md packages and Node-backed JS helpers |
| `summarizer` | Runtime-dispatched only: compresses oversized tool results for the orchestrator |
@@ -126,22 +126,28 @@ still names `mcp_agent` unconditionally (TOML can't be `cfg`'d); both the
orchestrator tool synthesis in `tools/orchestrator_tools.rs` and
`validate_tier_hierarchy` skip that dangling id rather than failing boot.
+The orchestrator picks tools at request time through the shared tool-search
+ranker (Jev when a decision-model credential is installed, BM25 otherwise);
+see [`tinyagents/README.md`](../tinyagents/README.md) and
+[the Jev page](../../../../../gitbooks/developing/jev.md) for how that
+ranking works.
+
## Called by
-- `core/all.rs` — registers the `agent_registry` controllers under
+- `core/all.rs`: registers the `agent_registry` controllers under
`DomainGroup::Agent`.
-- `config/schema/` — `Config.agent_registry: AgentRegistryConfig` is the
+- `config/schema/`: `Config.agent_registry: AgentRegistryConfig` is the
persisted store every `ops.rs` function reads and writes.
-- `agent/harness/builtin_definitions.rs` — `load_builtins()` seeds the
+- `agent/harness/builtin_definitions.rs`: `load_builtins()` seeds the
process-global `AgentDefinitionRegistry`; `agent/harness/definition/registry.rs`
calls `validate_tier_hierarchy` again after workspace overrides merge.
-- `agent/session_host/builder/factory.rs` —
+- `agent/session_host/builder/factory.rs`:
`Agent::from_config_for_agent` falls back to `find_custom_in_config` +
`definition_from_registry_entry` when an id is not in the harness registry.
-- `agent/schemas.rs` — `agent.graph_topologies` and `agent.registry_snapshot`
+- `agent/schemas.rs`: `agent.graph_topologies` and `agent.registry_snapshot`
enumerate `load_builtins()`.
- `flows/` (`ops/inference_readiness.rs`, `ops/builder_gates.rs`,
- `builder_tools/kind_reads.rs`, `tinyflows/caps/agent.rs`) — resolve a flow
+ `builder_tools/kind_reads.rs`, `tinyflows/caps/agent.rs`): resolve a flow
`agent` node's `agent_ref` through `list_agents`/`get_agent`/`find_custom_in_config`.
## Tests
diff --git a/crates/openhuman-core/src/core/runtime/README.md b/crates/openhuman-core/src/core/runtime/README.md
index 48eb8da6e3..61ba5975a2 100644
--- a/crates/openhuman-core/src/core/runtime/README.md
+++ b/crates/openhuman-core/src/core/runtime/README.md
@@ -113,20 +113,19 @@ initialize the workspace-bound stores, and run the pure-registration part of
`bootstrap_core_runtime`. `init_stores` gates each store on its owning
`DomainGroup` via `StoreInitPlan`: the memory driver binding (`Memory`), the
image-attachment sidecar dir (`Agent`), and the legacy-workflow prune
-(`Skills`): while the keyring-path log and the boot-time Sentry user bind run
+(`Skills`). The keyring-path log and the boot-time Sentry user bind run
unguarded for every `DomainSet`. The WhatsApp store moved to the Tauri
shell and the people store is owned by the bound memory driver, so neither
-is seeded here. It also
-holds the `DomainSet` for its scope and, when supplied, the embedder's
-`Config`: RPC handlers otherwise re-resolve config independently per
-dispatch, so an embedder-supplied config would be silently ignored without
-this seam.
+is seeded here. `CoreContext` also holds the `DomainSet` for its scope and,
+when supplied, the embedder's `Config`. RPC handlers otherwise re-resolve
+config independently per dispatch, so an embedder-supplied config would be
+silently ignored without this seam.
The "wrong-workspace guard" (Sentry OPENHUMAN-CORE-48 / TAURI-RUST-8NM)
lives in `CoreContext::init_with_config`: when no config was supplied and
`Config::load_or_init()` fails, it logs an error and skips `init_stores`
-entirely: memory stays explicitly uninitialised for the run and callers get
-a "memory client not ready" error: rather than falling back to
+entirely. Memory stays explicitly uninitialised for the run and callers get
+a "memory client not ready" error, rather than the core falling back to
`Config::default()` and seeding stores against the wrong workspace.
`CoreContext::scope(ctx, fut)` establishes the ambient context for the
@@ -152,5 +151,5 @@ host an agent turn must set:
## Related docs
-- [../README.md](../README.md): the rest of `core/`: dispatch, registry,
- event bus, transport, CLI.
+- [../README.md](../README.md): the rest of `core/`, covering dispatch,
+ registry, event bus, transport, and CLI.
diff --git a/crates/openhuman-core/src/runtime/pool/README.md b/crates/openhuman-core/src/runtime/pool/README.md
index 8a4ebf175c..99f4195de0 100644
--- a/crates/openhuman-core/src/runtime/pool/README.md
+++ b/crates/openhuman-core/src/runtime/pool/README.md
@@ -1,7 +1,7 @@
# runtime/pool
-The client for pooled inline execution. The pool itself — warm interpreter
-children, the job protocol, backpressure, idle reaping, recycle-after-N — lives
+The client for pooled inline execution. The pool itself (warm interpreter
+children, the job protocol, backpressure, idle reaping, recycle-after-N) lives
in the `tinyruntime` module, where one implementation serves every language.
What is here is two decisions this core still owns.
@@ -24,15 +24,15 @@ than being one error type. Each drives different caller behaviour:
| Variant | The job… | The caller must… |
| --- | --- | --- |
-| `PreDispatch` | provably never reached a worker | fall back to a per-call spawn — safe, because nothing ran |
+| `PreDispatch` | provably never reached a worker | fall back to a per-call spawn (safe, because nothing ran) |
| `PostDispatch` | reached a worker and **may have executed** | **not** retry, or it risks running someone's code twice |
-| `Saturated` | was shed because the pool was full | **not** spawn — that reintroduces exactly the resident memory the pool caps. Report busy, or retry later |
+| `Saturated` | was shed because the pool was full | **not** spawn: that reintroduces exactly the resident memory the pool caps, so report busy or retry later |
`classify` maps the module's failures onto these. The default is `PreDispatch`,
and the asymmetry is deliberate: mistakenly treating a job as un-run costs one
extra fallback spawn, while mistakenly treating a run job as un-run duplicates
-its side effects. Only the two signals the module states explicitly — capacity
-and post-dispatch — move a failure out of the default.
+its side effects. Only the two signals the module states explicitly, capacity
+and post-dispatch, move a failure out of the default.
## Key files
diff --git a/gitbooks/developing/architecture/README.md b/gitbooks/developing/architecture/README.md
index f2205ea1d3..21ad3435c8 100644
--- a/gitbooks/developing/architecture/README.md
+++ b/gitbooks/developing/architecture/README.md
@@ -11,7 +11,7 @@ OpenHuman is open-sourced under GNU GPL3. This page is the high-level shape of t
## The shape
-OpenHuman is a **React + Tauri v2 desktop app** with a **Rust core** that does the heavy lifting.
+OpenHuman is a **React + Tauri v2 desktop app** with a **Rust core** doing the heavy lifting, in the same process rather than as a separate service.
```
┌──────────────────────────────────────────────────────────────────┐
@@ -40,23 +40,25 @@ OpenHuman is a **React + Tauri v2 desktop app** with a **Rust core** that does t
**Where logic lives:**
-- **Rust core**. all business logic. Memory Tree, integrations, model routing, tools, voice. Authoritative.
-- **Tauri shell**. windowing, process lifecycle, IPC. A delivery vehicle, not where features live.
+- **Rust core**. All business logic: Memory Tree, integrations, model routing, tools, voice. Authoritative.
+- **Tauri shell**. Windowing, process lifecycle, IPC. A delivery vehicle, not where features live.
- **React frontend**. UI and orchestration. Calls into core via JSON-RPC: `coreRpcClient` `fetch()`es `http://127.0.0.1:<port>/rpc` directly; only non-loopback plain-`http://` runtimes go through the shell's `relay_http_rpc` command (the `openhuman-rpc` HTTP client).
+Running the core in-process instead of behind a socket is also why it's cheap to run many agents at once: no per-agent OS process, no per-agent socket. See [Performance](../performance.md) for the measurements and [Embedding OpenHuman](../embedding.md) for using the same core as a library outside the desktop app.
+
## Crates
-- `crates/openhuman-app/` — Tauri v2 desktop host; excluded from the root workspace, built from its own manifest.
-- `crates/openhuman-core/` — Cargo package `openhuman`: business domains, JSON-RPC server, CLI, `CoreBuilder`/`CoreRuntime`.
-- `crates/openhuman-embed/` — typed library facade (`openhuman_embed::Harness`) for embedding the core in another product.
-- `crates/openhuman-rpc/` — shared RPC contracts (`RpcOutcome`, `unwrap_rpc`, `StructuredRpcError`) and the HTTP client used by the app and TUI.
-- `crates/openhuman-tui/` — standalone terminal frontend that boots the core in-process.
+- `crates/openhuman-app/` - Tauri v2 desktop host; excluded from the root workspace, built from its own manifest.
+- `crates/openhuman-core/` - Cargo package `openhuman`: business domains, JSON-RPC server, CLI, `CoreBuilder`/`CoreRuntime`.
+- `crates/openhuman-embed/` - typed library facade (`openhuman_embed::Runtime` / `Agent`, with `Harness` as a one-agent shorthand) for embedding the core in another product.
+- `crates/openhuman-rpc/` - shared RPC contracts (`RpcOutcome`, `unwrap_rpc`, `StructuredRpcError`) and the HTTP client used by the app and TUI.
+- `crates/openhuman-tui/` - standalone terminal frontend that boots the core in-process.
The full table is under "Repository layout" in the [deep architecture reference](../architecture.md).
## Data flow
-1. **Connect**. OAuth into a [integration](../../features/integrations/README.md). Backend stores the token; core never sees it in plaintext.
+1. **Connect**. OAuth into an [integration](../../features/integrations/README.md). Backend stores the token; core never sees it in plaintext.
2. **Auto-fetch**. Every twenty minutes the [scheduler](../../features/obsidian-wiki/auto-fetch.md) walks every active connection and asks each native provider to sync.
3. **Canonicalize**. Provider output (an email page, a GitHub diff, a Slack channel dump) is normalized into provenance-tagged Markdown.
4. **Chunk**. Markdown is split into ≤3k-token deterministic chunks.
@@ -65,7 +67,7 @@ The full table is under "Repository layout" in the [deep architecture reference]
7. **Summarize**. Source / topic / global summary trees are built and refreshed from the chunk pool.
8. **Retrieve**. When you ask a question, the agent queries the Memory Tree (search / drill down / topic / global / fetch).
9. **Compress**. Tool output and large source data go through [TokenJuice](../../features/token-compression.md) before entering LLM context.
-10. **Route**. The [router](../../features/model-routing/) picks the right provider+model for the task hint.
+10. **Route**. The [router](../../features/model-routing/) picks the right provider and model for the task hint, one of several [pluggable engines](../engines.md) the core chooses at runtime.
## Privacy boundary
@@ -75,14 +77,14 @@ Stays on your machine:
- The Obsidian Markdown vault.
- Audio capture buffers and any local model state.
-Goes through the OpenHuman backend (under one subscription):
+Goes through the OpenHuman backend (under one subscription, and one TinyHumans API key for embedders):
- LLM calls (model providers).
- Web search proxy.
- Integration OAuth and tool proxying.
- TTS streaming.
-See [Privacy & Security](../../features/privacy-and-security.md) for the full picture.
+See [Privacy & Security](../../features/privacy-and-security.md) for the full picture, and [One TinyHumans API key](../tinyhumans-api-key.md) for what that single key covers.
## Open source