#6401·deepagents

quickjs: JS `task()` subagent dispatch runs without the parent run's callbacks

Author: radu-mocanuCreated Sep 18, 2026Updated Sep 26, 2026
Labelstype:bugtopic:subagentsorg:externalpriority:backlogintegration:quickjstopic:tracingtopic:code-interpreter

Submission checklist

  • This is a bug, not a usage question.
  • I added a clear and descriptive title.
  • I searched existing issues and didn't find this.
  • I can reproduce this with the latest released version.
  • I included a minimal reproducible example and steps to reproduce.

Area (Required)

  • deepagents (SDK)
  • dcode
  • talon
  • acp
  • evals
  • daytona
  • modal
  • quickjs
  • runloop
  • vercel
  • langsmith-sandbox
  • Other / not sure / general

Related Issues / PRs

No response

Reproduction Steps / Example Code (Python)

python
import asyncio

from deepagents import create_deep_agent
from langchain_core.callbacks import BaseCallbackHandler
from langchain_core.language_models.fake_chat_models import GenericFakeChatModel
from langchain_core.messages import AIMessage, HumanMessage
from langchain_quickjs import CodeInterpreterMiddleware


class Recorder(BaseCallbackHandler):
    """Records what a tracer attached to the agent run would see."""

    def __init__(self):
        self.events = []

    def on_tool_start(self, serialized, input_str, **kwargs):
        self.events.append(f"tool_start:{serialized['name']}")

    def on_chat_model_start(self, serialized, messages, **kwargs):
        self.events.append(f"chat_model_start:{serialized.get('name')}")


class ScriptedModel(GenericFakeChatModel):
    """Replays scripted turns so the run is deterministic and offline."""

    def bind_tools(self, tools, **kwargs):
        return self


class MainModel(ScriptedModel):
    pass


class WorkerModel(ScriptedModel):
    pass


def build_agent(first_turn: AIMessage):
    main_model = MainModel(messages=iter([first_turn, AIMessage(content="done")]))
    worker_model = WorkerModel(messages=iter([AIMessage(content="ok")]))
    return create_deep_agent(
        model=main_model,
        middleware=[CodeInterpreterMiddleware()],
        subagents=[
            {
                "name": "worker",
                "description": "Does one unit of work.",
                "system_prompt": "Reply with ok.",
                "model": worker_model,
            }
        ],
    )


async def run(label: str, first_turn: AIMessage):
    recorder = Recorder()
    agent = build_agent(first_turn)
    await agent.ainvoke(
        {"messages": [HumanMessage(content="go")]},
        config={"callbacks": [recorder]},
    )
    print(f"{label}: {recorder.events}")


async def main():
    await run(
        "model calls `task` tool directly",
        AIMessage(
            content="",
            tool_calls=[
                {
                    "id": "call_1",
                    "name": "task",
                    "args": {"description": "work", "subagent_type": "worker"},
                }
            ],
        ),
    )
    await run(
        "model calls `eval`, JS calls task()",
        AIMessage(
            content="",
            tool_calls=[
                {
                    "id": "call_2",
                    "name": "eval",
                    "args": {
                        "code": "await task({description: 'work', subagentType: 'worker'})"
                    },
                }
            ],
        ),
    )


asyncio.run(main())

Error Message and Stack Trace (if applicable)

bash
No exception. Output on langchain-quickjs 0.3.7:

model calls `task` tool directly: ['chat_model_start:MainModel', 'tool_start:task', 'chat_model_start:WorkerModel', 'chat_model_start:MainModel']
model calls `eval`, JS calls task(): ['chat_model_start:MainModel', 'tool_start:eval', 'chat_model_start:MainModel']

Description

When the model calls the task tool directly, the parent run's callback handlers receive on_tool_start for the tool and then every run inside the subagent graph. When the same subagent is dispatched from JavaScript inside the eval REPL via the task() global, the handlers receive nothing: no tool start for the dispatch, and none of the subagent's chain, model, or tool runs.

Impact: any tracer or streaming handler attached to the parent run (LangSmith, OpenTelemetry-based tracers, custom handlers) has a blind spot for every subagent launched from JS. In a fan-out, this can be dozens of LLM calls per eval that are invisible to observability and to anything that keys billing or span parenting off the callback run tree. Nested tool calls made by those subagents are also invisible.

Fix: pass the outer runtime's callbacks to task_tool.arun, mirroring the PTC tool bridge.

Environment / System Info

OS: macOS 26.5.2 (Darwin 25.5.0), arm64 Python: 3.12.13 deepagents: 0.7.13 langchain-quickjs: 0.3.7 quickjs-rs: 0.2.5 langchain: 1.4.0 langchain-core: 1.6.2 langgraph: 1.2.11