Commit 34111be
fix(openai-agents): Resolve agent from
Update the openai-agents integration's run-loop patches to resolve the
current agent from the new `AgentBindings` dataclass introduced in
openai-agents 0.14, falling back to the pre-0.14 `agent` kwarg.
Prior to 0.14, `run_single_turn`, `run_single_turn_streamed`,
`execute_handoffs`, and `execute_final_output` all received the current
agent as `agent=...`. In 0.14 the library refactored these to pass
`bindings: AgentBindings` (carrying `public_agent` and
`execution_agent`) to the `run_single_turn*` functions and renamed the
`agent` kwarg to `public_agent` on the `execute_*` functions. Our
patches still called `kwargs.get("agent")`, which returned `None` — so
`_maybe_start_agent_span` short-circuited and no `invoke_agent` span was
ever created. Every `test_agent_invocation_span*` parametrization failed
on the `openai_agents-latest` suite with `not enough values to unpack
(expected 2, got 1)`.
`public_agent` is used rather than `execution_agent` because it's the
user-facing identity the library itself uses for lifecycle hooks
(`on_agent_start`, `on_llm_start`), `streamed_result.current_agent`, and
`RunItem.agent` fields. The two only diverge in sandbox execution
(`agents/sandbox/runtime.py`), where `execution_agent` is 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)
and `py3.14-openai_agents-v0.8.4` (legacy kwarg fallback path).
Refs PY-2382
Fixes #6101
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>bindings for openai-agents >= 0.14 (#6102)1 parent a594f8b commit 34111be
1 file changed
Lines changed: 30 additions & 5 deletions
Lines changed: 30 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
93 | 99 | | |
94 | 100 | | |
95 | 101 | | |
| |||
119 | 125 | | |
120 | 126 | | |
121 | 127 | | |
122 | | - | |
| 128 | + | |
123 | 129 | | |
124 | 130 | | |
125 | 131 | | |
| |||
131 | 137 | | |
132 | 138 | | |
133 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
134 | 153 | | |
135 | 154 | | |
136 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
137 | 160 | | |
138 | 161 | | |
139 | 162 | | |
| |||
179 | 202 | | |
180 | 203 | | |
181 | 204 | | |
182 | | - | |
| 205 | + | |
| 206 | + | |
183 | 207 | | |
184 | 208 | | |
185 | 209 | | |
| |||
214 | 238 | | |
215 | 239 | | |
216 | 240 | | |
217 | | - | |
| 241 | + | |
| 242 | + | |
218 | 243 | | |
219 | 244 | | |
220 | 245 | | |
| |||
0 commit comments