extra_middleware: Sequence[AgentMiddleware] | Callable[[], Sequence[AgentMiddleware]] = ()Middleware appended to every runtime middleware stack.
Applied to the main agent, the auto-added general-purpose subagent, and
declarative synchronous subagents created from SubAgent specs —
i.e., the stacks that create_deep_agent assembles itself.
Not applied to CompiledSubAgent runnables or AsyncSubAgent entries.
A CompiledSubAgent is passed in pre-built (its runnable is already a
compiled graph with its own middleware chain), so create_deep_agent has
nothing to append to. An AsyncSubAgent runs out-of-process against a
remote deployment and its middleware is configured on that remote graph,
not here. In both cases, injecting local middleware would either fail
silently or violate the caller's explicit configuration.
May be a static sequence or a zero-arg factory that returns one. Use a
factory when middleware instances should not be shared across stacks. This
field is runtime-only and intentionally absent from HarnessProfileConfig.