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
docs(agent): document agent archetype layout and prompt pipeline
Steven Enamakel83a4ec0470c3
diff --git a/crates/openhuman-core/src/agent/learning/README.md b/crates/openhuman-core/src/agent/learning/README.mdindex e937fe1720..0b64af0e93 100644--- a/crates/openhuman-core/src/agent/learning/README.md+++ b/crates/openhuman-core/src/agent/learning/README.md@@ -79,7 +79,7 @@ All handlers go through the memory client's `profile_store()` and a `FacetCache`## Events-Uses the typed event bus (`crates/openhuman-core/src/core/event_bus/`):+Uses the typed event bus (`crates/openhuman-core/src/core/bus.rs`, the process-wide `BUS` singleton, and `core/events.rs` for `DomainEvent` / `EventHandler`):- **Publishes**: `DomainEvent::CacheRebuilt { added, evicted, kept, total_size, rebuilt_at }` after each rebuild (`stability_detector.rs`).- **Subscribes**:diff --git a/crates/openhuman-core/src/agent/prompts/mod.rs b/crates/openhuman-core/src/agent/prompts/mod.rsindex 363fb2fa83..81e7ae52f4 100644--- a/crates/openhuman-core/src/agent/prompts/mod.rs+++ b/crates/openhuman-core/src/agent/prompts/mod.rs@@ -1,3 +1,7 @@+//! Bundled prompt assets and system-prompt rendering pipeline. See+//! [`README.md`](README.md) for the section/builder model and the+//! `agent::context::prompt` compat shim.+pub mod types;pub use types::*;mod connected_identities;diff --git a/crates/openhuman-core/src/agent/registry/agents/mod.rs b/crates/openhuman-core/src/agent/registry/agents/mod.rsindex 16365fb11c..8854ff2e5a 100644--- a/crates/openhuman-core/src/agent/registry/agents/mod.rs+++ b/crates/openhuman-core/src/agent/registry/agents/mod.rs@@ -1,9 +1,28 @@+//! Built-in agent archetypes.+//!+//! Each submodule below is one shipped agent and owns the same three+//! files, so none of the 30 leaf `mod.rs` files need their own doc+//! comment:+//!+//! * `agent.toml` — id, `when_to_use`, model, tool allowlist, sandbox,+//! iteration cap, and `omit_*` flags. Parsed directly into+//! [`crate::agent::harness::definition::AgentDefinition`].+//! * `prompt.md` — legacy static prompt body, kept for reference and as+//! the workspace-override target.+//! * `prompt.rs` — exposes `pub fn build(&PromptContext) ->+//! anyhow::Result<String>`, wired into `PromptSource::Dynamic` by+//! [`loader::BUILTINS`] so the prompt can branch on runtime state+//! (available tools, user profile, connected integrations, model hint).+//!+//! A handful of archetypes (currently only `researcher`) additionally own a+//! `graph.rs` exposing `fn graph() -> AgentGraph` for a bespoke turn graph;+//! see [`loader::BuiltinAgent::graph_fn`].+//!+//! See the [package README](../README.md) for what each archetype does and+//! [`loader`] for how this list turns into the running registry.+mod loader;-// Built-in agents. Each module owns an `agent.toml` (metadata), the-// legacy `prompt.md` (kept alongside for reference / workspace-// overrides), and a `prompt.rs` exposing a `pub fn build(&PromptContext)-// -> Result<String>` that the loader wires into `PromptSource::Dynamic`.pub mod archivist;pub mod code_executor;pub mod context_scout;diff --git a/crates/openhuman-core/src/tools/toolpacks/README.md b/crates/openhuman-core/src/tools/toolpacks/README.mdnew file mode 100644index 0000000000..09cd4e6317--- /dev/null+++ b/crates/openhuman-core/src/tools/toolpacks/README.md@@ -0,0 +1,96 @@+# toolpacks++On-demand tool disclosure. A tool's JSON schema is charged on every provider+call of every turn whether or not the tool is used; the Master Agent's belt+measured ~21.4k tokens of schema against a ~4.3k-token system prompt, so most+of that fixed cost is idle in most conversations. A pack keeps its tools+constructed and executable but unadvertised: the agent sees one small tool,+`use_skill`, instead of the pack's real schemas.++## How it works++- [`types::ToolPack`] is the unit: an `id`, a one-line `summary` shown in the+ always-on pack index, the `tools` it owns, and `owners` — agent ids the pack+ is *not* applied to, because the specialist that a family was delegated to+ (e.g. `settings_agent` for `system`) should not pay a `use_skill` round trip+ on every call of its own belt.+- [`registry::PACKS`] is the compiled-in table. Membership is a build-time+ decision on purpose: a pack config or RPC could edit would let a caller move+ a dangerous tool out of the reviewed, advertised surface without review.+ `registry::pack`, `pack_for_tool`, `all_packed_tool_names`,+ `packed_tool_names_for_agent`, and the two `pack_index_markdown*` /+ `callable_pack_ids` helpers all read this table.+- [`tools::UseSkillTool`] (name constant `USE_SKILL = "use_skill"`) is the one+ always-on proxy tool. Called with `skill` alone it renders that pack's tool+ schemas into the conversation (`render_pack_filtered`); called with `skill` ++ `tool` + `args` it resolves and executes the real tool, forwarding+ permission level, timeout policy, and external-effect classification so+ nothing is laundered through the proxy. [`tools::PackRegistryHandle`] is the+ late-bound, non-owning (`Weak`) view into the agent's tool registries the+ proxy dispatches through — two of them (durable + `synthesized_tools`),+ since `delegate_*` tools live in the second and both must be rebound after+ every registry rebuild (see `ops::bind_pack_registry` /+ `ops::bind_synthesized_pack_registry` doc comments for the exact call+ points and staleness failure mode).+- [`ops::strip_packed_from_visible`] does the actual compression: it removes+ a pack's tool names from an agent's advertised `visible` set and adds+ `use_skill` back in only if something was actually withheld.+ [`ops::is_withheld_from`] exposes the same predicate for callers building a+ tool *listing* rather than mutating a `visible` set (the collapsed+ `delegate_to` tool).++**Why a proxy instead of dynamic registration.** Registering the real schemas+mid-turn would be better (native tool calling, no nested `args` object), but+`tinyagents` registers tools into a plain `HashMap` behind `&mut` before the+turn starts and derives the provider-facing schema list once from that.+Making the registry interior-mutable and re-deriving schemas per iteration is+the upstream change that would retire this proxy.++## `ToolGroups`++[`groups::ToolGroups`] (fixed-size array, `GROUP_COUNT = PACKS.len()`) is the+`CoreBuilder`-facing narrowing control referenced from `AGENTS.md` ("tool+visibility with `ToolGroups`"). Per pack it holds a [`groups::GroupMode`]:++| Mode | Schemas on the wire | Registered and callable |+| --- | --- | --- |+| `Advertised` | yes | yes |+| `Withheld` (default) | no, reached via `use_skill` | yes |+| `Off` | no | no |++`ToolGroups::default()`/`packed()` puts every pack in `Withheld` — exactly the+compiled-in behavior before this type existed, so a host that never calls+`CoreBuilder::tool_groups` is unaffected. This axis only narrows: a pack+compiled out by a Cargo feature, or off under the ambient `DomainSet`, stays+absent regardless of the mode set here. `groups::current()` reads the ambient+`ToolGroups` off `CoreContext`, falling back to `Withheld`-everywhere when+there is no context (unit tests, pre-boot CLI paths).++## Name collision++`use_skill` here is the tool-pack disclosure proxy in this module. It is+unrelated to `skills::runtime::run_skill`, which is itself one of the tools+packed under the `skills` pack (see `registry::PACKS`) — do not conflate the+two when tracing a `run_skill` call.++## Called by++- `crates/openhuman-core/src/tools/ops.rs` — registers `use_skill` into the+ default/all tool registries.+- `crates/openhuman-core/src/core/runtime/builder.rs` and+ `crates/openhuman-core/src/core/runtime/context.rs` — `CoreBuilder::tool_groups`+ plumbing and the ambient `ToolGroups` on `CoreContext`.+- `crates/openhuman-core/src/agent/harness/session/builder/` — binds the pack+ registry (durable and synthesized) when an agent's tool `Arc`s are built or+ rebuilt, and strips packed names from the agent's visible set.+- `crates/openhuman-core/src/agent/orchestration/tools/collapsed_delegation.rs`+ — consults `is_withheld_from` so a collapsed `delegate_to` listing never+ re-advertises a route the pack table withholds.+- `crates/openhuman-embed/` — `Harness` builders expose `ToolGroups` to+ embedding hosts.++## Tests++`toolpacks_tests.rs` and `toolpacks_tests_part_02_tests.rs` (pack table+invariants, `strip_packed_from_visible`, `render_pack_filtered` behavior);+`groups_tests.rs` (`GroupMode` defaults and narrowing rules).