Random task executes a dynamic subagent? AFAIK, this shouldn’t happen if you aren’t using CodeInterpreterMiddleware
Really curious about this.
Random task executes a dynamic subagent? AFAIK, this shouldn’t happen if you aren’t using CodeInterpreterMiddleware
Really curious about this.
Nothing dynamic ran there. What you are seeing is the regular task tool that every create_deep_agent(...) gets by default, and its built-in description literally starts with “Launch an ephemeral subagent to handle a complex, multi-step task.” That wording has been in deepagents/middleware/subagents.py (TASK_TOOL_DESCRIPTION) since the monorepo migration in Nov 2025, long before dynamic subagents existed. “Ephemeral” just means stateless and one-shot, not created at runtime.
Why it fired on a “random” task: create_deep_agent auto-adds a general-purpose subagent and SubAgentMiddleware unless you disable it (graph.py), and the tool description tells the model to use general-purpose “for any complex, context-heavy task”. So the model can decide on its own to delegate. It cannot invent subagents though - an unknown subagent_type just returns “We cannot invoke subagent X because it does not exist” and the set of types is fixed at build time.
Your understanding is correct: dynamic subagents require CodeInterpreterMiddleware. In langchain_quickjs/middleware.py the JS task() global is only injected when the interpreter is present with subagents=True and a task tool exists in the tool list - and even then it is just a bridge to the same static task tool. create_deep_agent never adds the interpreter by itself and deepagents-code defaults enable_interpreter=False. Quick check in the trace: a dynamic dispatch shows up as a call to the interpreter tool (default name eval) with JS containing task({...}), while what you saw is a direct task tool call with description and subagent_type.
If you want to stop this: register a harness profile with general_purpose_subagent=GeneralPurposeSubagentProfile(enabled=False) and pass no subagents= (then SubAgentMiddleware and the task tool are not added at all - don’t use excluded_middleware, it raises), or tighten the wording via tool_description_overrides={"task": "... {available_agents}"} on the profile. Docs: Subagents - Docs by LangChain and Dynamic subagents - Docs by LangChain
I’m good! I hadn’t seen it before until recent and thought maybe I added some dynamic agent. I did grep the code before I posted and found the same thing. Thanks for the reply.