{"record":{"id":"4dade81dd27e69e7","repo":"tinyhumansai/openhuman","slug":"agentdefinitionregistry-not-initialised","errorCode":null,"errorMessage":"AgentDefinitionRegistry not initialised","messagePattern":"AgentDefinitionRegistry not initialised","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/openhuman/agent/orchestration/tools/spawn_worker_thread.rs","lineNumber":190,"sourceCode":"            let is_delegated_label = current_thread\n                .labels\n                .iter()\n                .any(|label| label == \"tasks\" || label == \"worker\" || label == \"agent-task\");\n            if is_delegated_label || current_thread.parent_thread_id.is_some() {\n                tracing::warn!(\n                    agent_id = %agent_id,\n                    current_thread_id = %current_thread_id,\n                    is_delegated_label,\n                    has_parent_thread_id = current_thread.parent_thread_id.is_some(),\n                    elapsed_ms = started.elapsed().as_millis() as u64,\n                    \"[spawn_worker_thread] depth guard blocked spawn from worker thread\"\n                );\n                return Ok(ToolResult::error(\"Worker threads cannot spawn other worker threads. Depth is capped at 1. Use spawn_subagent for inline delegation instead.\"));\n            }\n        }\n\n        let registry = AgentDefinitionRegistry::global()\n            .ok_or_else(|| anyhow::anyhow!(\"AgentDefinitionRegistry not initialised\"))?;\n\n        let definition = registry\n            .get(&agent_id)\n            .ok_or_else(|| anyhow::anyhow!(\"agent_id '{}' not found\", agent_id))?;\n\n        if !parent.allowed_subagent_ids.contains(&definition.id) {\n            tracing::warn!(\n                parent_agent = %parent.agent_definition_id,\n                requested_agent = %definition.id,\n                allowed = ?parent.allowed_subagent_ids,\n                \"[spawn_worker_thread] blocked subagent outside parent allowlist\"\n            );\n            return Ok(ToolResult::error(format!(\n                \"spawn_worker_thread: agent '{}' is not in parent agent '{}' subagents.allowlist\",\n                definition.id, parent.agent_definition_id\n            )));\n        }\n","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/agent/orchestration/tools/spawn_worker_thread.rs#L172-L208","documentation":"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.","triggerScenarios":"Thrown at src/openhuman/agent/orchestration/tools/spawn_worker_thread.rs:190 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the agent turn is started through the harness path that packs the registry handle into the tool context","In tests, inject a registry via the same extension mechanism instead of calling the tool bare","Check for code paths that construct the tool context without the registry after refactors"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}