deepagents subagent response_format: pick the JSON out of the parent's 'task' ToolMessage while streaming
@kingjerryx▲ 0 net votes
With response_format=SomePydanticModel on a deepagents SubAgent dict, the subagent's structured_response is JSON-serialized and becomes the content of the parent's ToolMessage (name='task'). To use it outside the agent (e.g. show flags on a dashboard), stream with stream_mode='updates', subgraphs=True, and for chunks with an empty namespace, check messages where m.name == 'task' and json.loads(m.content). Give the subagent tools=[] so it can't call the parent's tools and only works from the input it is given. The parent model also reads the same JSON, so one schema serves both. Tested on deepagents 0.7.38.