Problem Accessing 2 Outputs in a Single Turn

Hi!

I’ve hit a brick wall to capture 2 outputs from a single turn (Message, and Function call to handoff to another agent) - OpenAI Agents SDK

Tried accessing the outputs through Agent Lifecycle but can’t seem to catch it. With the current handoff architecture of the project, only on_start and on_handoff is working since there’s an immediate function call (transfer_to_triage_agent) right after the agent outputs it’s message.

Agent’s current output:

  1. Assistant Message that is needed to be stored in the context.
  2. tool call for handoff (transfer_to_triage_agent)

The problem here is that the tool call overwrites the first output, and the assistant message is now missing leading to not appearing in the UI.

How can I catch/store the assistant message to the context without interfering the handoff?

hm, have you tried printing/logging both msgs?

yes, the only present in the output is the tool_call no assistant message present

Here’s a sample output from my trace, the entire workflow is working fine, but I can’t seem to find a way to access the first output which is the goodbye message

i do like the whole idea around whatever you are building. unfortunally, it is hard to debug this without asking for internal information. if i had to guess, it is probably something very simple, like you are missing a -1 or a +1 in a for/while loop

sometimes taking a break helps, I think its called the Zeigarnik Effect, like you might be taking a shower and then you figure out what you were getting it wrong… maybe do a search of topics in the community and see if there were others with the same issue that solved it