Skip to content

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

docs(openhuman-embed): add readmes for examples and tests

Steven Enamakela4dfcf260d61
diff --git a/crates/openhuman-embed/examples/README.md b/crates/openhuman-embed/examples/README.md
new file mode 100644
index 0000000000..a5f3a36bb5
--- /dev/null
+++ b/crates/openhuman-embed/examples/README.md
@@ -0,0 +1,54 @@
+# examples
+
+Runnable programs that use `openhuman-embed` the way a host product would.
+Cargo discovers them, so they run with `cargo run -p openhuman-embed
+--example <name>`. Both build their tokio runtime by hand with
+`AGENT_WORKER_STACK_BYTES` and `MAX_BLOCKING_THREADS` instead of
+`#[tokio::main]`, because a turn overflows tokio's default worker stack. Set
+`RUST_LOG=debug` to see the `[embed]` log lines around each turn.
+
+## run_turn
+
+One turn on a `Harness`, read-only, with live progress printed to stderr.
+By default it builds an ephemeral workspace, points the agent's `action_dir`
+at the current directory, and sends inference to the endpoint you name:
+
+```bash
+OPENHUMAN_EXAMPLE_BASE_URL=https://api.openai.com/v1 \
+OPENHUMAN_EXAMPLE_API_KEY=sk-... \
+OPENHUMAN_EXAMPLE_MODEL=gpt-5 \
+ cargo run -p openhuman-embed --example run_turn -- "What can you see in this directory?"
+```
+
+`OPENHUMAN_EXAMPLE_MODEL` defaults to `gpt-4o-mini`. With
+`OPENHUMAN_EXAMPLE_INHERIT=1` it uses `Workspace::Inherit` and
+`Provider::inherit()` instead: the machine's real OpenHuman workspace and
+whatever inference it is configured with.
+
+```bash
+OPENHUMAN_EXAMPLE_INHERIT=1 cargo run -p openhuman-embed --example run_turn -- "Hello."
+```
+
+## two_agents
+
+A read-only reviewer and a full-access fixer on one `Runtime`, each with its
+own access tier, working directory and model. Run it BYOK with the same three
+variables as `run_turn`, or on managed inference with a TinyHumans API key:
+
+```bash
+OPENHUMAN_EXAMPLE_TINYHUMANS_API_KEY=th_... \
+ cargo run -p openhuman-embed --example two_agents -- "Describe this directory."
+```
+
+## Optional settings
+
+| Variable | Effect |
+| --- | --- |
+| `OPENHUMAN_EXAMPLE_BACKEND_URL` | Points the core's non-inference backend calls at your own backend. |
+| `OPENHUMAN_EXAMPLE_SKILLS_DIR` | Skill bundles to copy in (the reviewer only, in `two_agents`). Ignored without the `skills` feature. |
+
+These programs make real network calls to the endpoint you configure. The
+tests in [`../tests/`](../tests/README.md) cover the same paths against mocks.
+The repository-root `examples/embed_headless.rs` and `examples/embed_kernel.rs`
+use `CoreBuilder` directly, without this crate; run them with
+`cargo run -p openhuman-cli --example embed_headless`.
diff --git a/crates/openhuman-embed/tests/README.md b/crates/openhuman-embed/tests/README.md
new file mode 100644
index 0000000000..357e7fe750
--- /dev/null
+++ b/crates/openhuman-embed/tests/README.md
@@ -0,0 +1,50 @@
+# tests
+
+End-to-end suites for `openhuman-embed`. Each file builds a real `Runtime`
+(or `Harness`) in-process and drives turns against `wiremock` servers that
+stand in for the model provider and, where needed, the backend. No suite
+calls a live LLM or a real service. Cargo discovers these files on its own;
+this crate declares no `[[test]]` entries.
+
+## How the suites are shaped
+
+A runtime claims a process-wide slot (the core's keyring, event bus and
+domain subscribers are process-scoped), so each file is its own test binary
+and usually holds a single `#[test]` that builds one runtime and checks
+everything against it. Splitting the assertions into separate tests would
+either race for the slot or need a mutex. `attached_tools.rs` holds a static
+`RUNTIME_LOCK` for the same reason.
+
+Each `#[test]` builds its tokio runtime with `common::runtime()`, which sets
+the large worker stack a turn needs, instead of using `#[tokio::test]`.
+
+Routing assertions come from the mocks: each agent gets its own provider
+mock, so a turn that leaked to another agent's endpoint shows up as a request
+recorded on the wrong server.
+
+## Layout
+
+| File | What it proves |
+| --- | --- |
+| `common/mod.rs` | Shared helpers: `runtime()`, `offline_config()`, `provider(reply)`, `stub_backend()`, `chat_completion`, `tool_call_completion`, and request inspectors (`chat_requests`, `tool_names`, `tool_results`). |
+| `harness_embed.rs` | A `Harness` runs a real turn with no transport and no background services, routes it to the mock provider, and binds nothing. |
+| `runtime_agents.rs` | Several agents on one runtime keep their own provider, access tier, skills, MCP servers and working directory, and the runtime's API key reaches a mocked managed backend as a bearer. |
+| `session_store.rs` | On a `Stateless` workspace with `InMemorySessionStores`, transcripts, journal and run status land in the store per agent, a reopened agent resumes from the store, and nothing durable is written to the scratch directory. |
+| `attached_tools.rs` | `Agent::attach_tools` sources survive clones and session resume, and name collisions are refused. |
+| `composio_agents.rs` | Two agents with their own `ComposioHostCredential` reach Composio with their own key only. |
+| `memory_facade.rs` | `Runtime::memory` over TinyMemory's in-memory reference engine keeps two tenant roots apart. |
+| `public_api.rs` | Compile-time check that the host-facing types and signatures stay exported. |
+
+## Running
+
+`runtime_agents.rs` gates its skills and MCP assertions on the `skills` and
+`mcp` features, so run with them on:
+
+```bash
+cargo test -p openhuman-embed --features inference,mcp,skills
+cargo test -p openhuman-embed --features inference,mcp,skills --test session_store
+pnpm debug rust session_store
+```
+
+Add a new scenario as a new file rather than a second `#[test]` in an
+existing one, and reuse `common/` for mocks.