Skip to content

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

docs(learning): document schemas.rs split and new tools.rs module

Steven Enamakelf85877a59c58
diff --git a/crates/openhuman-core/src/agent/learning/README.md b/crates/openhuman-core/src/agent/learning/README.md
index 6fd45bcddb..e937fe1720 100644
--- a/crates/openhuman-core/src/agent/learning/README.md
+++ b/crates/openhuman-core/src/agent/learning/README.md
@@ -24,7 +24,8 @@ The subsystem is organised in phases (issue #566): **Phase 1** the candidate tax
| `cache.rs` | `FacetCache` — typed wrapper over `user_profile_facets`; class↔key helpers (`class_from_key`, `key_with_class`, `class_prefix`). Delegates to the `MemoryProfile` family via `crate::memory::guard::MemoryGuard`. |
| `stability_detector.rs` | Phase 3 `StabilityDetector::rebuild` — the scoring/budget/state-assignment cycle; thresholds, half-lives, budgets, and the `stability()` formula. Publishes `CacheRebuilt`. |
| `scheduler.rs` | Periodic rebuild loop (`spawn_rebuild_loop`, default 30 min) + event-driven debounced trigger (`register_event_trigger`) subscribing to memory/tree-summarizer events. |
-| `schemas.rs` | All RPC controller schemas + `handle_*` async handlers for the `learning.*` namespace. |
+| `schemas.rs` | `include!`s `schemas_part_01.rs` (controller schema list) and `schemas_part_02.rs` (the `handle_*` async handlers) for the `learning.*` namespace. |
+| `tools.rs` | The 11 `Learning*Tool`s mirroring the RPC surface (see "Agent tools" below). |
| `reflection.rs` | `ReflectionHook` post-turn hook: heuristic reflection-cue capture + LLM reflection, stores observations/patterns/preferences/reflections, emits Goal/Style candidates. |
| `tool_tracker.rs` | `ToolTrackerHook` post-turn hook + `ToolStats`; per-tool running success/failure/duration tallies in the `tool_effectiveness` memory category. |
| `user_profile.rs` | `UserProfileHook` post-turn hook; Aho-Corasick DFA over curated preference phrases, stores matches in the `user_profile` category. |
@@ -37,7 +38,8 @@ The subsystem is organised in phases (issue #566): **Phase 1** the candidate tax
| `extract/summary_facets.rs` | Parses the LLM summariser's structured JSON block; `route_facets_to_buffer` pushes validated candidates (requires `evidence_chunks`). |
| `transcript_ingest/` | Transcript→memory pipeline (`mod.rs`, `extract.rs`, `dedupe.rs`, `persist.rs`, `types.rs`). |
| `transcript_ingest/mod.rs` | `ingest_transcript_path` / `ingest_session_transcript`; extract→dedupe→persist into `conversation_memory` + `conversation_reflections` namespaces. |
-| `*_tests.rs` | Sibling test suites (`cache`, `reflection`, `prompt_sections`, `linkedin_enrichment`). |
+| `test_profile.rs` | In-memory `MemoryProfile` test double (`HashMap` behind a mutex) mimicking the engine's facet ordering, for tests that don't need a real store. Not `#[cfg(test)]`-gated so integration tests under `tests/` (compiled without `cfg(test)`) can still use it. |
+| `*_tests.rs` | Sibling test suites (`cache`, `candidate`, `reflection`, `prompt_sections`, `linkedin_enrichment`, `startup`, `tools`, `schemas`, …). |
## Public surface
diff --git a/crates/openhuman-core/src/agent/registry/README.md b/crates/openhuman-core/src/agent/registry/README.md
new file mode 100644
index 0000000000..47ac01be6b
--- /dev/null
+++ b/crates/openhuman-core/src/agent/registry/README.md
@@ -0,0 +1,118 @@
+# registry
+
+User-facing agent registry. Owns the `agent_registry` RPC namespace: the
+merged list of shipped default agents and user-authored custom agents, their
+enable/disable state, and their tool visibility policy. This is a config
+layer over the harness — the actual tool-calling loop and prompt/runtime
+implementation live in [`agent/harness`](../harness/).
+
+## Files
+
+- [`types.rs`](types.rs) — wire types: `AgentRegistryConfig` (the persisted
+ `entries: Vec<AgentRegistryEntry>`), `AgentRegistryEntry` (id, name,
+ description, `source: AgentRegistrySource` — `Default` vs `Custom` —
+ enabled, model, optional system prompt, `tool_allowlist`/`tool_denylist`,
+ `subagents: AgentSubagentPolicy` allowlist, tags, free-form metadata),
+ `AgentRegistryPatch` (partial update), `AgentRegistrySource`.
+ `AgentRegistryEntry::validate` enforces id/name/description and
+ ASCII-safe id charset for both the entry and its subagent allowlist.
+- [`defaults.rs`](defaults.rs) — `default_agents()` loads the built-ins from
+ [`agents::load_builtins`](agents/mod.rs) and maps each `AgentDefinition` to
+ a registry entry. `definition_from_registry_entry` is the inverse: it
+ synthesizes an `AgentDefinition` from a *custom* entry (one with no shipped
+ harness definition) so a custom agent runs through the same
+ `Agent::from_config_for_agent` factory path as a built-in, with a real tool
+ belt instead of a persona-only completion. Every harness-only field
+ (`omit_*`, temperature, iteration policy, sandbox mode, tier) takes the
+ harness's own safe worker default; see the function's doc comment for the
+ exact mapping and why an empty `tool_allowlist` must stay `Named(vec![])`
+ rather than collapsing to `Wildcard`.
+- [`ops.rs`](ops.rs) — config-backed CRUD: `list_agents`, `get_agent`,
+ `upsert_custom_agent`, `update_agent`, `set_agent_enabled`, `remove_agent`,
+ `merge_entries` (defaults overlaid with persisted config entries,
+ default-first), `find_custom_in_config`. Reads/writes through
+ `config::rpc::load_config_with_timeout` and `Config::save`. Tool listing
+ (`available_tools`) is sourced from the `tools_agent` built-in — its tool
+ scope is the full catalog, unlike the orchestrator's curated subset.
+- [`schemas.rs`](schemas.rs) — `ControllerSchema`/`RegisteredController`
+ definitions for namespace `agent_registry`: `list`, `get`,
+ `available_tools`, `create_custom`, `upsert_custom`, `update`,
+ `set_enabled`, `remove`.
+- [`rpc.rs`](rpc.rs) — request/response payload types and the `*_rpc` handler
+ functions schemas.rs wires up, delegating into `ops.rs`.
+- [`tools.rs`](tools.rs) — backwards-compatible re-export of
+ `agent::orchestration::tools::*` (tool synthesis now lives there).
+- [`agents/`](agents/) — the built-in agent archetypes themselves.
+
+## `agents/`
+
+Each built-in agent owns a subfolder with an `agent.toml` (id, `when_to_use`,
+model, tool allowlist, sandbox, iteration cap, `omit_*` flags — parsed
+directly into `AgentDefinition`), a `prompt.rs` exposing
+`pub fn build(&PromptContext) -> anyhow::Result<String>` wired into
+`PromptSource::Dynamic`, and optionally a `graph.rs` for a bespoke
+`AgentGraph` runner (agents without one use `AgentGraph::Default`). See the
+per-archetype contract documented on [`agents/mod.rs`](agents/mod.rs).
+
+[`agents/loader.rs`](agents/loader.rs) owns `load_builtins` (walks the
+`BUILTINS` slice, parses each `agent.toml`, replaces `system_prompt` with the
+built-in's static `prompt.md` inline text, stamps
+`DefinitionSource::Builtin`) and `validate_tier_hierarchy` (worker-tier
+agents may not list subagents; a higher-tier agent may not delegate up the
+hierarchy; unknown subagent ids are tolerated here — they're a separate
+integrity concern). Workspace-level overrides
+(`$OPENHUMAN_WORKSPACE/agents/*.toml`) are merged in separately by
+`agent::harness::definition_loader`, replacing built-ins on id collision.
+
+| Archetype | Role |
+| --- | --- |
+| `archivist` | Background: extracts lessons from a completed session into `MEMORY.md` and FTS5 |
+| `code_executor` | Repo-scoped worker: locate/read/edit/build/test/git for any repo work |
+| `context_scout` | Read-only pre-flight context bundle (memory, goals, integrations, web) |
+| `critic` | Adversarial, read-only reviewer of diffs/code against project rules |
+| `crypto_agent` | Wallet/market specialist: balances, swaps, contract calls, x402 paid requests |
+| `flow_memory_agent` (feature `flows`) | Read-only context/memory retrieval for automation-flow `agent` nodes |
+| `goals_agent` | Background: keeps `MEMORY_GOALS.md` fresh from session context |
+| `help` | Answers "how does OpenHuman work" questions from the bundled GitBook docs |
+| `image_agent` | Image generation/edit specialist |
+| `integrations_agent` | Drives a single Composio toolkit (gmail, notion, github, …) per spawn |
+| `mcp_agent` (feature `mcp`) | Calls tools on an already-connected MCP server |
+| `mcp_setup` | Walks the user through installing/connecting a new MCP server |
+| `morning_briefing` | Proactive scheduled daily summary (tasks, calendar, email, skills) |
+| `orchestrator` | Default user-facing agent; direct-first, delegates only when it materially helps |
+| `planner` | Read-only architect: breaks a task into a DAG of subtasks with acceptance criteria |
+| `presentation_agent` | Builds decks from evidence; owns grounding/citations/image verification |
+| `profile_memory_agent` | Profile, persona, preferences, people-graph specialist |
+| `researcher` | Web/docs crawler that compresses findings to dense markdown; has a custom `graph.rs` |
+| `scheduler_agent` | Reminders, recurring jobs, cron — time/cron tools only, no live calendar reads |
+| `settings_agent` | App/core config, health/model diagnostics, service lifecycle, security policy |
+| `skill_creator` | Creates/updates SKILL.md packages and Node-backed JS helpers |
+| `summarizer` | Runtime-dispatched only: compresses oversized tool results for the orchestrator |
+| `task_manager_agent` | Task-board/task-source specialist: cards, feeds, artifacts, status |
+| `tool_maker` | Narrow self-healer: writes a polyfill when a host command is missing |
+| `tools_agent` | Generalist heavy execution (shell/HTTP/web/files) that never touches a repo or git |
+| `trigger_reactor` | One or two tool calls in direct reaction to an external trigger, no planning |
+| `trigger_triage` | Classifies an external trigger into drop/acknowledge/react/escalate; never acts |
+| `video_agent` | Video generation/animation specialist |
+| `vision_agent` | Read-only image understanding: describe, OCR, locate UI elements |
+
+`flow_memory_agent` and `mcp_agent` are compiled out entirely when their
+gating feature (`flows`, `mcp`) is disabled; the orchestrator's `agent.toml`
+subagent list still names `mcp_agent` unconditionally (TOML can't be
+`cfg`'d), and both the tool-synthesis path and `validate_tier_hierarchy`
+tolerate that dangling id rather than failing boot.
+
+## Called by
+
+- `agent/harness/definition_loader.rs` — merges built-ins with workspace TOML
+ overrides into the running `AgentDefinitionRegistry`.
+- `agent/library/` — shared agent-authored content referenced by archetypes.
+- `tools/orchestrator_tools.rs` — synthesizes one named delegation tool per
+ id in the orchestrator's `subagents` allowlist, pulling each tool's
+ description live from the target's `when_to_use` so it never drifts from
+ a hardcoded table.
+
+## Tests
+
+`defaults_tests.rs`, `ops_tests.rs`, `schemas_tests.rs`, `types_tests.rs`,
+and under `agents/`: `loader_tests.rs` (+ `loader_tests_part_0N_tests.rs`).