tinyhumansai/openhuman · error

AgentDefinitionRegistry not initialised

Error message

AgentDefinitionRegistry not initialised

What it means

The tool's stored AgentDefinitionRegistry handle (packed via the host_extension mechanism) is absent when spawn_worker_thread runs. The registry is injected at turn setup; its absence means the tool executed outside a properly initialized harness (unit tests, direct invocation, or a harness path that skipped registry injection), so agent definitions cannot be resolved.

Source

Thrown at src/openhuman/agent/orchestration/tools/spawn_worker_thread.rs:190

            let is_delegated_label = current_thread
                .labels
                .iter()
                .any(|label| label == "tasks" || label == "worker" || label == "agent-task");
            if is_delegated_label || current_thread.parent_thread_id.is_some() {
                tracing::warn!(
                    agent_id = %agent_id,
                    current_thread_id = %current_thread_id,
                    is_delegated_label,
                    has_parent_thread_id = current_thread.parent_thread_id.is_some(),
                    elapsed_ms = started.elapsed().as_millis() as u64,
                    "[spawn_worker_thread] depth guard blocked spawn from worker thread"
                );
                return Ok(ToolResult::error("Worker threads cannot spawn other worker threads. Depth is capped at 1. Use spawn_subagent for inline delegation instead."));
            }
        }

        let registry = AgentDefinitionRegistry::global()
            .ok_or_else(|| anyhow::anyhow!("AgentDefinitionRegistry not initialised"))?;

        let definition = registry
            .get(&agent_id)
            .ok_or_else(|| anyhow::anyhow!("agent_id '{}' not found", agent_id))?;

        if !parent.allowed_subagent_ids.contains(&definition.id) {
            tracing::warn!(
                parent_agent = %parent.agent_definition_id,
                requested_agent = %definition.id,
                allowed = ?parent.allowed_subagent_ids,
                "[spawn_worker_thread] blocked subagent outside parent allowlist"
            );
            return Ok(ToolResult::error(format!(
                "spawn_worker_thread: agent '{}' is not in parent agent '{}' subagents.allowlist",
                definition.id, parent.agent_definition_id
            )));
        }

View on GitHub (pinned to 7491200858)

Solutions

  1. Ensure the agent turn is started through the harness path that packs the registry handle into the tool context
  2. In tests, inject a registry via the same extension mechanism instead of calling the tool bare
  3. Check for code paths that construct the tool context without the registry after refactors
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/openhuman/agent/orchestration/tools/spawn_worker_thread.rs:190 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/4dade81dd27e69e7. Report an issue: GitHub.