Skip to content

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

docs: add READMEs for artifacts, approval, egress, and web_chat modules

Steven Enamakelf8438531415f
diff --git a/crates/openhuman-core/src/agent/artifacts/README.md b/crates/openhuman-core/src/agent/artifacts/README.md
index 1d4234e506..234f21a3d3 100644
--- a/crates/openhuman-core/src/agent/artifacts/README.md
+++ b/crates/openhuman-core/src/agent/artifacts/README.md
@@ -53,8 +53,8 @@ and trim string params.
| `ai.regenerate` | `artifact_id`, `thread_id`, `client_id` (all required) | `{ artifact_id, regenerated: true, is_error }` |
`ai.regenerate` only accepts `kind == presentation`, reloads `args.json`,
-and re-runs `PresentationTool::with_regenerate_target(id)` inside
-`APPROVAL_CHAT_CONTEXT.scope({thread_id, client_id}, ..)` so the same id
+and re-runs `PresentationTool::with_regenerate_target(id)` with the
+`{thread_id, client_id}` chat context passed to the tool, so the same id
is reused and the Pending/Ready/Failed events route back to the originating
chat. The RPC result is an ack; the card state comes from the socket events.
When `thread_id` is given to `list_artifacts`, legacy records with no
@@ -82,8 +82,8 @@ subscribes to nothing):
- `DomainEvent::ArtifactReady`: from `finalize_artifact` on a real transition.
- `DomainEvent::ArtifactFailed`: from `fail_artifact`.
-All three carry `thread_id` / `client_id` read from the
-`security::approval::APPROVAL_CHAT_CONTEXT` task-local; outside a chat turn
+All three carry `thread_id` / `client_id` taken from the
+`ApprovalChatContext` the producing tool receives with its run context; outside a chat turn
(CLI, cron, sub-agents) both are `None` and the
`web_chat::artifact_surface` subscriber ([`web_chat/event_bus.rs`](../../web_chat/event_bus.rs)) drops the
event.
diff --git a/crates/openhuman-core/src/security/approval/README.md b/crates/openhuman-core/src/security/approval/README.md
index d9a534e5b5..e1792cb313 100644
--- a/crates/openhuman-core/src/security/approval/README.md
+++ b/crates/openhuman-core/src/security/approval/README.md
@@ -32,7 +32,7 @@ Interactive approval workflow for supervised mode (issue #1339). `ApprovalGate`
Re-exported from [`mod.rs`](./mod.rs):
-- Gate: `ApprovalGate`, `ApprovalChatContext`, `FlowRunContext`, the `APPROVAL_CHAT_CONTEXT` / `APPROVAL_COPILOT_STREAM_CONTEXT` / `APPROVAL_FLOW_RUN_CONTEXT` task-locals, `parse_approval_reply`.
+- Gate: `ApprovalGate`, `ApprovalChatContext`, `FlowRunContext`, `ApprovalTurnContext` (the explicit per-turn chat / copilot / flow-run context every gate check takes), `parse_approval_reply`.
- Redaction: `redact_args`, `summarize_action`.
- Types: `PendingApproval`, `ApprovalAuditEntry`, `ApprovalDecision`, `ApprovalSourceContext`, `ExecutionOutcome`, `GateOutcome`.
- Controller registry: `all_approval_controller_schemas`, `all_approval_registered_controllers`.
@@ -101,7 +101,7 @@ stored as JSON strings. With no backend configured (the desktop default)
- `crates/openhuman-core/src/core/runtime/bootstrap.rs`: installs the global gate (`ApprovalGate::init_global`) at startup; `core/all.rs` registers the approval RPC controllers.
- `crates/openhuman-core/src/core/all.rs`: registers the controller schemas.
- `crates/openhuman-core/src/agent/tinyagents/middleware.rs` (`ApprovalSecurityMiddleware`, a `wrap_tool` middleware on every turn path): routes external-effect tool calls through the gate before `execute()` and records the terminal audit row.
-- `crates/openhuman-core/src/web_chat/`: sets `APPROVAL_CHAT_CONTEXT`, hosts `ApprovalSurfaceSubscriber`, and routes typed yes/no replies to `approval_decide`.
+- `crates/openhuman-core/src/web_chat/`: hands each turn its chat `ApprovalTurnContext`, hosts `ApprovalSurfaceSubscriber`, and routes typed yes/no replies to `approval_decide`.
- `crates/openhuman-core/src/channels/proactive.rs`, `crates/openhuman-core/src/agent/triage/escalation.rs`, `crates/openhuman-core/src/tools/impl/system/install_tool.rs`, `crates/openhuman-core/src/web3/wallet/execution.rs`: interact with the gate / approval types.
## Notes / gotchas
diff --git a/crates/openhuman-core/src/security/egress/README.md b/crates/openhuman-core/src/security/egress/README.md
index 18475aa097..854159a021 100644
--- a/crates/openhuman-core/src/security/egress/README.md
+++ b/crates/openhuman-core/src/security/egress/README.md
@@ -25,8 +25,8 @@ plus the `LocalOnly` enforcement chokepoint built on top of it.
`::network_fetch`, rather than the struct literal.
- `emit_external_transfer(descriptor)`: the one call every external-egress
point makes right before a transfer leaves the device. It drops non-external
- transfers, attaches best-effort chat routing from
- `security::approval::APPROVAL_CHAT_CONTEXT`, and fire-and-forget publishes
+ transfers, attaches best-effort chat routing from the
+ turn's `ApprovalChatContext` (an argument, or carried by the `EgressLedger`), and fire-and-forget publishes
`DomainEvent::ExternalTransferPending` on `crate::core::bus::BUS`. This
never blocks or fails the caller.
- `EgressLedger::per_turn()` / `emit_external_transfer_in(&ledger, d)`: an explicit per-turn dedup ledger, passed down the provider factory chain, so a single
diff --git a/crates/openhuman-core/src/web_chat/README.md b/crates/openhuman-core/src/web_chat/README.md
index c9cd88024b..6750b5fbf6 100644
--- a/crates/openhuman-core/src/web_chat/README.md
+++ b/crates/openhuman-core/src/web_chat/README.md
@@ -32,7 +32,7 @@ subscriber all listen to.
v
tokio::spawn( run_turn_under_cancel_and_deadline( )
cancel token + wall-clock backstop
- + WebChat origin + APPROVAL_CHAT_CONTEXT
+ + WebChat origin + chat approval context
run_chat_task (run_task.rs) )
|
| checkout_session_agent (session.rs)
@@ -80,8 +80,8 @@ subscriber all listen to.
`run_task::run_chat_task` through `run_turn_under_cancel_and_deadline`
([`ops/turn_guards.rs`](./ops/turn_guards.rs)). That wrapper puts four things around the same
future: a cooperative `CancellationToken`, the wall-clock backstop, the
- `AgentTurnOrigin::WebChat` scope, and the `APPROVAL_CHAT_CONTEXT`
- task-local.
+ `AgentTurnOrigin::WebChat` scope, and the turn's `ApprovalTurnContext`
+ (handed to `run_chat_task`, which gives it to the session turn).
5. `run_chat_task` checks the session agent out of the per-thread cache
(`session::checkout_session_agent`). The entry is removed from
@@ -313,7 +313,7 @@ because the in-app chat is core product surface (#5002).
This module only produces events.
- External provider adapters (Telegram, Slack, ...) live in `channels/`.
- Prompt-injection policy is `security::prompt_injection`; the approval gate
- and `APPROVAL_CHAT_CONTEXT` are `security::approval`.
+ and `ApprovalTurnContext` are `security::approval`.
- Failure copy per error class is `inference/failure_copy/`; provider
resolution is `inference::provider`.
- Turn-state storage is `threads::turn_state`; the conversation store that the
@@ -321,11 +321,13 @@ because the in-app chat is core product surface (#5002).
## Gotchas
-- `APPROVAL_CHAT_CONTEXT` is a task-local scoped around the `run_chat_task`
- future. The wallet quote-owner gate
- (`web3::wallet::execution::current_owner()`) relies on it staying in scope
- through the inline `.await` chain. Moving the tool loop onto a fresh
- `tokio::spawn` without re-scoping it would silently disable that gate.
+- The chat approval context is an explicit value on the turn
+ (`ApprovalTurnContext`, carried by the turn's run context to the gate and to
+ the tools that read it). A detached sub-agent deliberately starts without it
+ (`OpenHumanRunContext::detached_child`), so its parks route through the
+ origin and are marked detached (#5499). The wallet quote owner is taken from
+ that context by the wallet and Web3 tools; a tool dispatched without a run
+ context has none and cannot prepare or execute an owned quote.
- Approval-reply routing runs before the `beforeSubmitPrompt` hook on
purpose. Reordering them lets a hook strand a turn waiting on an approval.
- Attachment staging must stay ahead of prompt scanning and persistence.