# Ephemeral Subagent Task - Deep Agent

**URL:** <https://forum.langchain.com/t/ephemeral-subagent-task-deep-agent/4518>\
**Category:** LangGraph\
**Tags:** python-help\
**Created:** [September 10, 2026, 12:05pm UTC](https://forum.langchain.com/t/ephemeral-subagent-task-deep-agent/4518 "2026-09-10T12:05:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ipatchcables](https://avatars.discourse-cdn.com/v4/letter/i/c2a13f/32.png) [@ipatchcables](https://forum.langchain.com/u/ipatchcables)\
**Post date:** [September 10, 2026, 12:05pm UTC](https://forum.langchain.com/t/ephemeral-subagent-task-deep-agent/4518/1 "2026-09-10T12:05:39Z")

</div>

Random task executes a dynamic subagent? AFAIK, this shouldn’t happen if you aren’t using CodeInterpreterMiddleware

Really curious about this.

? [Dynamic subagents - Docs by LangChain](https://docs.langchain.com/oss/python/deepagents/dynamic-subagents)

---

<div class="post-metadata">

**Author:** ![pawel-twardziak](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/pawel-twardziak/32/960_2.png) [@pawel-twardziak](https://forum.langchain.com/u/pawel-twardziak)\
**Post date:** [September 10, 2026, 12:43pm UTC](https://forum.langchain.com/t/ephemeral-subagent-task-deep-agent/4518/2 "2026-09-10T12:43:47Z")

</div>

hi @ipatchcables

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](https://docs.langchain.com/oss/python/deepagents/subagents#running-without-subagents) and [Dynamic subagents - Docs by LangChain](https://docs.langchain.com/oss/python/deepagents/dynamic-subagents)

---

<div class="post-metadata">

**Author:** ![ipatchcables](https://avatars.discourse-cdn.com/v4/letter/i/c2a13f/32.png) [@ipatchcables](https://forum.langchain.com/u/ipatchcables)\
**Post date:** [September 10, 2026, 1:55pm UTC](https://forum.langchain.com/t/ephemeral-subagent-task-deep-agent/4518/3 "2026-09-10T13:55:06Z")

</div>

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.
