CompiledSubAgent()A custom agent implementation.
Create a custom agent using either:
create_agent()langgraphIf you're creating a custom graph, make sure the state schema includes a 'messages' key. This is required for the subagent to communicate results back to the main agent.
A pre-compiled agent spec.
The runnable's state schema must include a 'messages' key.
This is required for the subagent to communicate results back to the main agent.
When the subagent completes, the parent reads the returned state:
if structured_response is non-None, it is JSON-serialized and used as
the ToolMessage content; otherwise, the last non-empty AIMessage
text is used.