I want to exclude file system middleware (system prompt file system prompt + registered tools)
I know I can do this using profiles, but I want to do this for some subagent not all the agents that use the same provider
I know about tool exclusion middleware but this just removes the tool not file system prompt added to the system prompt
hi @bassuniz
have you checked the doc there Customize Deep Agents - Docs by LangChain ?
from what I see in the source code:
FilesystemMiddlewareis in_REQUIRED_MIDDLEWARE(deepagents/graph.py), soHarnessProfile.excluded_middlewarecannot drop it -_validate_excluded_middleware_configraisesValueErroron attempts- Profiles are resolved by
provider:model(_harness_profile_for_model), never by subagent name, so a profile-level change is global per provider _ToolExclusionMiddlewareonly filtersrequest.tools;FilesystemMiddleware.wrap_model_callindependently appends the file-system prose torequest.system_message- they’re orthogonal.- The
middlewarefield on the declarativeSubAgentis appended to the hard-coded base stack, not a replacement
Swap the affected subagent from declarative SubAgent to CompiledSubAgent. In graph.py, the if "runnable" in spec: inline_subagents.append(spec) branch skips all base-stack injection, profile resolution, and permission inheritance - you get exactly the stack you build with create_agent(...). Same model, no provider collision.
If the subagent still needs file tools but not the prompt, instantiate FilesystemMiddleware(backend=..., system_prompt=""). The wrap_model_call short-circuits on a falsy system_prompt, so the tools are still injected but the prose is suppressed.
Great thanks for the reply