fix(openai-agents): Resolve agent from bindings for openai-agents >= 0.14#6102
Merged
ericapisani merged 1 commit intomasterfrom Apr 21, 2026
Merged
Conversation
…= 0.14
openai-agents 0.14 refactored its run loop to pass an `AgentBindings`
dataclass (with `public_agent` and `execution_agent` fields) instead of
a raw `agent` kwarg to `run_single_turn` / `run_single_turn_streamed`,
and renamed the `agent` kwarg to `public_agent` on `execute_handoffs` /
`execute_final_output`. As a result, the integration's `kwargs.get("agent")`
returned `None`, no `invoke_agent` span was created, and every
`test_agent_invocation_span*` case failed.
Resolve the agent from `bindings.public_agent` (or the `public_agent`
kwarg) with a fallback to the pre-0.14 `agent` kwarg so older pinned
versions remain supported. `public_agent` is the user-facing identity
the library itself uses for hooks and stream events, which keeps span
names stable across sandbox-prepared execution agents.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 142 passed | Total: 142 | Pass Rate: 100% | Execution Time: 21.27s All tests are passing successfully. ❌ Patch coverage is 0.00%. Project has 14156 uncovered lines. Files with missing lines (1)
Generated by Codecov Action |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update the openai-agents integration's run-loop patches to resolve the current agent from the new
AgentBindingsdataclass introduced in openai-agents 0.14, falling back to the pre-0.14agentkwarg.Prior to 0.14,
run_single_turn,run_single_turn_streamed,execute_handoffs, andexecute_final_outputall received the current agent asagent=.... In 0.14 the library refactored these to passbindings: AgentBindings(carryingpublic_agentandexecution_agent) to therun_single_turn*functions and renamed theagentkwarg topublic_agenton theexecute_*functions. Our patches still calledkwargs.get("agent"), which returnedNone— so_maybe_start_agent_spanshort-circuited and noinvoke_agentspan was ever created. Everytest_agent_invocation_span*parametrization failed on theopenai_agents-latestsuite withnot enough values to unpack (expected 2, got 1).public_agentis used rather thanexecution_agentbecause it's the user-facing identity the library itself uses for lifecycle hooks (on_agent_start,on_llm_start),streamed_result.current_agent, andRunItem.agentfields. The two only diverge in sandbox execution (agents/sandbox/runtime.py), whereexecution_agentis a cloned sandbox-prepared agent — using that would produce unstable span names that don't match what users see from the library's own callbacks.Verified locally against
py3.14-openai_agents-latest(bindings path) andpy3.14-openai_agents-v0.8.4(legacy kwarg fallback path).Refs PY-2382
Fixes #6101