Skip to content

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

docs(architecture): add memory architecture documentation

Steven Enamakelce71d414dd90
diff --git a/gitbooks/developing/architecture/README.md b/gitbooks/developing/architecture/README.md
index 2065f3345a..6eff1df319 100644
--- a/gitbooks/developing/architecture/README.md
+++ b/gitbooks/developing/architecture/README.md
@@ -1,17 +1,17 @@
---
description: >-
- High-level shape of the OpenHuman system (desktop shell, Rust core, Memory
- Tree, agent loop). Pointer to the deep developer architecture in the repo.
+ The high-level shape of OpenHuman: the desktop shell, the Rust core and the
+ frontend, plus how data flows between them.
icon: code-branch
---
# Architecture
-OpenHuman is open-sourced under GNU GPL3. This page is the high-level shape of the system; the deep developer architecture lives in [deep architecture reference](../architecture.md) in the repo.
+OpenHuman is open source under GNU GPL3. This page gives the high-level shape of the system. The full developer reference is [Architecture](../architecture.md).
## The shape
-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.
+OpenHuman is a React and Tauri v2 desktop app. A Rust core does the heavy lifting, in the same process rather than as a separate service.
```text
┌──────────────────────────────────────────────────────────────────┐
@@ -34,21 +34,21 @@ OpenHuman is a **React + Tauri v2 desktop app** with a **Rust core** doing the h
│ React frontend (app/src/) │
│ • Screens, navigation │
│ • Talks to core over `coreRpcClient` │
-│ • No business logic - presentation only │
+│ • No business logic, presentation only │
└──────────────────────────────────────────────────────────────────┘
```
-**Where logic lives:**
+Where logic lives:
-- **Rust core**. All business logic: Memory, 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).
+- The Rust core holds all business logic: memory, integrations, model routing, tools and voice. It is authoritative.
+- The Tauri shell handles windowing, process lifecycle and IPC. Features do not live there.
+- The React frontend draws the UI and orchestrates it. It calls the core over JSON-RPC: `coreRpcClient` sends `fetch()` requests straight to `http://127.0.0.1:<port>/rpc`. Only non-loopback plain-`http://` runtimes go through the shell's `relay_http_rpc` command.
-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.
+Running the core in-process, instead of behind a socket, is also why many agents are cheap to run at once. There is no per-agent OS process and 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/`](https://github.com/tinyhumansai/openhuman/tree/main/crates/openhuman-app) - Tauri v2 desktop host; excluded from the root workspace, built from its own manifest.
+- [`crates/openhuman-app/`](https://github.com/tinyhumansai/openhuman/tree/main/crates/openhuman-app) - the Tauri v2 desktop host; excluded from the root workspace, built from its own manifest.
- [`crates/openhuman-core/`](https://github.com/tinyhumansai/openhuman/tree/main/crates/openhuman-core) - Cargo package `openhuman`: business domains, the controller contract and in-process dispatch, `CoreBuilder`/`CoreRuntime`. It is a library: no binary, no JSON-RPC server, and no dependency on `tinyhumans-sdk`.
- [`crates/openhuman-embed/`](https://github.com/tinyhumansai/openhuman/tree/main/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/`](https://github.com/tinyhumansai/openhuman/tree/main/crates/openhuman-rpc) - JSON-RPC 2.0 over the core: the envelopes, the browser-origin allowlist, the HTTP client used by the app and TUI, and the whole server (axum router, auth middleware, Socket.IO, `/dev/connect`, the listener bind). The contract types themselves (`Outcome`, `ControllerSchema`, `StructuredRpcError`) live in the core.
@@ -56,42 +56,40 @@ Running the core in-process instead of behind a socket is also why it's cheap to
- [`crates/openhuman-cli/`](https://github.com/tinyhumansai/openhuman/tree/main/crates/openhuman-cli) - the `openhuman-core` binary, the developer and benchmark bins, and every root `tests/` and `examples/` target.
- [`crates/openhuman-tui/`](https://github.com/tinyhumansai/openhuman/tree/main/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); per-crate notes are in [`crates/README.md`](https://github.com/tinyhumansai/openhuman/blob/main/crates/README.md).
+The full table is under "Repository layout" in [Architecture](../architecture.md). Per-crate notes are in [`crates/README.md`](https://github.com/tinyhumansai/openhuman/blob/main/crates/README.md).
## Data flow
-1. **Connect**. OAuth into an [integration](../../features/integrations/README.md). Backend stores the token; core never sees it in plaintext.
-2. **Sync**. A [memory source](../../features/memory.md) (folder, file, link, GitHub, RSS, or a connected Composio toolkit) syncs on demand and on its own schedule.
-3. **Read**. `tinymemory-sources` turns the source into documents, with an SSRF guard on links.
-4. **Scrub**. Every engine the host binds is wrapped in `memory::guard::ScrubbingEngine`, which uses the `safety` feature of `tinymemory-integrations` to strip secrets and personal identifiers before a write leaves the process. The wrap happens where the engine is resolved, so it covers the tool, the RPC surface, source sync, backfill and import; a caller holding a `BoundEngine` and reaching past it is not covered, which is why resolution is the only sanctioned way to get one.
-5. **Store**. The item goes to the selected engine (hosted TinyHumans or your CortexDB). Conversation turns are logged as they happen, learnings when the agent or you add one.
-6. **Recall / Fetch**. The agent's `memory` tool asks the engine a question (with citations) or runs a raw hybrid search.
-7. **Pack**. Before every turn, a token-budgeted memory pack is recalled and added to that turn's model request only, never to the transcript.
-8. **Forget**. Items are removed by id from the Memory page or the tool.
-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/README.md) picks the right provider and model for the task hint, one of several [pluggable engines](../engines.md) the core chooses at runtime.
+1. Connect. You sign in to an [integration](../../features/integrations/README.md) with OAuth. The backend stores the token, and the core never sees it in plaintext.
+2. Sync. A [memory source](../../features/memory.md) (folder, file, link, GitHub, RSS or a connected Composio toolkit) syncs on demand and on its own schedule.
+3. Read. `tinymemory-sources` turns the source into documents, with an SSRF guard on links.
+4. Scrub. Every engine the host binds is wrapped in `memory::guard::ScrubbingEngine`. It uses the `safety` feature of `tinymemory-integrations` to strip secrets and personal identifiers before a write leaves the process. The wrap happens where the engine is resolved, so it covers the tool, the RPC surface, source sync, backfill and import. A caller that holds a `BoundEngine` and reaches past it is not covered, so resolution is the only supported way to get one.
+5. Store. The item goes to the selected engine, either hosted TinyHumans or your CortexDB. Conversation turns are logged as they happen. Learnings are stored when the agent or you add one.
+6. Recall and fetch. The agent's `memory` tool asks the engine a question and gets an answer with citations, or runs a raw hybrid search.
+7. Pack. Before every turn, a token-budgeted memory pack is recalled. It goes into that turn's model request only, never into the transcript.
+8. Forget. You remove items by id from the Memory page or the tool.
+9. Compress. Tool output and large source data go through [TokenJuice](../../features/token-compression.md) before they enter the LLM context.
+10. Route. The [router](../../features/model-routing/README.md) picks the provider and model for the task hint. It is one of several [pluggable engines](../engines.md) the core chooses at runtime.
## Privacy boundary
Stays on your machine:
-- Workspace config and persona files.
-- Audio capture buffers and any local model state.
+- Workspace config and persona files
+- Audio capture buffers and any local model state
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.
+- LLM calls (model providers)
+- The web search proxy
+- Integration OAuth and tool proxying
+- TTS streaming
-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.
+See [Privacy and 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
-- **Repo:** [github.com/tinyhumansai/openhuman](https://github.com/tinyhumansai/openhuman). GNU GPL3.
-- **Issues and PRs** are welcome. The project is in early beta.
-- For contributors, the canonical developer guide is [deep architecture reference](../architecture.md).
+The code is at [github.com/tinyhumansai/openhuman](https://github.com/tinyhumansai/openhuman) under GNU GPL3. Issues and pull requests are welcome. The project is in early beta. Contributors should start with [Architecture](../architecture.md).
## Further reading
diff --git a/gitbooks/developing/architecture/memory.md b/gitbooks/developing/architecture/memory.md
index b54a733f20..b6e9085df4 100644
--- a/gitbooks/developing/architecture/memory.md
+++ b/gitbooks/developing/architecture/memory.md
@@ -7,13 +7,9 @@ icon: diagram-project
# Memory
-`crates/openhuman-core/src/memory/` is the host layer over TinyMemory: it drives
-the agent memory lifecycle around every turn, with a memory pack recalled before
-the model runs, the turn logged on both sides, memory recalled into compaction
-checkpoints, and belief builds run in the background.
+`crates/openhuman-core/src/memory/` is the host layer over TinyMemory. It runs the agent memory lifecycle around every turn. A memory pack is recalled before the model runs, the turn is logged on both sides, memory is recalled into compaction checkpoints, and belief builds run in the background.
-The behaviour is specified in `docs/specs/memory-v2.md`; the user-facing feature
-is [Memory](../../features/memory.md).
+The behavior is specified in [`docs/specs/memory-v2.md`](https://github.com/tinyhumansai/openhuman/blob/main/docs/specs/memory-v2.md). The user-facing feature is [Memory](../../features/memory.md).
## TinyMemory crates (`vendor/tinymemory/crates/`)
@@ -56,7 +52,7 @@ is [Memory](../../features/memory.md).
The turn's `MemoryTurn` (config, identity, thread, pack) rides
`OpenHumanRunContext::memory_turn`; a child run has its own.
-Chat thread persistence is not memory: it is `tinyagents_session::threads`,
+Chat thread persistence is not memory. It is `tinyagents_session::threads`,
wrapped by `crates/openhuman-core/src/threads/store`.
The MCP server exposes `memory.recall`, `memory.fetch`, `memory.list`,