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(skills, tools): add README documentation for webhooks and timeout modules
Steven Enamakel5b147dbcbcb9
diff --git a/crates/openhuman-core/src/skills/webhooks/README.md b/crates/openhuman-core/src/skills/webhooks/README.mdindex 44585209a4..c4bd52e008 100644--- a/crates/openhuman-core/src/skills/webhooks/README.md+++ b/crates/openhuman-core/src/skills/webhooks/README.md@@ -1,8 +1,8 @@# webhooks-Client-side webhook **tunnel routing** for OpenHuman. The backend provisions and hosts the actual tunnels (ngrok / cloudflare / etc.) and forwards incoming HTTP requests to the app over Socket.IO; this module maps each backend tunnel UUID to its owning target (a skill, the built-in echo responder, or the agent triage pipeline), dispatches incoming requests, builds responses, captures debug logs, and exposes both local routing RPCs and thin proxies to the backend's tunnel-management API.+Client-side webhook tunnel routing for OpenHuman. The backend provisions and hosts the actual tunnels (ngrok / cloudflare / etc.) and forwards incoming HTTP requests to the app over Socket.IO; this module maps each backend tunnel UUID to its owning target (a skill, the built-in echo responder, or the agent triage pipeline), dispatches incoming requests, builds responses, captures debug logs, and exposes both local routing RPCs and thin proxies to the backend's tunnel-management API.-`webhooks` is nested under `skills/` for historical reasons but is **not** gated by the `skills` Cargo feature: it has always-compiled callers in `crates/openhuman-core/src/core/` and stays outside the `skills` feature gate (see `crates/openhuman-core/src/skills/mod.rs`).+`webhooks` is nested under `skills/` for historical reasons but is not gated by the `skills` Cargo feature. It has always-compiled callers in `crates/openhuman-core/src/core/` and stays outside the `skills` feature gate (see `crates/openhuman-core/src/skills/mod.rs`).## Responsibilitiesdiff --git a/crates/openhuman-core/src/tools/timeout/README.md b/crates/openhuman-core/src/tools/timeout/README.mdindex e6c7341860..1373f4497b 100644--- a/crates/openhuman-core/src/tools/timeout/README.md+++ b/crates/openhuman-core/src/tools/timeout/README.md@@ -1,48 +1,50 @@# tool_timeout-Process-wide wall-clock timeout policy for tool execution (the node/tool runtime and the agent loop). It resolves a single bounded timeout value and exposes it as seconds and as a `Duration` for callers that wrap individual tool calls in a timeout. The value is **runtime-mutable**: the UI (via the `config.update_agent_settings` RPC) can change it without a core restart, and the change takes effect on the next tool call.+Process-wide wall-clock timeout policy for tool execution (the node/tool runtime and the agent loop). It resolves a single bounded timeout value and exposes it as seconds and as a `Duration` for callers that wrap individual tool calls in a timeout. The value is runtime-mutable: the UI (via the `config.update_agent_settings` RPC) can change it without a core restart, and the change takes effect on the next tool call.## Resolution orderHighest precedence first:-1. `OPENHUMAN_TOOL_TIMEOUT_SECS` environment variable — operator override. When set to a valid value (`1..=3600`) it always wins; config pushes are ignored while it is present.+1. `OPENHUMAN_TOOL_TIMEOUT_SECS` environment variable, an operator override. When set to a valid value (`1..=3600`) it always wins; config pushes are ignored while it is present.2. The persisted config value (`[agent].agent_timeout_secs`), pushed in via `set_tool_timeout_secs` at startup (from `core::jsonrpc::register_domain_subscribers`, the always-on core boot path) and on every `config.update_agent_settings` RPC.3. The built-in `DEFAULT_TIMEOUT_SECS` (`120`) default.## Responsibilities-- Hold the effective timeout in a process-global `AtomicU64`, seeded lazily from env/default on first read.-- Bound every candidate value to `1..=3600` seconds; fall back to the `120`s default on missing, non-numeric, zero, negative, or out-of-range input.+- Hold the effective timeout in a process-global `AtomicU64`, seeded lazily from env or default on first read.+- Bound every candidate value to `1..=3600` seconds, falling back to the `120`s default on missing, non-numeric, zero, negative, or out-of-range input.- Let the persisted config drive the value at runtime while keeping the operator env var as an always-wins override.-- Provide the timeout to callers in two shapes: raw seconds (for logging / matching frontend timeouts) and `Duration` (for `tokio::time::timeout`-style wrapping).-- Keep parsing/resolution logic pure and testable, isolated from global-state mutation.+- Provide the timeout to callers in two shapes: raw seconds (for logging and matching frontend timeouts) and `Duration` (for `tokio::time::timeout`-style wrapping).+- Keep parsing and resolution logic pure and testable, isolated from global-state mutation.## Key files| File | Role || --- | --- |-| `crates/openhuman-core/src/tools/timeout/mod.rs` | Entire module: constants, env parsing, pure resolver, atomic-backed runtime value, setter, public accessors, and inline unit tests. |+| `crates/openhuman-core/src/tools/timeout/mod.rs` | Entire module: constants, env parsing, pure resolver, atomic-backed runtime value, setter, public accessors. |+| `crates/openhuman-core/src/tools/timeout/mod_tests.rs` | Unit tests for the module, run via the `#[path = "mod_tests.rs"] mod tests` include in `mod.rs`. |## Public surface-- `parse_tool_timeout_secs(raw: Option<&str>) -> u64` — pure parser; bounds to `1..=3600`, else returns the `120`s default.-- `set_tool_timeout_secs(config_secs: u64) -> u64` — push a config-sourced value into the runtime atomic, honouring the env override. Returns the effective value stored. Called at startup and on each config update.-- `env_override_active() -> bool` — `true` when `OPENHUMAN_TOOL_TIMEOUT_SECS` is set to a valid override (so UI changes are ignored). Surfaced to the settings panel.-- `tool_execution_timeout_secs() -> u64` — effective timeout in seconds (read fresh each call).-- `tool_execution_timeout_duration() -> Duration` — same effective value as a `Duration`.-- `explicit_call_timeout_secs(requested: Option<u64>, cap: u64) -> Option<u64>` — resolve an **explicit** per-call timeout for an otherwise-unbounded scripting tool. `None`/`Some(0)` ⇒ `None` (run unbounded); any positive value clamps to `MIN_TIMEOUT_SECS..=cap`. Callers pass their own ceiling (`MAX_TIMEOUT_SECS` for `shell`, `1800` for `node_exec`/`npm_exec`).-- `explicit_call_timeout_duration(requested: Option<u64>, cap: u64) -> Option<Duration>` — same as a `Duration`, `None` for unbounded.+- `parse_tool_timeout_secs(raw: Option<&str>) -> u64`: pure parser. Bounds to `1..=3600`, else returns the `120`s default.+- `set_tool_timeout_secs(config_secs: u64) -> u64`: pushes a config-sourced value into the runtime atomic, honoring the env override. Returns the effective value stored. Called at startup and on each config update.+- `env_override_active() -> bool`: true when `OPENHUMAN_TOOL_TIMEOUT_SECS` is set to a valid override, so UI changes are ignored. Surfaced to the settings panel.+- `tool_execution_timeout_secs() -> u64`: effective timeout in seconds, read fresh each call.+- `tool_execution_timeout_duration() -> Duration`: same effective value as a `Duration`.+- `explicit_call_timeout_secs(requested: Option<u64>, cap: u64) -> Option<u64>`: resolves an explicit per-call timeout for an otherwise-unbounded scripting tool. `None` or `Some(0)` means `None` (run unbounded); any positive value clamps to `MIN_TIMEOUT_SECS..=cap`. Callers pass their own ceiling (`MAX_TIMEOUT_SECS` for `shell`, `1800` for `node_exec`/`npm_exec`/`python_exec`).+- `explicit_call_timeout_duration(requested: Option<u64>, cap: u64) -> Option<Duration>`: same as a `Duration`, `None` for unbounded.+- `resolve_tool_deadline(policy: tinytools::ToolTimeout) -> (Option<Duration>, u64)`: resolves a tool's `ToolTimeout` policy (`Inherit`, `Millis(req)`, or `Unbounded`) into the `(deadline, timeout_secs)` pair the agent tool-execution loop enforces, padding an explicit millisecond request with `TOOL_TIMEOUT_GRACE_SECS` before the hard deadline fires.- Constants: `DEFAULT_TIMEOUT_SECS = 120`, `MIN_TIMEOUT_SECS = 1`, `MAX_TIMEOUT_SECS = 3600`, `SANDBOX_UNBOUNDED_CAP_SECS = 86_400`, `ENV_VAR = "OPENHUMAN_TOOL_TIMEOUT_SECS"`.## Scripting tools run unbounded (issue #4023)-The global timeout governs **non-scripting** tools only — a hung network/MCP call must stay bounded. The scripting tools (`shell`, `node_exec`, `npm_exec`) instead run with **no** default deadline: a build / solver / test run legitimately takes minutes and must not be hard-killed. They expose a per-call `timeout_secs` argument and return [`Tool::timeout_policy`] → `ToolTimeout::Unbounded` when none is supplied, or `ToolTimeout::Secs(n)` when one is. The OpenHuman tool adapters map `Unbounded` to "no `tokio::time::timeout` wrapper at all" and `Secs(n)` to a clamped deadline plus a small grace margin so the tool's own internal timeout (which actually kills the child) fires first. Sandbox backends, which require a finite deadline, substitute `SANDBOX_UNBOUNDED_CAP_SECS` (24h) for the unbounded case.+The global timeout governs non-scripting tools only, since a hung network or MCP call must stay bounded. The scripting tools (`shell`, `node_exec`, `npm_exec`, `python_exec`) instead run with no default deadline: a build, solver, or test run legitimately takes minutes and must not be hard-killed. They expose a per-call `timeout_secs` argument and resolve it through `explicit_call_timeout_secs`/`explicit_call_timeout_duration`: `None` runs unbounded, a positive value clamps to the tool's own ceiling. Sandbox backends, which require a finite deadline even when the caller asked for none, substitute `SANDBOX_UNBOUNDED_CAP_SECS` (24h) for the unbounded case.## Configuration-- `[agent].agent_timeout_secs` (config TOML) — integer seconds, valid range `1..=3600`, default `120`. Editable live via **Settings → Agent OS access → Action timeout** or the `config.update_agent_settings` RPC.-- `OPENHUMAN_TOOL_TIMEOUT_SECS` (env) — operator override with the same range. When valid it overrides the config value; an invalid value is ignored so the config value still applies.+- `[agent].agent_timeout_secs` (config TOML): integer seconds, valid range `1..=3600`, default `120`. Editable live via Settings, Agent OS access, Action timeout, or the `config.update_agent_settings` RPC.+- `OPENHUMAN_TOOL_TIMEOUT_SECS` (env): operator override with the same range. When valid it overrides the config value; an invalid value is ignored so the config value still applies.## Dependencies@@ -50,16 +52,16 @@ The global timeout governs **non-scripting** tools only — a hung network/MCP c## Used by-- `crates/openhuman-core/src/agent/tinyagents/tools.rs` — OpenHuman tools execute through `execute_with_options`, which applies each tool's [`Tool::timeout_policy`]: `Inherit` uses `tool_execution_timeout_secs()`; `Secs(n)` uses a clamped value plus grace; `Unbounded` runs with no deadline.-- `crates/openhuman-core/src/tools/impl/system/{shell,node_exec,npm_exec}.rs` — scripting tools: unbounded by default, explicit `timeout_secs` via `explicit_call_timeout_*`.-- `crates/openhuman-core/src/agent/tools/delegate.rs` — bounds the delegated provider chat call with `tool_execution_timeout_secs`.-- `crates/openhuman-core/src/config/ops.rs` — `apply_agent_settings` calls `set_tool_timeout_secs` after persisting; `get_agent_settings` reports `effective_timeout_secs` / `env_override`.-- `crates/openhuman-core/src/core/jsonrpc.rs` — `register_domain_subscribers` seeds the runtime value from config on the always-on core boot path (its ungated `INFRA: Once` block), so channel-less / web-chat-only cores get the configured timeout too (#5027).-- `crates/openhuman-core/src/agent/harness/harness_gap_tests.rs` — pins `parse_tool_timeout_secs` default/boundary behaviour.+- `crates/openhuman-core/src/agent/tinyagents/tools.rs`: OpenHuman tools execute through `execute_with_options`, which applies each tool's `Tool::timeout_policy` via `resolve_tool_deadline`.+- `crates/openhuman-core/src/tools/impl/system/{shell,node_exec,npm_exec,python_exec}.rs`: scripting tools, unbounded by default, explicit `timeout_secs` via `explicit_call_timeout_*`.+- `crates/openhuman-core/src/agent/tools/delegate.rs`: bounds the delegated provider chat call with `tool_execution_timeout_secs`.+- `crates/openhuman-core/src/config/ops/agent.rs`: `apply_agent_settings` calls `set_tool_timeout_secs` after persisting; `get_agent_settings` reports `effective_timeout_secs`/`env_override`.+- `crates/openhuman-core/src/core/jsonrpc.rs`: `register_domain_subscribers` seeds the runtime value from config on the always-on core boot path, so channel-less or web-chat-only cores get the configured timeout too (#5027).+- `crates/openhuman-core/src/agent/harness/harness_gap_tests.rs`: pins `parse_tool_timeout_secs` default and boundary behavior.-## Notes / gotchas+## Notes and gotchas-- The value is read fresh on every tool call, so a config change takes effect on the **next** tool call. A `tokio::time::timeout` already in flight keeps the deadline it captured.+- The value is read fresh on every tool call, so a config change takes effect on the next tool call. A `tokio::time::timeout` already in flight keeps the deadline it captured.- `0` is deliberately rejected (it would mean "disable timeout") and falls back to the default rather than disabling.-- A present-but-invalid env value (non-numeric / `0` / out of range) counts as "no override", so the config value still applies — only a valid env value overrides.+- A present-but-invalid env value (non-numeric, `0`, or out of range) counts as "no override", so the config value still applies. Only a valid env value overrides.- The default (`120`s) must stay in sync with any frontend timeout that mirrors it (`app/src/utils/config.ts` `TOOL_TIMEOUT_SECS`).