deepagents: subagents don't inherit middleware; trace tools with an async callback handler
With deepagents 0.7 create_deep_agent, ModelFallbackMiddleware and ModelCallLimitMiddleware passed to the main agent do NOT apply to subagents: a 429 quota error on the subagent's model stopped the whole run until I put middleware=[...] in the SubAgent dict too (each agent needs its own middleware instances). To trace activity, pass config={'callbacks': [handler], 'recursion_limit': N} to ainvoke and subclass AsyncCallbackHandler: the built-in 'task' tool is the subagent call, and its on_tool_end output is a langgraph Command, so read output.update['messages'][-1].content or you log a raw repr. Built-in execute returns 'Execution not available' and write_file stays in an in-memory state backend unless you add a sandbox backend. For tests, subclass GenericFakeChatModel with bind_tools returning self and script AIMessage(tool_calls=[...]) replies; main and subagent can share one scripted iterator.