Skip to content

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

docs(hooks): document the hooks module and its upstream contracts

Steven Enamakelb3ba2d9852c7
diff --git a/crates/openhuman-core/src/agent/README.md b/crates/openhuman-core/src/agent/README.md
index c2e101af73..216ddb8469 100644
--- a/crates/openhuman-core/src/agent/README.md
+++ b/crates/openhuman-core/src/agent/README.md
@@ -278,9 +278,9 @@ Turn execution:
| [`turn_env.rs`](./turn_env.rs) | `HostTurnEnv`: the explicit per-turn host values (budget, depth, cancellation, deadline, hooks, tool-belt authority) an entry point hands the session |
| [`progress_tracing.rs`](./progress_tracing.rs), `progress_tracing/` | OpenTelemetry/Langfuse-style spans built from the progress stream ([README](progress_tracing/README.md)) |
| `turn_origin.rs` | `AgentTurnOrigin` task-local, the trust and routing label the approval gate reads |
-| [`stop_hooks.rs`](./stop_hooks.rs) | `StopHook` mid-turn halts and the `tool_call_limit` budget |
+| [`tinyagents/turn_policy.rs`](./tinyagents/turn_policy.rs) | The OpenHuman `tool_call_limit` turn budget |
| [`tool_policy.rs`](./tool_policy.rs) | `ToolPolicy`, the pre-execution allow/deny hook installed through the builder |
-| [`hooks.rs`](./hooks.rs) | `PostTurnHook` background hooks, including ones registered by embedders |
+| [`hooks.rs`](./hooks.rs) | Process-wide embedder hook registries and the `OpenHumanRunContext` identity implementation for upstream hook contracts |
| [`queued_turn.rs`](./queued_turn.rs) | `QueuedTurn`, the payload for a message sent while a turn is running |
| [`cost.rs`](./cost.rs) | Per-turn token and cost accounting (`TurnCost`) |
| [`message_convert.rs`](./message_convert.rs), [`messages.rs`](./messages.rs) | Conversions between `TranscriptMessage` rows and TinyAgents `Message`s; the `history_wire` adapter for host-owned files |
diff --git a/crates/openhuman-core/src/agent/tinyagents/README.md b/crates/openhuman-core/src/agent/tinyagents/README.md
index feb35c5a28..2faeec2f91 100644
--- a/crates/openhuman-core/src/agent/tinyagents/README.md
+++ b/crates/openhuman-core/src/agent/tinyagents/README.md
@@ -44,7 +44,6 @@ The adapter seam between OpenHuman and the vendored [`tinyagents`](../../../../.
| [`policy_denial.rs`](./policy_denial.rs) | `maybe_enrich_policy_block`: rewrites `[policy-blocked]` tool results into structured what/why/workaround messages that tell the model to relay the denial rather than fabricate output. Called from `ToolOutcomeCaptureMiddleware`. |
| [`host/run_context.rs`](./host/run_context.rs) + typed tool dispatch | `OpenHumanRunContext` owns one root `CancellationToken`; child contexts share it and recursive tools receive it from their typed parent `RunContext`. |
| [`steering_forwarder.rs`](./steering_forwarder.rs) | Host adapter over `tinyagents_harness::run_queue::SteeringForwarderGuard` (forwards `RunQueue` steer/collect messages into the harness `SteeringHandle`; abort-on-drop so drop-based cancellation always deregisters it, issue #4456): `QueuedMessage for QueuedTurn`, the `RunQueue*` domain-event sink and the steering-registry cleanup hook. |
-| [`stop_hooks.rs`](./stop_hooks.rs) | Host accounting and halt-summary projection for the TinyAgents stop-hook middleware; budget and goal policies remain in OpenHuman. |
| `summarize.rs` | `ModelSummarizer` / `FaultTolerantCachingSummarizer` plus a context-window-aware `SummarizationPolicy` driving the crate's `ContextCompressionMiddleware`. |
| [`embeddings.rs`](./embeddings.rs) | `ProviderEmbeddingModel`: cost-recording binding over the host-built `tinyinference_embeddings::EmbeddingModel`. |
| [`todos.rs`](./todos.rs) | `todos_store` / `scratch_todos_store` (the crate `Store` behind per-thread agent todos, `tinyagents_graph::todos`). |
diff --git a/crates/openhuman-core/src/hooks/README.md b/crates/openhuman-core/src/hooks/README.md
new file mode 100644
index 0000000000..88f016430c
--- /dev/null
+++ b/crates/openhuman-core/src/hooks/README.md
@@ -0,0 +1,18 @@
+# Hooks
+
+OpenHuman configures external hooks through the contracts owned by
+`tinyagents-hooks`. The core keeps only the process-wide embedder registries in
+[`agent/hooks.rs`](../agent/hooks.rs), implements `HookIdentity` for
+`OpenHumanRunContext`, and installs the configured command `HookEngine` from
+[`ops.rs`](./ops.rs).
+
+Tool callbacks and their scoped registration live in `tinyagents-hooks` and
+`tinyagents-runtime`. OpenHuman supplies its run context so a hook can inspect
+the session, agent and working directory without introducing another hook
+adapter. Post-turn learning uses the upstream `LearningSink` contract and
+receives a privacy-preserving `TurnSummary` after the session commits.
+
+The `hooks.*` RPC namespace and its model-facing command names remain stable.
+Configuration parsing and command execution are supplied by
+`tinyagents_hooks::command`; this module retains the OpenHuman controllers and
+their lifecycle integration.
diff --git a/crates/openhuman-core/src/hooks/mod.rs b/crates/openhuman-core/src/hooks/mod.rs
index 8365d6c906..b0cdeb8784 100644
--- a/crates/openhuman-core/src/hooks/mod.rs
+++ b/crates/openhuman-core/src/hooks/mod.rs
@@ -2,7 +2,7 @@
//!
//! OpenHuman already had *hooks* in the sense of in-process Rust callbacks an
//! embedding host installs ([`crate::agent::hooks`],
-//! [`crate::agent::stop_hooks`]). Those require compiling against
+//! upstream `tinyagents-hooks` contracts. Those require compiling against
//! the core, which makes them the wrong tool for the thing people actually want
//! hooks for: a small script, checked into a repository, that blocks `rm -rf`,
//! runs the formatter after an edit, or writes an audit line per tool call.