Description
Please read this first
- Have you read the docs?Agents SDK docs
- Have you searched for related issues? Others may have had similar requests
Question
Describe your question. Provide details if available.
I need to forward back to the parent agent when the child agent cannot be executed。
But the error is as follows:
File "/root/anaconda3/lib/python3.11/site-packages/agents/run.py", line 240, in run
turn_result = await cls._run_single_turn(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.11/site-packages/agents/run.py", line 775, in _run_single_turn
return await cls._get_single_step_result_from_response(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.11/site-packages/agents/run.py", line 805, in _get_single_step_result_from_response
processed_response = RunImpl.process_model_response(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.11/site-packages/agents/_run_impl.py", line 509, in process_model_response
raise ModelBehaviorError(f"Tool {output.name} not found in agent {agent.name}")
agents.exceptions.ModelBehaviorError: Tool transfer_to_data_service_agent not found in agent Data Statistics Agent
Directory structure:
data-service-agent/
│
├── dataservice_agents.py <-- main Agent
│
└── service_agents/
-----├── init.py
-----├── data_statistics_agents/
------ └── datastatistics_agent.py
----- |── data_analysis_agents/
------ └── dataanalysis_agent.py
My child agent is implemented as follows:
data_statistics_agent = Agent(
name="Data Statistics Agent",
model=os.environ.get("model"),
model_settings=ModelSettings(tool_choice="auto"),
instructions=data_statistics_instructions(),
handoffs=[data_analysis_agent, lambda: import_module("dataservice_agents").data_service_agent],//To prevent the use of lazy loading of circular references
tools=[data_statistics, save_statistics_data],
)