Extracts the output_schema from an agent. For LlmAgent, returns its output_schema directly. For agents with sub_agents, recursively searches the last sub-agent for an output_schema. Args: agent: The agent to extract output_schema from. Returns: The output_schema if found, None o
(agent: BaseAgent)
| 80 | |
| 81 | |
| 82 | def _get_output_schema(agent: BaseAgent) -> Optional[SchemaType]: |
| 83 | """Extracts the output_schema from an agent. |
| 84 | |
| 85 | For LlmAgent, returns its output_schema directly. |
| 86 | For agents with sub_agents, recursively searches the last sub-agent for an |
| 87 | output_schema. |
| 88 | |
| 89 | Args: |
| 90 | agent: The agent to extract output_schema from. |
| 91 | |
| 92 | Returns: |
| 93 | The output_schema if found, None otherwise. |
| 94 | """ |
| 95 | from ..agents.llm_agent import LlmAgent |
| 96 | |
| 97 | if isinstance(agent, LlmAgent): |
| 98 | return agent.output_schema |
| 99 | |
| 100 | # For composite agents, check the last sub-agent |
| 101 | if agent.sub_agents: |
| 102 | return _get_output_schema(agent.sub_agents[-1]) |
| 103 | |
| 104 | return None |
| 105 | |
| 106 | |
| 107 | class AgentTool(BaseTool): |
no outgoing calls
no test coverage detected