Skip to content

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

chore: files changed crates/openhuman-core/src/api/README.md,crates/openhuman-core/src/channels/READ

Steven Enamakel91a8212b1389
diff --git a/crates/openhuman-core/src/api/README.md b/crates/openhuman-core/src/api/README.md
index b7ba9915bb..2006d5eef9 100644
--- a/crates/openhuman-core/src/api/README.md
+++ b/crates/openhuman-core/src/api/README.md
@@ -64,35 +64,35 @@ or an LLM inference endpoint. Two families are resolved separately because a
`config.api_url` pointed at a local model runner (Ollama, vLLM, LM Studio)
only speaks `/v1/chat/completions` and 404s on every other path:
-- `effective_api_url` — chat/inference base: non-empty `config.api_url` →
- `BACKEND_URL`/`VITE_BACKEND_URL` runtime env → the same keys baked in via
- `option_env!` → environment default. `effective_inference_url` returns an
- explicit `inference_url` override verbatim, otherwise joins
- `OPENHUMAN_INFERENCE_PATH` (`/openai/v1/chat/completions`) onto
- `effective_api_url`.
-- `effective_backend_api_url` — base for all control-plane calls (auth,
- billing, team, integrations, voice, sockets, …). Skips the user's
+- `effective_api_url`: chat/inference base. Resolution order is non-empty
+ `config.api_url`, then `BACKEND_URL`/`VITE_BACKEND_URL` runtime env, then
+ the same keys baked in via `option_env!`, then the environment default.
+ `effective_inference_url` returns an explicit `inference_url` override
+ verbatim, otherwise joins `OPENHUMAN_INFERENCE_PATH`
+ (`/openai/v1/chat/completions`) onto `effective_api_url`.
+- `effective_backend_api_url`: base for all control-plane calls (auth,
+ billing, team, integrations, voice, sockets, and so on). Skips the user's
`api_url` override when it `looks_like_local_ai_endpoint`,
`looks_like_inference_provider_endpoint`, or resolves to a builtin cloud
provider host (`config::schema::cloud_providers`) and is not the OpenHuman
- backend itself, so pointing `api_url` at Ollama or `openrouter.ai` doesn't
+ backend itself, so pointing `api_url` at Ollama or `openrouter.ai` does not
also misroute `/teams/me/usage` and billing calls there. Falls through the
same env/default chain, passed through `normalize_backend_api_base_url`
- (`pub(crate)`) which strips an inference-style path from a misconfigured
+ (`pub(crate)`), which strips an inference-style path from a misconfigured
`BACKEND_URL`.
-- `normalize_api_base_url` — trims whitespace and trailing slashes only; it
+- `normalize_api_base_url`: trims whitespace and trailing slashes only. It
is a cheap string operation with no URL parsing. `api_url(base, path)` is
the matching join helper.
-- `DEFAULT_API_BASE_URL` (`https://api.tinyhumans.ai`) /
+- `DEFAULT_API_BASE_URL` (`https://api.tinyhumans.ai`) and
`DEFAULT_STAGING_API_BASE_URL` (`https://staging-api.tinyhumans.ai`),
chosen by `default_api_base_url_for_env` from `app_env_from_env`, which
reads `OPENHUMAN_APP_ENV` / `VITE_OPENHUMAN_APP_ENV` (`APP_ENV_VAR` /
`VITE_APP_ENV_VAR`) at runtime, then compile time. `api_base_from_env` is
the separate `BACKEND_URL` / `VITE_BACKEND_URL` lookup; both check each key
independently so an empty primary never shadows the secondary.
-- `looks_like_local_ai_endpoint` / `looks_like_inference_provider_endpoint` —
- heuristics documented in-file; both are intentionally tight to avoid
- misclassifying real custom backends or ephemeral test mock servers.
+- `looks_like_local_ai_endpoint` / `looks_like_inference_provider_endpoint`:
+ heuristics documented in-file. Both are intentionally tight so they do not
+ misclassify real custom backends or ephemeral test mock servers.
## `jwt.rs`
@@ -100,10 +100,10 @@ only speaks `/v1/chat/completions` and 404s on every other path:
`crate::security::credentials::session_support::get_session_token` (with
`APP_SESSION_PROVIDER` and `DEFAULT_AUTH_PROFILE_NAME`), so callers keep one
import path for "where the token lives". Token *parsing* and header
-*formatting* — `bearer_authorization_value`, `decode_jwt_payload`,
-`decode_jwt_exp_unix` — are implemented here (they are pure and the
-credentials store needs them on a core with no backend at all; the SDK keeps
-its own identical copy for hosts). `decode_jwt_exp` wraps the Unix-seconds
+*formatting* (`bearer_authorization_value`, `decode_jwt_payload`,
+`decode_jwt_exp_unix`) are implemented here: they are pure, and the
+credentials store needs them on a core with no backend at all. The SDK keeps
+its own identical copy for hosts. `decode_jwt_exp` wraps the Unix-seconds
`exp` decoder in the `chrono` type the credentials store uses, so an expired
token can be rejected locally instead of round-tripping to a guaranteed 401.
None of them verify the signature; the backend stays the authority.
@@ -119,8 +119,8 @@ lower-cases, truncates to 64 bytes, and returns `None` when nothing survives,
so the wrapped value can never break `HeaderValue` construction. The
identity is process-wide (a `OnceLock<RwLock<ProductIdentity>>`), not a
constructor parameter, because `BackendOAuthClient` is built at dozens of
-call sites across domains. **Call `set_product_identity` once at startup,
-before building any backend client** — `BackendOAuthClient` and
+call sites across domains. Call `set_product_identity` once at startup,
+before building any backend client: `BackendOAuthClient` and
`IntegrationClient` bake the identity into their default headers at
construction and do not pick up a later change. A build that never calls
the setter sends `DEFAULT_PRODUCT_IDENTITY` (`"openhuman"`).
diff --git a/crates/openhuman-core/src/channels/README.md b/crates/openhuman-core/src/channels/README.md
index 629897daec..097db972b3 100644
--- a/crates/openhuman-core/src/channels/README.md
+++ b/crates/openhuman-core/src/channels/README.md
@@ -4,7 +4,7 @@ Multi-platform messaging integration. Re-exports the `Channel` trait vocabulary,
## Feature gate
-The domain lives behind the `channels` feature (default-ON, #4801), except two dependency-free carve-outs that always-on code reaches directly: `traits` (the `Channel`/`SendMessage` re-export, named by the always-on agent-harness interactive loop in `agent/session_host/`) and `cli` (`CliChannel`, the stdin/stdout REPL that loop drives in every build). Everything else — `providers`, `host`, `controllers`, `runtime`, `bus`, `proactive`, `commands`, `context`, `routes`, `relay_runtime`, `system_prompt`, the provider re-exports, `doctor_channels`, `start_channels`, `build_system_prompt` and the `test_support` re-export — is `#[cfg(feature = "channels")]`. The feature owns the optional `tinychannels` crate (`channels = ["dep:tinychannels", "tinychannels/email", "tinychannels/lark"]`); the always-on pins (config schema, the `DomainEvent` inbound envelope, security pairing) resolve through the unconditional `tinychannels-bus` contract crate instead. Measured, the gate sheds no transitive packages — its value is compile surface and binary size — and `voice` re-enables `dep:tinychannels` for `EmailChannel` alone. The full rationale is the comment above the `channels` feature in `crates/openhuman-core/Cargo.toml`.
+The domain lives behind the `channels` feature (default-ON, #4801), except two dependency-free carve-outs that always-on code reaches directly: `traits` (the `Channel`/`SendMessage` re-export, named by the always-on agent-harness interactive loop in `agent/session_host/`) and `cli` (`CliChannel`, the stdin/stdout REPL that loop drives in every build). Everything else (`providers`, `host`, `controllers`, `runtime`, `bus`, `proactive`, `commands`, `context`, `routes`, `relay_runtime`, `system_prompt`, the provider re-exports, `doctor_channels`, `start_channels`, `build_system_prompt` and the `test_support` re-export) is `#[cfg(feature = "channels")]`. The feature owns the optional `tinychannels` crate (`channels = ["dep:tinychannels", "tinychannels/email", "tinychannels/lark"]`); the always-on pins (config schema, the `DomainEvent` inbound envelope, security pairing) resolve through the unconditional `tinychannels-bus` contract crate instead. Measured, the gate sheds no transitive packages: its value is compile surface and binary size. `voice` also re-enables `dep:tinychannels`, for `EmailChannel` alone. The full rationale is the comment above the `channels` feature in `crates/openhuman-core/Cargo.toml`.
## Public surface
diff --git a/crates/openhuman-embed/src/agent/README.md b/crates/openhuman-embed/src/agent/README.md
new file mode 100644
index 0000000000..082feef842
--- /dev/null
+++ b/crates/openhuman-embed/src/agent/README.md
@@ -0,0 +1,55 @@
+# agent
+
+One fully described, independently configured participant on a `Runtime`.
+See [`gitbooks/developing/embedding.md`](../../../../gitbooks/developing/embedding.md)
+for how agents fit into the two-step library API.
+
+## Contents
+
+- `mod.rs` — `Agent`, the cheap-to-clone handle a host holds: `run()` /
+ `turn()` to talk to it, `action_dir()` / `workspace_dir()` / `home_dir()` /
+ `skills_dir()` / `transcripts_dir()` for its paths, `provider()` /
+ `access()` / `config()` for inspection. `AgentInner` is the shared state
+ behind every clone, and `AgentError` covers the ways building or driving an
+ agent can fail (duplicate id, invalid id, widening the runtime's surface, a
+ workspace I/O failure).
+- `spec.rs` — `AgentSpec`, the pure-data description a host builds before an
+ agent exists: id, `AgentDefinitionSpec`, provider, access, tool groups,
+ domains, MCP servers (`mcp` feature), a skills directory (`skills`
+ feature), `action_dir`, trusted paths, an escape-hatch config closure, and
+ an optional per-turn tool factory (`tools()`). `Runtime::agent` applies
+ these, in order, onto a clone of the runtime's base config.
+- `definition.rs` — `AgentDefinitionSpec`, `ToolScopeSpec` and
+ `SandboxModeSpec`: a thin re-spelling of the core's `AgentDefinition` so
+ the library surface does not track that struct field by field. The default
+ is the built-in orchestrator's definition under the agent's own id, with
+ every registered tool visible.
+- `layout.rs` — `AgentLayout`: where one agent's files live under the
+ runtime's workspace (`agents/<id>/` for its home and skills,
+ `session_raw/` for transcripts, plus its resolved `action_dir`).
+- `build.rs` — `instantiate`, the function that turns an `AgentSpec` plus a
+ `Runtime` into the assembled `AgentInner` (lays out directories, copies
+ skills, builds the `Config`, derives the `CoreContext`).
+
+## Isolation between agents
+
+Two agents on one runtime never read each other's settings. Each turn
+dispatches under its own derived `CoreContext`, so the core's config loader,
+`DomainSet` gate, tool-group filter and skill discovery all read the agent
+that turn belongs to, not any other agent sharing the runtime.
+
+## Tool factories
+
+`AgentSpec::tools` is the only way a host's own in-process tools reach an
+agent without going through MCP. The factory runs once per session build,
+which in practice means once per turn, because a session is rebuilt from the
+spec's data every time; see the doc comment on `AgentSpec::tools` for why
+this is forced (an `Agent` is `Clone`, `Box<dyn Tool>` is not) and useful (a
+belt bound to something shorter-lived than the agent can vary per turn).
+
+## Where to look next
+
+- [`../runtime/README.md`](../runtime/README.md) — what instantiates an
+ agent and what stays runtime-wide instead of per-agent.
+- [`../harness/README.md`](../harness/README.md) — the one-runtime,
+ one-agent shorthand.
diff --git a/gitbooks/developing/jev.md b/gitbooks/developing/jev.md
new file mode 100644
index 0000000000..b54e306d59
--- /dev/null
+++ b/gitbooks/developing/jev.md
@@ -0,0 +1,178 @@
+# Jev
+
+Jev is a decision model, not a text generator. Give it a request and a
+handful of labelled options, and it returns a calibrated probability for
+each one in about 150 milliseconds. OpenHuman uses it as a fast, cheap judge
+wherever a turn needs to pick from a short list rather than write prose: tool
+selection during a search, and step-by-step browser control.
+
+The models are `jev-1.13` and `jev-latest`, built by TypeSafe AI and reached
+through the TinyHumans System One proxy or, for a BYOK OpenRouter route,
+directly. Pricing is $0.042 per million input tokens, output free, and a
+typical tool search costs one to two thousand tokens. There is no session,
+no chain of thought, and nothing to stream: one request, one set of
+probabilities.
+
+## Three question types
+
+Jev answers three kinds of question, defined in `tinyjevclient`:
+
+- **Choice**: probabilities over a set of named options, so the caller can
+ pick the best one, the top three, or discard everything below a
+ confidence floor.
+- **Score**: a single calibrated number for one thing, rather than a choice
+ among several.
+- **Noul**: a yes/no probability, used where OpenHuman needs "does this even
+ apply" rather than "which of these applies."
+
+Tool search uses a Choice and a Noul in the same request: the Choice picks
+a tool from the shortlist (plus a `none` option), and the Noul answers
+whether the request needs a tool at all. Browser control uses Jev
+repeatedly, once per step, to decide the next action.
+
+## Why retrieval comes first
+
+Jev accepts at most 255 options in one Choice, and its accuracy drops as
+the option list fills with entries that have nothing to do with the
+request. So nothing in OpenHuman ever hands Jev a whole tool catalogue.
+`tinytools-jev` (`vendor/tinyagents/vendor/tinytools/crates/tinytools-jev/`)
+narrows first and decides second:
+
+1. A retriever (BM25 by default, or an embedding-based ranker when one is
+ configured) shortlists `retrieval_k` candidates, 20 by default. This step
+ is skipped when the catalogue already fits in one Choice.
+2. One request to Jev: a Choice over the shortlist plus `none`, and a Noul
+ asking whether the request needs a tool at all.
+3. Hits come back ranked by probability, `none` removed, anything below
+ `min_probability` (0.05 by default) dropped.
+
+`JevRankerConfig::with_strategy` picks how the catalogue gets narrowed:
+
+- `RetrieveThenDecide` (the default): retrieve top 20, decide once. Bounded
+ by the retriever's recall, since a paraphrase the retriever misses never
+ reaches Jev.
+- `FamilyThenDecide`: one evaluation picks the candidates' family first (a
+ toolkit or pack; anything without one falls into `core`), then a second
+ evaluation runs per chosen family (`max_families`, default 2, run
+ concurrently) over every member of that family. A family that fits in one
+ Choice skips retrieval entirely, so a paraphrase is judged on meaning at
+ both stages instead of being filtered out lexically before Jev sees it.
+
+## How OpenHuman uses it
+
+### Tool search
+
+The tinyagents harness owns the `tool_search` / `tool_call` bridge over
+every tool registered as deferred. `openhuman-tinyhumans` installs
+`TinyHumansJevRanker` (`crates/openhuman-tinyhumans/src/jev/ranker.rs`) as
+the process-wide ranker for that bridge
+(`crates/openhuman-core/src/agent/tinyagents/discovery/`). The product
+default uses `RetrieveThenDecide` with the process's embedding provider as
+the retriever, so retrieval finds candidates by meaning rather than by
+shared words before Jev decides among them.
+
+The ranker resolves the signed-in TinyHumans credential fresh on every
+search rather than caching it at install time, because a desktop can sign in
+and out while the process keeps running. The built Jev client is cached by
+credential and backend URL, so a stable session does not rebuild an HTTP
+client on every search. When the process has no usable embedding provider,
+`TinyHumansJevRanker` refuses outright and the harness answers with its own
+BM25 ranking instead of running a Jev decision over a lexical shortlist that
+would only add a network round trip for no gain.
+
+### Browser control
+
+`crates/openhuman-core/src/modules/browser_task.rs` runs bounded browser
+tasks through `tinybrowser_control::JevController`, billed on whichever
+route the agentic provider resolves to (the user's own OpenRouter credential
+directly, or the hosted System One proxy). A consequential step, one that
+would submit a form or send something, returns `NeedsConfirmation` with the
+exact pending decision instead of acting on it; the caller has to get host
+confirmation before the controller proceeds.
+
+## Measured results
+
+From `docs/plans/jev-tool-search-baseline.md`, measured 2026-09-22 against
+215 core tools plus 1,000 recorded Composio actions, with 160 hand-written
+requests (66 mapped to a Composio action, 63 to a core tool, 31 that no tool
+should answer):
+
+| Ranker | Top-1 | Top-3 | Needless calls (of 31) | p50 latency |
+| --- | --- | --- | --- | --- |
+| BM25 | 22.5% | 38.0% | 26 | 28 ms |
+| Jev, BM25 top-20 then decide | 57.4% | 62.0% | 1 | 1.5 s |
+| Jev, embedding top-20 then decide (product default) | 62.0% | 66.7% | 1 | 1.5 s |
+| Jev, family then decide | 62.0-64.3% | 67.4-69.0% | 1 | 1.3 s |
+
+On the Composio-only slice, `FamilyThenDecide` with an embedding cut for
+oversized families reaches 80.3% top-1 and 87.9% top-3, against BM25's 18.2%
+and 36.4%. The gap comes mostly from retrieval, not the decision itself:
+under `RetrieveThenDecide` with BM25 shortlisting, Jev's Composio top-3
+(72.7%) lands exactly on BM25's recall@20, meaning Jev is choosing correctly
+from everything it was shown but a paraphrase like "ping alex" for
+`SLACK_SEND_MESSAGE` never reaches it. Letting Jev pick the family first
+removes the shortlist for every toolkit that fits in one Choice and lifts
+Composio top-3 into the high 80s.
+
+Needless tool calls collapse under any Jev configuration: BM25 answers 26 of
+31 tool-less requests with a (wrong) tool anyway, while Jev's `none` option
+and `needs_tool` Noul let it abstain on all but one.
+
+## Configuration
+
+`ToolSearchConfig` (`crates/openhuman-core/src/config/schema/agent.rs`) is
+the `[agent.tool_search]` block:
+
+```toml
+[agent.tool_search]
+ranker = "jev" # "jev" (default) | "auto" | "bm25" | "compare"
+top_k = 3
+```
+
+- `ranker = "jev"`: use the installed decision-model ranker, falling back to
+ BM25 only when it fails or the process has no TinyHumans credential.
+- `"auto"`: same fallback behaviour as `"jev"`.
+- `"bm25"`: the built-in lexical ranker only, no network call.
+- `"compare"`: serve Jev, but also record the BM25 ranking in the
+ `tool.searched` telemetry, so the two can be compared on live traffic
+ without changing what the model sees.
+- `top_k`: how many matches a search returns when the model does not ask for
+ a specific number. Three by default, enough to choose from without
+ returning so many schemas that the point of deferring them is lost.
+
+Without an embedding provider or a TinyHumans credential, tool search falls
+back to BM25 automatically. `auto` and `jev` cost nothing extra when signed
+out.
+
+## Running the benchmark
+
+```bash
+cargo run -p openhuman-cli --bin tool-search-bench -- --ranker all --misses
+cargo run -p openhuman-cli --bin tool-search-bench -- --ranker jev --family --embedding
+cargo run -p openhuman-cli --bin tool-search-bench -- --dump-catalogue
+```
+
+`OPENHUMAN_BACKEND_API_KEY` (or `TYPESAFE_API_KEY`) selects the credential;
+without one the bench ranks through the signed-in TinyHumans session, same
+as the product.
+
+## Where the code lives
+
+- `vendor/tinyagents/vendor/tinytools/crates/tinytools-jev/`: the
+ transport-neutral `ToolRanker` implementation, its retrieval strategies,
+ and the `JevRankerConfig` / `JevRanking` types.
+- `crates/openhuman-tinyhumans/src/jev/`: the TinyHumans-specific evaluator
+ (`TinyJevEvaluator`, over `tinyjevclient`) and the process-installed
+ ranker (`TinyHumansJevRanker`).
+- `crates/openhuman-core/src/agent/tinyagents/discovery/`: the host slot
+ that holds the installed ranker and turns `[agent.tool_search]` into the
+ policy a turn runs with.
+- `crates/openhuman-core/src/modules/browser_task.rs`: the browser-task
+ entry point that runs `JevController`.
+- `docs/plans/jev-tool-search-baseline.md`: the full benchmark writeup this
+ page's numbers come from.
+
+See also: [Performance](performance.md) for the wider cost and density
+picture, [Pluggable engines](engines.md) for the other swappable pieces
+around inference and memory, and [Embedding OpenHuman](embedding.md) for
+running an agent as a library, including one that uses tool search.