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 pull request #7133 from senamakel/openhuman-embed-host-only
Steven Enamakel0ede52d90323
diff --cc crates/openhuman-embed/README.mdindex 70f435a986,d550dac9fd..e6e9122315--- a/crates/openhuman-embed/README.md+++ b/crates/openhuman-embed/README.md@@@ -447,114 -364,123 +447,151 @@@ included) and the gateway-reported cosCohere, Ollama, mock) for hosts that keep their own vector index, with thesignature format unchanged so stored vectors stay in their partition.+ ## Locked-down agents: `HostOnly`++ An agent that reads untrusted input (a PR diff) and must never act takes+ `ToolScopeSpec::HostOnly`: the tools it can see and call are the ones the host+ supplies (`AgentSpec::tools`, `Agent::attach_tools`) and nothing else.++ ```rust,no_run+ use openhuman_embed::{AgentDefinitionSpec, AgentSpec, HostTurnTools, ToolScopeSpec};+ # fn read_only_tools() -> Vec<Box<dyn openhuman_embed::Tool>> { Vec::new() }+ let spec = AgentSpec::new("reviewer")+ .definition(+ AgentDefinitionSpec::new()+ .bare_prompt("You review pull requests.")+ .tools(ToolScopeSpec::HostOnly),+ )+ .tools(|_| HostTurnTools::advertised(read_only_tools()));+ ```++ - No config-derived tool is built and no delegation tool is synthesised, so+ shell, file writes, network, memory, skills, MCP and sub-agents do not exist+ for the model. A deny-by-default gate refuses any other name it calls anyway.+ - Access and sandbox are forced read-only, whatever `Access` was set (even+ after `AgentSpec::config`). Declaring MCP servers or skills is an error.+ - The agent needs its own prompt. `bare_prompt(text)` makes `text` the whole+ system prompt: no identity, safety, tools, workspace or memory section.++ Host tools should themselves be read-only: `HostOnly` bounds which tools+ exist, not what they do.++ Per turn, `Turn::response_format(ResponseFormat)` (the `complete` type) and+ `Turn::max_tokens(n)` apply to every call of the tool loop on any runtime-owned+ agent. `TurnOutcome` then carries `structured` (the reply parsed as JSON),+ `finish_reason`, `answered_model`, and `usage.reasoning_tokens`.+ `Turn::untrusted_input(true)` reads the message as data, so the prompt-injection+ guard and screen are skipped. It is accepted only on a `HostOnly` agent; any+ other agent refuses the turn (`untrusted_input_requires_host_only`).+## Feature flags-Every feature on this crate is a pass-through to the same-named feature on-`openhuman-core` (package `openhuman`): `default`, `http-server`,-`inference`, `documents`, `hosting`, `modules`, `voice`, `web3`,-`runtime-node`, `contacts`, `media`, `flows`, `skills`, `mcp`,-`crash-reporting`, `channels`,-`sandbox-bubblewrap`, `browser-native`, `whatsapp-web`,-`file-logging`, `scheduler-gate`.+Every feature is a pass-through to the same-named feature on+`openhuman-core` (package `openhuman`): `default`, `http-server`, `inference`,+`documents`, `hosting`, `modules`, `voice`, `web3`, `runtime-node`, `media`,+`flows`, `skills`, `mcp`, `crash-reporting`, `channels`, `whatsapp-web`,+`file-logging` and `scheduler-gate`. A gate added to the core has to be+forwarded here (and then by `openhuman-tinyhumans` and `openhuman-cli`);+[`scripts/ci/check-feature-forwarding.mjs`](../../scripts/ci/check-feature-forwarding.mjs) checks the chain.-Two of them also gate items on this crate's own public surface:+Two features also gate this crate's own surface. `mcp` adds `HttpHeader`,+`McpAuthConfig`, `McpServer`, `AgentSpec::mcp` and `HarnessBuilder::mcp`.+`skills` adds `AgentSpec::skills_dir` and `HarnessBuilder::skills_dir`.-- `mcp`: `HttpHeader`, `McpAuthConfig`, `McpServer`, `AgentSpec::mcp` and- `HarnessBuilder::mcp`.-- `skills`: `AgentSpec::skills_dir` and `HarnessBuilder::skills_dir`.--See [`docs/library-minimal-recipe.md`](../../docs/library-minimal-recipe.md)-for a measured minimal-footprint feature set, and+[`docs/library-minimal-recipe.md`](../../docs/library-minimal-recipe.md) has a+measured minimal feature set, and[`gitbooks/developing/performance.md`](../../gitbooks/developing/performance.md)-for the resulting binary sizes and per-agent memory numbers.--## Examples and tests+has the resulting binary sizes and per-agent memory.++## Boundaries++- The only in-repo dependency is `openhuman-core` with+ `default-features = false`. Every capability comes from a forwarded+ feature.+- No JSON-RPC here. This crate does not depend on `openhuman-rpc`; `Outcome`+ and `StructuredRpcError` are core types. `openhuman-app` and+ `openhuman-tui` use `openhuman-rpc` and the core directly and do not use+ this crate.+- No backend client. The hosted transport, product identity, login-token+ exchange and `/auth/me` live in `openhuman-tinyhumans`.+- The agent loop, transcripts, session identity and tool-call parsing belong+ to [`vendor/tinyagents`](../../vendor/tinyagents/) (repo `tinyhumansai/tinyagents`); the `Tool` trait+ belongs to its nested `tinytools`. Use the `Tool` re-exported here: a+ separately added `tinytools` builds an incompatible type.+- Memory contracts come from [`vendor/tinymemory`](../../vendor/tinymemory/) (`tinymemory-api`).++## Gotchas++- One runtime per process. The keyring master key, the RPC bearer, the+ event bus and the `Once`-guarded domain subscribers are process-scoped+ (`CoreContext::init`). A second `RuntimeBuilder::build` returns+ `RuntimeError::AlreadyRunning`; a second harness returns+ `HarnessError::AlreadyRunning`. `Core::from_runtime` is not guarded, but+ the same rule applies to the `CoreRuntime` beneath it. The slot is+ released only when the `Runtime` and every `Agent` built on it are+ dropped.+- Build the tokio runtime yourself. A turn is a deep async state machine,+ and a nested sub-agent overflows tokio's default 2 MiB worker stack, so+ `#[tokio::main]` is not enough. The constants live in the core crate, so+ the host needs the `openhuman` package as a dependency to name them:++ ```rust,no_run+ use openhuman_core::core::runtime::{AGENT_WORKER_STACK_BYTES, MAX_BLOCKING_THREADS};++ let runtime = tokio::runtime::Builder::new_multi_thread()+ .enable_all()+ .thread_stack_size(AGENT_WORKER_STACK_BYTES)+ .max_blocking_threads(MAX_BLOCKING_THREADS)+ .build()+ .expect("tokio runtime");+ ```++- Access has two halves. The autonomy tier drives `SecurityPolicy`, and the+ turn origin (a task-local) drives the approval gate. `Access::full()` sets+ both; setting only the tier through `config` gives an agent whose acting+ tools refuse while the transcript looks plausible. `readonly()` and+ `supervised()` set no origin and leave the approval gate on, so an+ unattended supervised agent stalls on approvals until they expire.+- When building a `CoreRuntime` yourself, set `config_path` together with+ `workspace_dir` (`CoreBuilder::workspace(dir)` does both). Credentials,+ auth profiles and the keyring file resolve beside `config_path`, so a+ workspace-only override reads the operator's real credentials. `Runtime`+ and `Harness` handle this for `Ephemeral`, `Stateless` and `Dir`, and the+ `AgentSpec::config` escape hatch cannot move it.+- Supply skills through `skills_dir`, which copies bundles. Skill discovery+ rejects symlinked bundles, so linking them in silently does nothing.+- `Provider::model` is advisory. A model no provider serves falls back to+ the default rather than failing, and a route with no model resolved is+ ignored.+- A `Route` (or `Provider::openai_compatible`) that pairs a key with a plain+ `http://` endpoint is refused before dispatch with+ `CoreError::InsecureRoute`. A route without a key is allowed.+- A resumed session keeps its first system prompt and tool list. Prompt+ changes and a tool factory that returns a different belt only reach new+ sessions.++## Tests++The integration suites under [`tests/`](tests/README.md) each build one+runtime per process against `wiremock` providers; unit tests sit beside+their modules as `*_tests.rs`.```bash-# Against any OpenAI-compatible endpoint:-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?"--# Or against the machine's own configured inference, in its real workspace:-OPENHUMAN_EXAMPLE_INHERIT=1 cargo run -p openhuman-embed --example run_turn -- "Hello."+cargo test -p openhuman-embed --features inference,mcp,skills+cargo test -p openhuman-embed --features inference,mcp,skills --test runtime_agents```-Optional: `OPENHUMAN_EXAMPLE_BACKEND_URL` points non-inference backend calls-somewhere specific, and `OPENHUMAN_EXAMPLE_SKILLS_DIR` supplies skill bundles.+The repository-root [`examples/embed_headless.rs`](../../examples/embed_headless.rs) and [`examples/embed_kernel.rs`](../../examples/embed_kernel.rs)+drive `CoreBuilder` directly, without this crate. They are `[[example]]`+targets of `openhuman-cli`:+`cargo run -p openhuman-cli --example embed_headless`.-Two agents on one runtime, either BYOK with the same variables as above, or-managed inference with `OPENHUMAN_EXAMPLE_TINYHUMANS_API_KEY`:--```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 two_agents -- "Describe this directory."--# Or managed inference, no BYOK endpoint needed:-OPENHUMAN_EXAMPLE_TINYHUMANS_API_KEY=th_… \- cargo run -p openhuman-embed --example two_agents -- "Describe this directory."-```+## Further reading-The repository-root `examples/embed_headless.rs` (`DomainSet::harness()`,-`ServiceSet::none()`, RPC through `CoreRuntime::invoke`) and-`examples/embed_kernel.rs` (`DomainSet::kernel()`, then opt one family back-in) drive `CoreBuilder` from `openhuman_core` directly, without this crate;-they are `[[example]]` entries of the `openhuman` package, so run them with-`cargo run --example embed_headless`.--`tests/harness_embed.rs` is the end-to-end proof that `Harness` runs a real-turn against a `wiremock` provider with nothing bound;-`tests/runtime_agents.rs` runs three agents with different providers, access-tiers, skills, MCP servers and working directories on one runtime and shows-the API key reaching a mocked managed backend as a bearer;-`tests/public_api.rs` pins the host-facing embedding contract at compile-time. Run them with `cargo test -p openhuman-embed --features inference,mcp,skills`.--## Relationship to other crates--Its only in-repo dependency is `openhuman-core` (package `openhuman`) with-`default-features = false`: every capability comes from a feature forwarded-above. It does not depend on `openhuman-rpc`; `Outcome` and `StructuredRpcError`-are core types (`openhuman_core::core`). `openhuman-app` and `openhuman-tui`-depend on `openhuman-rpc` for its client (and the app on its server) and on-`openhuman-core`; neither uses `openhuman-embed`.--## Permanent tools on supplied agents--Hosts can pass an existing configured `Agent` to another library, which adds-its tools through `Agent::attach_tools` without constructing a replacement.-Attachments are shared by clones, always directly advertised, and update only-their managed system catalogue when a continuing conversation gains tools.-See [agent attachment semantics and example](src/agent/README.md#attach-tools-to-an-existing-agent)-for source identity, collision errors, policy composition, and runtime identity.+- [`crates/openhuman-embed/examples/README.md`](examples/README.md): the examples module README.+- [`gitbooks/developing/embedding.md`](../../gitbooks/developing/embedding.md): embedding the core in another product.+- [`gitbooks/developing/tinyhumans-api-key.md`](../../gitbooks/developing/tinyhumans-api-key.md): running on a TinyHumans API key.+- [`gitbooks/developing/architecture.md`](../../gitbooks/developing/architecture.md): architecture overview.+- [`gitbooks/developing/architecture/agent-harness.md`](../../gitbooks/developing/architecture/agent-harness.md): the agent harness.+- [`gitbooks/developing/loadable-modules.md`](../../gitbooks/developing/loadable-modules.md): loadable modules.+- [`crates/README.md`](../README.md): crates overview.diff --cc scripts/ci/check-openhuman-rust-layout.mjsindex 42a7efdf74,458fa86b9f..893a818b9d--- a/scripts/ci/check-openhuman-rust-layout.mjs+++ b/scripts/ci/check-openhuman-rust-layout.mjs@@@ -43,9 -43,9 +43,9 @@@ const LEGACY_LIMIT_ENTRIES =// provider, security, memory, tool and prompt policy. Generic session// state moved to tinyagents-runtime; this remaining composition is split in// a follow-up without reintroducing an old harness/session exception.- ["crates/openhuman-core/src/agent/session_host/builder/factory.rs", 986],+ ["crates/openhuman-core/src/agent/session_host/builder/factory.rs", 984],["crates/openhuman-core/src/agent/subagent_host/lifecycle.rs", 1309],- ["crates/openhuman-core/src/agent/subagent_host/ops/runner.rs", 1152],+ ["crates/openhuman-core/src/agent/subagent_host/ops/runner.rs", 1150],["crates/openhuman-core/src/tools/ops.rs", 1209],["crates/openhuman-core/src/web_chat/progress_bridge.rs", 1304],// These established external test modules grew with upstream coverage. Pin