OpenAI agents sdk - Handoffs can't iterate, am I right?

Let’s suppose I have 3 agents:

  • Email
  • Calendar
  • Orchestrator(handoffs=[Email, Calendar])

If I ask the orchestrator: “what are my latest emails and events of today?”.
The orchestrator will handoff the response to another agent (one of the two) and the answer will come just from one of the two, the question can’t be answered by both agents and then re-assembled and interpreted by the orchestrator.

So basically the answer will just be from the appropriate Agent. Cool behavior, but how would you implement the handoff in such a way that the agent would be able to answer a question which would require two different handoffs and an “aggregator”?

I mean, if I have to implement it by myself I’m missing the point of having a library dedicated to agents, am I missing something? Maybe there’s a parameter or something I’m doing wrong?

Thanks!

Maybe this answers youre question

assuming you have 2 tools:

@function_tool
async def get_emails_for_date(date: str) -> list:
@function_tool
async def get_appointments_for_date(date: str) -> list:

You can add both tools to an orchestrater and provide the model setting parallel_tool_calls (found in Issue 256 of openai-agents-python) like this:

orchestrator_agent = Agent(
    name="Orchestrater",
    instructions="Useful assistant",
    tools=[get_appointments_for_date, get_emails_for_date],
    model_settings=ModelSettings(parallel_tool_calls=True),
)

And by this both functions are getting called to answer the question.

Let me know if this helped.

Thanks @ah73,

what you suggest is a standard tool call which works fine up to a certain number of tools, if I want to have specific agents specialized on certain tasks the only way to proceed is to use handoffs.

I actually found a solution which is to use agents as tools as described here: Understanding Handoffs vs. Agents-as-Tools in OpenAI's Agents SDK

I think this is the perfect solution to my problem and I actually find this very helpful.

You basically pass an agent as tool to the main “orchestrator” agent