{"record":{"id":"ad91cd7996646875","repo":"langchain-ai/deepagents","slug":"task-requires-an-active-toolruntime","errorCode":null,"errorMessage":"task() requires an active ToolRuntime","messagePattern":"task\\(\\) requires an active ToolRuntime","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"libs/partners/quickjs/langchain_quickjs/_repl.py","lineNumber":589,"sourceCode":"        self,\n        payload: dict[str, Any],\n        *,\n        state: _PTCState,\n    ) -> Any:\n        \"\"\"Validate JS `task()` input and invoke the runner on the right loop.\n\n        The QuickJS host call runs on the REPL worker loop, but subagent runnables\n        should execute on the parent LangGraph loop when one exists so callbacks,\n        context, and async loop affinity match normal tool execution.\n        \"\"\"\n        validated = self._validate_task_payload(payload)\n        description, subagent_type, label, response_schema = validated\n\n        async def _call() -> Any:\n            runtime = state.outer_runtime\n            if runtime is None:\n                msg = \"task() requires an active ToolRuntime\"\n                raise RuntimeError(msg)\n            task_tool = find_subagent_task_tool(getattr(runtime, \"tools\", ()) or ())\n            if task_tool is None:\n                msg = \"task tool not configured for this eval\"\n                raise RuntimeError(msg)\n            return await call_subagent_task_tool(\n                task_tool,\n                description=description,\n                subagent_type=subagent_type,\n                response_schema=response_schema,\n                runtime=runtime,\n                label=label,\n            )\n\n        outer_loop = state.outer_loop\n        if outer_loop is None:\n            return await _call()\n        current_loop = asyncio.get_running_loop()\n        if current_loop is outer_loop:","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/partners/quickjs/langchain_quickjs/_repl.py#L571-L607","documentation":"The task bridge's `_call` raises this RuntimeError when the captured PTC state has no `outer_runtime`. The outer ToolRuntime is what carries the configured tools, including the subagent task tool; without it the library cannot dispatch the subagent at all. This is an integration/configuration problem, not a JS payload problem.","triggerScenarios":"JS calls `task()` during an eval where `_PTCState.outer_runtime` is None — the REPL was invoked outside a normal agent run that provides a ToolRuntime, or the runtime was not attached when the eval started.","commonSituations":"Running quickjs evals in a standalone harness that skips the ToolRuntime wiring, calling `task()` from an eval launched outside an agent invocation, or a version change in how the outer runtime is injected.","solutions":["Run the eval within a proper agent invocation so a ToolRuntime is active","Verify the eval entry point passes the outer runtime into the PTC state","If task() should be unavailable, disable subagents for the REPL instead of letting JS call task()"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# Python side, before running eval\nif ptc_state.outer_runtime is None:\n    raise SetupError('eval requires an active ToolRuntime for task()')","typeGuard":"def has_outer_runtime(state) -> bool:\n    return getattr(state, 'outer_runtime', None) is not None","tryCatchPattern":"try:\n    result = await task(payload)\nexcept (RuntimeError,) as e:\n    if 'ToolRuntime' in str(e):\n        log.warning('task() unavailable: no ToolRuntime wired');\n        return None\n    raise","preventionTips":["Only enable subagents when running under a full agent invocation","Assert outer_runtime presence in eval harness setup","Keep runtime injection wiring up to date across library upgrades"],"tags":["quickjs","task-bridge","missing-runtime"],"backgroundTag":"missing-tool-runtime","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}