Skip to content

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

fix(subagent): warn only when the allowlist readmitted a spawn tool\n\n`assemble_turn_harness` computed `spawn_stripped` and logged the refusal\nbefore consulting `admitted`, so it announced a refusal that was never in\ndoubt: `run_typed_mode` strips spawn/delegate tools out of\n`allowed_indices` first, and `allowed_names` is built from that stripped\nlist, so `spawn_stripped` was only ever true where `admitted` was already\nfalse. Every healthy sub-agent run therefore emitted one WRN per static\nspawn/delegate tool on the parent's surface, carrying no signal, while\nthe case the backstop exists for -- an allowlist that readmitted one --\nlooked identical in the log.\n\nGate the warn on `admitted`. No behavioural change: the tool was not\nregistered before and is not registered now. The already-excluded names\nare still visible at debug level via the existing\n"removed sub-agent spawn tools from sub-agent's tool surface" line in\n`run_typed_mode`, so nothing is lost by not re-logging them per tool.\n\nAlso correct `is_subagent_spawn_or_delegate_tool`'s doc comment, which\nclaimed to mirror `tool_prep::is_subagent_spawn_tool`. It does not: the\nprimary predicate resolves each archetype's `delegate_name` override\nthrough the registry (`plan`, `run_code`, `research`, ...), while this\ncopy matches only the `delegate_` prefix, so the backstop catches\nstrictly less than the thing it backstops. Say so, and say why widening\nit here is the caller's job rather than a registry lookup on the\nper-tool registration loop.\n

Shanu8b366e94439b
diff --git a/src/openhuman/agent/tinyagents/mod_part_01.rs b/src/openhuman/agent/tinyagents/mod_part_01.rs
index eea9879246..a6e7725a62 100644
--- a/src/openhuman/agent/tinyagents/mod_part_01.rs
+++ b/src/openhuman/agent/tinyagents/mod_part_01.rs
@@ -534,12 +534,22 @@ pub(crate) async fn run_turn_via_tinyagents(
/// name the tools that pause the loop (e.g. `ask_user_clarification`) and surface
/// the question via [`TinyagentsTurnOutcome::early_exit_tool`].
/// True when `name` is a sub-agent spawn/delegation tool that a **child** run
-/// must never be able to invoke (issue #4452). Mirrors the caller-side strip in
-/// `subagent_runner::tool_prep::is_subagent_spawn_tool` plus the worker-thread
-/// spawn, re-asserted at registration as defense-in-depth so a misconfigured
-/// allowlist cannot reintroduce sub-agent spawning into a nested run. Kept local
-/// to this seam (rather than importing the `pub(super)` runner helper) so the
-/// invariant travels with the registration site that enforces it.
+/// must never be able to invoke (issue #4452), re-asserted at registration as
+/// defense-in-depth so a misconfigured allowlist cannot reintroduce sub-agent
+/// spawning into a nested run. Kept local to this seam (rather than importing
+/// the `pub(super)` runner helper) so the invariant travels with the
+/// registration site that enforces it.
+///
+/// **This is a strict subset of the caller-side strip**, not a mirror of it
+/// (issue #6157). `subagent_runner::tool_prep::is_subagent_spawn_tool` also
+/// resolves each archetype's `delegate_name` override through the definition
+/// registry — `plan`, `research`, `run_code`, `review_code`, … — none of which
+/// carry the `delegate_` prefix this match relies on. Matching them here would
+/// put a registry lookup on the per-tool registration loop, so the caller
+/// stays responsible for the override names: every path that feeds `allowed`
+/// runs `is_subagent_spawn_tool` first, including the dynamic per-spawn tools
+/// (`subagent_runner::ops::runner`). Widen this predicate in lockstep if that
+/// ever stops being true.
fn is_subagent_spawn_or_delegate_tool(name: &str) -> bool {
name == "spawn_subagent"
|| name.starts_with("delegate_")
diff --git a/src/openhuman/agent/tinyagents/mod_part_04.rs b/src/openhuman/agent/tinyagents/mod_part_04.rs
index 4456d54895..bb8125da6d 100644
--- a/src/openhuman/agent/tinyagents/mod_part_04.rs
+++ b/src/openhuman/agent/tinyagents/mod_part_04.rs
@@ -253,12 +253,12 @@ fn assemble_turn_harness(
Some(set) => set.contains(name),
};
// Defense-in-depth (issue #4452): a sub-agent must NEVER be handed a
- // spawn/delegate tool, regardless of what the resolved allowlist contains.
- // Re-assert the invariant here at registration time (not just on the
- // caller's `allowed_indices`) so a misbuilt allowlist can't reintroduce
- // `spawn_subagent`/`delegate_*`/worker-thread spawning into a child run.
+ // spawn/delegate tool whatever the allowlist says — re-assert it here at
+ // registration, not just on the caller's `allowed_indices`. Warn only when
+ // the allowlist actually readmitted one (issue #6157); the caller strips
+ // them first, so a bare `spawn_stripped` warn fired on every healthy run.
let spawn_stripped = is_subagent_run && is_subagent_spawn_or_delegate_tool(name);
- if spawn_stripped {
+ if spawn_stripped && admitted {
tracing::warn!(
tool = name,
"[subagent] refusing to register spawn/delegate tool on sub-agent run"