DeepAgent: sub-agents are just tools
agent_as_tool() wraps a shared_ptr<Agent> in a
DynamicTool with a JSON schema, so delegation needs no new concept and
no depth limit. Each sub-agent can run a different model from a different provider.
A tool that throws never takes down the loop: the exception comes back as a
tool_result the model reads and recovers from, and truncated tool
arguments get the same treatment instead of an exception out of the JSON parser.
The tree from the README's DeepAgent snippet: three agents, two
providers, one run(). Working versions in
examples/06_deep_agent.cpp and 16_deep_agent_custom.cpp.