Back to catalog / Agent observability
Render an agent event stream incrementally and handle completion states
Map streamed agent events to stable UI states without misrendering internal tool events as final answers.
Goal
Show progress while preserving event order and finish correctly on completion, failure, or cancellation.
Steps
- Identify event categories such as text deltas, tool calls, handoffs, and run completion. [openai-streaming] [openai-running]
- Start with
result=Runner.run_streamed(agent, input)and consumeasync for event in result.stream_events(). [openai-streaming] [openai-running] - Branch on
event.typeforraw_response_eventversusrun_item_stream_event; only text deltas are user-facing text. [openai-streaming] [openai-running] - Close the connection and set a final state on stream end, timeout, or user cancellation. [openai-streaming] [openai-running]
- Test a mock stream with text, tool events, and failure; ensure the UI does not expose hidden arguments. [openai-streaming] [openai-running]
How to verify
Event tests should cover normal end and mid-stream failure; tool events must not be appended to user-visible answers.
Troubleshooting
If output is duplicated, inspect event ordering and ensure deltas are not appended twice after reconnect.
Permissions
Prerequisites
- Python 3.10+, openai-agents compatible with the pinned revision, and authorized model-provider credentials (except local mock tests)
Permissions
- Use a local or isolated test environment; use least privilege and approval for external data or side effects
Limitations
SDK behavior varies by version. Check the pinned revision against your agent or client, then review data retention, authorization, and side effects before production use.
Pinned upstream source
- Repository
- openai/openai-agents-python
- File path
- docs/streaming.md
- Pinned commit
f53c62451c7f34c15f0c87fa745e05404025420f- Source checked
- 2026-10-14 · Reviewed against the pinned upstream source
Repository metrics
These values describe the upstream repository, not popularity or likes for an individual skill or playbook.
- Stars
- Not collected
- Forks
- Not collected
- Observed at
- Not collected
No metrics snapshot is available yet.
License: MIT
Main topic
Take a coding Agent change from context to verification