Skip to content

Comments

fix(openai_agents): compat with >=0.8.0#16596

Open
Kyle-Verhoog wants to merge 3 commits intomainfrom
dd/fix/openai-agents-080-compat
Open

fix(openai_agents): compat with >=0.8.0#16596
Kyle-Verhoog wants to merge 3 commits intomainfrom
dd/fix/openai-agents-080-compat

Conversation

@Kyle-Verhoog
Copy link
Member

@Kyle-Verhoog Kyle-Verhoog commented Feb 20, 2026

PR by Bits
View session in Datadog

Comment @DataDog to request changes

Feedback (especially what can be better) welcome in #code-gen-aka-bits-dev-feedback!


Description

Fixes MLOS-469. The openai-agents SDK v0.8.0 removed AgentRunner._run_single_turn and AgentRunner._run_single_turn_streamed, causing an AttributeError when ddtrace tries to patch these methods.

This change adds hasattr checks before wrapping/unwrapping these methods so the integration gracefully handles their absence in newer SDK versions.

Testing

Existing patch tests continue to pass. The fix is defensive — when the methods don't exist, we simply skip wrapping them.

Risks

None — the change is additive and only skips patching when the target methods are absent.

Additional Notes

The _run_single_turn / _run_single_turn_streamed patches are used for tag_agent_manifest. On openai-agents >= 0.8.0 this tagging will be skipped until a follow-up adds support for the new SDK API.

Co-authored-by: Kyle-Verhoog <kyle@verhoog.ca>
@Kyle-Verhoog Kyle-Verhoog requested a review from a team as a code owner February 20, 2026 04:31
@datadog-datadog-prod-us1
Copy link
Contributor

datadog-datadog-prod-us1 bot commented Feb 20, 2026

[View session in Datadog]

Bits Dev status: ✅ Done

CI Auto-fix: Enabled | Disable

Comment @DataDog to request changes

@cit-pr-commenter-54b7da
Copy link

cit-pr-commenter-54b7da bot commented Feb 20, 2026

Codeowners resolved as

releasenotes/notes/fix-openai-agents-080-compat-41de292c2df92250.yaml   @DataDog/apm-python

@datadog-official

This comment has been minimized.

@datadog-official datadog-official bot changed the title Fix openai-agents >=0.8.0 compatibility fix(openai_agents): compat with >=0.8.0 Feb 20, 2026
Comment on lines +74 to +77
if hasattr(agents.run.AgentRunner, "_run_single_turn"):
wrap(agents.run.AgentRunner, "_run_single_turn", patched_run_single_turn(agents))
if hasattr(agents.run.AgentRunner, "_run_single_turn_streamed"):
wrap(agents.run.AgentRunner, "_run_single_turn_streamed", patched_run_single_turn_streamed(agents))
Copy link
Contributor

@dubloom dubloom Feb 20, 2026

Choose a reason for hiding this comment

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

Take a look at the whole workflow (with Bits).

That is super cool ! However, I'd say this looks a bit uncommon to me. As we can see in the code just above, when we have to do version specific patching, we tend to check the version instead of the "can we patch if yes we do"

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants