Skip to main content
With flush_in_flight_messages_on_error (in agent/_run.py), the agent’s outer except block flushes the in-flight run_messages into run_response.messages before persisting. The conversation that led to the failure is preserved.
tool_error_persistence.py

Run the Example

1

Set up your virtual environment

2

Install dependencies

3

Export your OpenAI API key

4

Run the example

Save the code above as tool_error_persistence.py, then run:
Full source: cookbook/02_agents/18_checkpointing/02_tool_error_persistence.py