langchain-ai/deepagents · error · RuntimeError
task() requires an active ToolRuntime
Error message
task() requires an active ToolRuntime
What it means
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.
Source
Thrown at libs/partners/quickjs/langchain_quickjs/_repl.py:589
self,
payload: dict[str, Any],
*,
state: _PTCState,
) -> Any:
"""Validate JS `task()` input and invoke the runner on the right loop.
The QuickJS host call runs on the REPL worker loop, but subagent runnables
should execute on the parent LangGraph loop when one exists so callbacks,
context, and async loop affinity match normal tool execution.
"""
validated = self._validate_task_payload(payload)
description, subagent_type, label, response_schema = validated
async def _call() -> Any:
runtime = state.outer_runtime
if runtime is None:
msg = "task() requires an active ToolRuntime"
raise RuntimeError(msg)
task_tool = find_subagent_task_tool(getattr(runtime, "tools", ()) or ())
if task_tool is None:
msg = "task tool not configured for this eval"
raise RuntimeError(msg)
return await call_subagent_task_tool(
task_tool,
description=description,
subagent_type=subagent_type,
response_schema=response_schema,
runtime=runtime,
label=label,
)
outer_loop = state.outer_loop
if outer_loop is None:
return await _call()
current_loop = asyncio.get_running_loop()
if current_loop is outer_loop:View on GitHub (pinned to a1af029e6e)
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()
Defensive patterns
Strategy: try-catch
Validate before calling
# Python side, before running eval
if ptc_state.outer_runtime is None:
raise SetupError('eval requires an active ToolRuntime for task()') Type guard
def has_outer_runtime(state) -> bool:
return getattr(state, 'outer_runtime', None) is not None Try / catch
try:
result = await task(payload)
except (RuntimeError,) as e:
if 'ToolRuntime' in str(e):
log.warning('task() unavailable: no ToolRuntime wired');
return None
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- task() requires non-empty string field `description`
- task() requires non-empty string field `subagentType`
- task() field `label` must be a string when provided
- task() field `responseSchema` must be an object when provide
- task tool not configured for this eval
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/ad91cd7996646875.
Report an issue: GitHub.