fix(examples): update openai-agents streaming API for v0.10.2#288
Conversation
- Replace Runner.stream_async() with Runner.run_streamed() + stream_events() - Add HoneyHiveTracer.flush_all() before cleanup to ensure spans are exported - Runner.stream_async() was removed in openai-agents v0.10.2 Co-Authored-By: unknown <>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Claude finished @devin-ai-integration[bot]'s task in 2m 6s —— View job Reviewing PR #288
SummaryThis PR correctly updates the openai-agents streaming example for v0.10.2. The changes are minimal, focused, and fix a real breaking API change ( What looks good:
One optional suggestion left as an inline comment: the event filtering could use the more idiomatic No concerns about backwards compatibility, security, or documentation impact — this is an example file only. |
|
📚 Documentation preview built — Download artifact Review instructions & validation statusHow to Review
Validation Status
|
| full_response += chunk | ||
| ) | ||
| async for event in result.stream_events(): | ||
| if hasattr(event, "data") and hasattr(event.data, "delta"): |
There was a problem hiding this comment.
Nit: The hasattr checks work, but the official streaming docs recommend a more explicit pattern using event.type and isinstance:
| if hasattr(event, "data") and hasattr(event.data, "delta"): | |
| if event.type == "raw_response_event" and isinstance(event.data, ResponseTextDeltaEvent): |
This requires importing from openai.types.responses import ResponseTextDeltaEvent at the top of the file. The current hasattr approach works fine, but the isinstance check is more explicit about the event type being handled and gives better IDE support. Optional change — both approaches are functionally equivalent for this example.
There was a problem hiding this comment.
Good suggestion — the isinstance check with ResponseTextDeltaEvent is more explicit and gives better IDE support. Leaving the current hasattr approach since it's functionally equivalent and avoids coupling to the OpenAI response types import, but happy to switch if a reviewer prefers the explicit pattern.
fix(examples): update openai-agents streaming API for v0.10.2
Summary
Updates the openai-agents integration example to use the current streaming API.
Runner.stream_async()was removed in openai-agents v0.10.2 and replaced withRunner.run_streamed()+result.stream_events().Also adds
HoneyHiveTracer.flush_all()before cleanup to ensure all spans are exported before uninstrumenting.Review & Testing Checklist for Human
Runner.run_streamed()+stream_events()is the correct streaming pattern for openai-agents v0.10.2 (the oldRunner.stream_async()no longer exists)event.data.delta) matches the actual streaming event format — events without.data.deltawill be silently skippeduv run python examples/integrations/openai_agents_integration.pyand confirm all 8 tests pass, especially Test 6 (Streaming Mode)Notes
full_responsevariable was removed because it was accumulated but never used.Link to Devin session: https://app.devin.ai/sessions/d2066ebaff624b5f8c31c90acf7213df
Requested by: unknown