Skip to main content
Use raw httpx to track event_index, deliberately disconnect, and POST to the nested /resume route. The run demo resumes a new background stream. The continue demo first pauses on a confirmation tool, continues the run in the background, disconnects, and resumes that continued stream.
sse_reconnect.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 sse_reconnect.py, then run:
Full source: cookbook/05_agent_os/04_run_lifecycle/sse_reconnect.py