Skip to content

How to implement handoff between parents and children agents in different paths #764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Monkey-Moon opened this issue May 27, 2025 · 1 comment
Labels
question Question about using the SDK stale

Comments

@Monkey-Moon
Copy link

Monkey-Moon commented May 27, 2025

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],
)

@Monkey-Moon Monkey-Moon added the question Question about using the SDK label May 27, 2025
Copy link

github-actions bot commented Jun 4, 2025

This issue is stale because it has been open for 7 days with no activity.

@github-actions github-actions bot added the stale label Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about using the SDK stale
Projects
None yet
Development

No branches or pull requests

1 participant