Skip to content

fix(examples): update openai-agents streaming API for v0.10.2#288

Open
devin-ai-integration[bot] wants to merge 1 commit intofederated-sdk-release-candidatefrom
devin/1772445685-fix-openai-agents-streaming-api
Open

fix(examples): update openai-agents streaming API for v0.10.2#288
devin-ai-integration[bot] wants to merge 1 commit intofederated-sdk-release-candidatefrom
devin/1772445685-fix-openai-agents-streaming-api

Conversation

@devin-ai-integration
Copy link
Contributor

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 with Runner.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

  • Verify Runner.run_streamed() + stream_events() is the correct streaming pattern for openai-agents v0.10.2 (the old Runner.stream_async() no longer exists)
  • Verify the event shape check (event.data.delta) matches the actual streaming event format — events without .data.delta will be silently skipped
  • Run the example end-to-end: uv run python examples/integrations/openai_agents_integration.py and confirm all 8 tests pass, especially Test 6 (Streaming Mode)

Notes

  • The full_response variable was removed because it was accumulated but never used.
  • This fix was identified during an integration tracing pipeline validation for openai-agents v0.10.2. The other issues found (streaming token counts missing, guardrail-blocked empty spans, handoff empty I/O) are upstream instrumentor limitations, not fixable in this repo.

Link to Devin session: https://app.devin.ai/sessions/d2066ebaff624b5f8c31c90acf7213df
Requested by: unknown

- 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-integration devin-ai-integration bot requested a review from a team March 2, 2026 10:04
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@snyk-io
Copy link

snyk-io bot commented Mar 2, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@claude
Copy link
Contributor

claude bot commented Mar 2, 2026

Claude finished @devin-ai-integration[bot]'s task in 2m 6s —— View job


Reviewing PR #288

  • Gather context and read changed files
  • Review code changes for correctness and best practices
  • Post review feedback

Summary

This PR correctly updates the openai-agents streaming example for v0.10.2. The changes are minimal, focused, and fix a real breaking API change (Runner.stream_async() was removed in favor of Runner.run_streamed() + result.stream_events()).

What looks good:

  • The new streaming pattern (Runner.run_streamed() + stream_events()) matches the official openai-agents streaming docs
  • Adding HoneyHiveTracer.flush_all() before uninstrument() is a good practice — ensures all pending spans are exported before instrumentors are torn down
  • Removing the unused full_response accumulator is a clean improvement

One optional suggestion left as an inline comment: the event filtering could use the more idiomatic event.type == "raw_response_event" + isinstance(event.data, ResponseTextDeltaEvent) pattern from the official docs instead of hasattr checks, but both approaches work correctly for this example.

No concerns about backwards compatibility, security, or documentation impact — this is an example file only.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

📚 Documentation preview built — Download artifact

Review instructions & validation status

How to Review

  1. Download the artifact from the link above
  2. Extract the files
  3. Open index.html in your browser

Validation Status

  • API validation: ✅ Passed
  • Build process: ✅ Successful
  • Import tests: ✅ All imports working

full_response += chunk
)
async for event in result.stream_events():
if hasattr(event, "data") and hasattr(event.data, "delta"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The hasattr checks work, but the official streaming docs recommend a more explicit pattern using event.type and isinstance:

Suggested change
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants