FileSystem middleware

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:

  • FilesystemMiddleware is in _REQUIRED_MIDDLEWARE (deepagents/graph.py), so HarnessProfile.excluded_middleware cannot drop it - _validate_excluded_middleware_config raises ValueError on attempts
  • Profiles are resolved by provider:model (_harness_profile_for_model), never by subagent name, so a profile-level change is global per provider
  • _ToolExclusionMiddleware only filters request.tools; FilesystemMiddleware.wrap_model_call independently appends the file-system prose to request.system_message - they’re orthogonal.
  • The middleware field on the declarative SubAgent is 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