-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
Description
Problem
When canceling a streaming run with result.cancel()
, it stops immediately and discards the current turn. This means:
- The incomplete turn isn't saved to the session
- Usage tracking is cut off mid-turn
- Can't resume the session cleanly
This is painful if the user interrupts a long task - all progress from current turn is lost, and its usage cant be tracked.
Current behavior
result = Runner.run_streamed(agent, "Task", session=session)
async for event in result.stream_events():
if timeout:
result.cancel() # Stops immediately, turn is discarded
Would be nice to have a way to let the current turn complete before stopping.