Open
Description
Describe the feature
I want to access intermediate results when MaxTurnExceededException
is thrown.
I have a workflow broken into 2 phases.
Phase 1 is investigation.
Phase 2 is writing up a report based on the investigation results.
I'm feeding the results of phase 1 into phase 2 like so:
result = Runner.run(investigation_agent, max_turns=5)
report = Runner.run(report_agent, result.to_input_list())
I want to limit the number of turns in Phase 1.
If a MaxTurnExceededException
is thrown in Phase 1, I still want to make use of the available information in Phase 2.
Currently this doesn't seem possible to do. I have no way to access the intermediate results (tool calls, etc.) if I reach max turns in Phase 1.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
rm-openai commentedon May 20, 2025
Yes we should indeed do this. Will try to get to it soon - as always, PR welcome from anyone
DanieleMorotti commentedon May 20, 2025
I can have a look if @chiehmin-wei is not already working on it. How would you return / save the partial results?
In the
Runner
object?rm-openai commentedon May 21, 2025
I think partial results are already built up in Runner, as you described; when the exception is raised, you can add a RunErrorDetails object with all that data
DanieleMorotti commentedon May 22, 2025
Okay, so I have to create a new class
RunErrorDetails
and then pass the data in theMaxTurnsExceeded
exception? Obviously adding this optional attribute to the exceptionrm-openai commentedon May 22, 2025
yup!
Added RunErrorDetails object for MaxTurnsExceeded exception (#743)
Added RunErrorDetails object for MaxTurnsExceeded exception (openai#743)