Hmbown/CodeWhale · error · anyhow::Error

Tool is not active for this sub-agent

Error message

Tool {name} is not active for this sub-agent

What it means

The sub-agent tool dispatcher checks every requested tool name against `request_active_names`, the set of tools activated for this specific sub-agent request. Deferred tools may be hydrated lazily, but once hydration is not applicable, calling a tool that is not in the active set is rejected. This enforces the tool allowlist the parent configured for the sub-agent.

Solutions

  1. Add the tool name to the sub-agent's allowed_tools list in the parent configuration
  2. Pick a different tool that is active for this sub-agent
  3. If the tool should be deferred, request it through the hydration path once instead of executing directly

Example fix

// before
spawn_subagent(role: "researcher", allowed_tools: ["web_search"])
subagent.call("fetch_url", ...)
// after
spawn_subagent(role: "researcher", allowed_tools: ["web_search", "fetch_url"])
Defensive patterns

Strategy: validation

Validate before calling

const active = new Set(requestActiveNames);
if (!active.has(toolName)) throw new Error(`Tool ${toolName} not active for sub-agent`);
await subagent.call(toolName, input);

Type guard

const isActiveTool = (name, activeNames) => activeNames.includes(name);

Prevention

When it happens

Trigger: A sub-agent (or the model driving it) invokes a tool whose name is not in the allowed/active tool list for that sub-agent request, and the tool is not a deferred tool eligible for hydration (`deferred` false, or deferred but already consumed).

Common situations: Parent passes an `allowed_tools` list that omits a tool the sub-agent's prompt tells it to use; a custom role's tool list is stale after a rename; deferred tool hydration was already returned once so the second call falls through to the active-name check.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/9e472b73f8e6f204. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/tools/subagent/mod.rs:18139

        }

        let Some(deferred) = surface
            .catalog
            .iter()
            .find(|tool| tool.name == name)
            .map(|tool| tool.defer_loading.unwrap_or(false))
        else {
            return Err(anyhow!(
                "Tool {name} is not in this child's policy-filtered catalog"
            ));
        };
        if deferred && !request_active_names.contains(name) {
            return surface
                .hydrate(name)
                .map(|content| RichToolResult::plain(ToolResult::success(content)));
        }
        if !request_active_names.contains(name) {
            return Err(anyhow!("Tool {name} is not active for this sub-agent"));
        }
        let result = self.execute_full(agent_id, tool_id, name, input).await;
        if deferred && result.is_ok() {
            touch_cached_tool_after_execution(
                &surface.catalog,
                &mut surface.active_names,
                &mut surface.cache,
                name,
            );
        }
        result
    }
}

/// A child admission refusal is a typed permission denial, not an opaque
/// execution error — the worker loop's no-progress guard (#6015) can only
/// count denials it can name.
/// Whether `name` is a desktop / computer-control surface.

View on GitHub (pinned to 73e0f67d83)