Skip to content

Conversation

@alexander-alderman-webb
Copy link
Contributor

@alexander-alderman-webb alexander-alderman-webb commented Feb 12, 2026

Description

The AgentRunner._get_model() class method has been moved to the function agents.run_internal.turn_preparation.get_model().

Patch the new function by re-using existing wrapper logic.

Issues

Reminders

@alexander-alderman-webb alexander-alderman-webb changed the title fix(openai-agents): Patch tool functions following library refactor fix(openai-agents): Patch models functions following library refactor Feb 12, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

Openai Agents

  • Patch models functions following library refactor by alexander-alderman-webb in #5449
  • Patch tool functions following library refactor by alexander-alderman-webb in #5445

Other

  • (celery) Close the connection we're reading driver_type from by sentrivana in #5427

Documentation 📚

  • Document openai-agents control-flow by alexander-alderman-webb in #5447

Internal Changes 🔧

  • (ci) Improve Craft config with title stripping and artifact filtering by BYK in #5444
  • (openai-agents) Avoid calling SDK-internal functions by alexander-alderman-webb in #5437
  • Use fixed clickhouse action, remove aws-sam-cli dependency by sentrivana in #5457
  • Remove references to unsupported attribute types by alexander-alderman-webb in #5425
  • Pin setuptools for linting and chalice tests by alexander-alderman-webb in #5438

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

Codecov Results 📊

56 passed | Total: 56 | Pass Rate: 100% | Execution Time: 7.67s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +4
Passed Tests 📈 +4
Failed Tests
Skipped Tests

All tests are passing successfully.

❌ Patch coverage is 1.33%. Project has 12820 uncovered lines.
✅ Project coverage is 35.11%. Comparing base (base) to head (head).

Files with missing lines (181)
File Patch % Lines
langchain.py 3.28% ⚠️ 590 Missing
openai.py 5.57% ⚠️ 492 Missing
utils.py 55.48% ⚠️ 406 Missing and 77 partials
utils.py 0.00% ⚠️ 474 Missing
tracing_utils.py 54.73% ⚠️ 268 Missing and 44 partials
transport.py 24.56% ⚠️ 298 Missing and 4 partials
scope.py 74.54% ⚠️ 209 Missing and 70 partials
mcp.py 5.24% ⚠️ 253 Missing
anthropic.py 9.16% ⚠️ 248 Missing
client.py 63.55% ⚠️ 183 Missing and 64 partials
__init__.py 3.91% ⚠️ 221 Missing
langgraph.py 5.29% ⚠️ 215 Missing
utils.py 16.08% ⚠️ 214 Missing
span_processor.py 0.00% ⚠️ 205 Missing
__init__.py 5.14% ⚠️ 203 Missing
continuous_profiler.py 44.73% ⚠️ 173 Missing and 13 partials
strawberry.py 8.54% ⚠️ 182 Missing
aws_lambda.py 16.50% ⚠️ 167 Missing
spark_driver.py 0.00% ⚠️ 166 Missing
huggingface_hub.py 8.89% ⚠️ 164 Missing
sanic.py 9.60% ⚠️ 160 Missing
tracing.py 76.21% ⚠️ 113 Missing and 46 partials
aiohttp.py 10.84% ⚠️ 148 Missing
cloud_resource_context.py 0.00% ⚠️ 145 Missing
ai_client.py 0.00% ⚠️ 145 Missing
transaction_profiler.py 63.28% ⚠️ 123 Missing and 21 partials
rust_tracing.py 0.00% ⚠️ 143 Missing
litellm.py 0.00% ⚠️ 138 Missing
litestar.py 9.59% ⚠️ 132 Missing
starlite.py 8.33% ⚠️ 132 Missing
__init__.py 76.14% ⚠️ 94 Missing and 26 partials
envelope.py 48.47% ⚠️ 101 Missing and 16 partials
falcon.py 8.94% ⚠️ 112 Missing
cohere.py 12.70% ⚠️ 110 Missing
dramatiq.py 0.00% ⚠️ 110 Missing
agent_run.py 0.00% ⚠️ 110 Missing
arq.py 9.92% ⚠️ 109 Missing
hub.py 45.60% ⚠️ 105 Missing and 3 partials
pymongo.py 10.17% ⚠️ 106 Missing
beat.py 8.62% ⚠️ 106 Missing
utils.py 0.00% ⚠️ 103 Missing
asyncpg.py 11.61% ⚠️ 99 Missing
quart.py 16.10% ⚠️ 99 Missing
gcp.py 0.00% ⚠️ 98 Missing
otlp.py 0.00% ⚠️ 97 Missing
utils.py 13.39% ⚠️ 97 Missing
models.py 4.95% ⚠️ 96 Missing
pyramid.py 13.76% ⚠️ 94 Missing
tornado.py 14.55% ⚠️ 94 Missing
__init__.py 0.00% ⚠️ 93 Missing
bottle.py 11.65% ⚠️ 91 Missing
agent_run.py 0.00% ⚠️ 90 Missing
stdlib.py 35.82% ⚠️ 86 Missing and 2 partials
runner.py 0.00% ⚠️ 87 Missing
beam.py 0.00% ⚠️ 84 Missing
loguru.py 11.58% ⚠️ 84 Missing
ray.py 0.00% ⚠️ 84 Missing
caching.py 22.64% ⚠️ 82 Missing and 2 partials
asyncio.py 0.00% ⚠️ 80 Missing
invoke_agent.py 0.00% ⚠️ 79 Missing
clickhouse_driver.py 17.58% ⚠️ 75 Missing
spotlight.py 54.86% ⚠️ 65 Missing and 8 partials
pure_eval.py 0.00% ⚠️ 73 Missing
worker.py 22.58% ⚠️ 72 Missing
ariadne.py 14.46% ⚠️ 71 Missing
gql.py 10.13% ⚠️ 71 Missing
starlette.py 88.76% ⚠️ 40 Missing and 31 partials
sqlalchemy.py 10.26% ⚠️ 70 Missing
monitoring.py 17.07% ⚠️ 68 Missing
graphene.py 12.82% ⚠️ 68 Missing
_queue.py 26.67% ⚠️ 66 Missing
rq.py 15.38% ⚠️ 66 Missing
huey.py 17.72% ⚠️ 65 Missing
boto3.py 14.86% ⚠️ 63 Missing
logging.py 68.63% ⚠️ 48 Missing and 15 partials
chalice.py 16.18% ⚠️ 57 Missing
propagator.py 0.00% ⚠️ 57 Missing
streaming.py 0.00% ⚠️ 56 Missing
server.py 0.00% ⚠️ 56 Missing
spark_worker.py 0.00% ⚠️ 56 Missing
api.py 65.10% ⚠️ 52 Missing and 1 partials
graph_nodes.py 0.00% ⚠️ 52 Missing
gnu_backtrace.py 0.00% ⚠️ 51 Missing
_async_common.py 0.00% ⚠️ 51 Missing
socket.py 0.00% ⚠️ 50 Missing
sessions.py 70.68% ⚠️ 39 Missing and 10 partials
tools.py 0.00% ⚠️ 49 Missing
caches.py 16.95% ⚠️ 49 Missing
invoke_agent.py 0.00% ⚠️ 46 Missing
traces.py 47.06% ⚠️ 45 Missing
templates.py 62.00% ⚠️ 38 Missing and 7 partials
utils.py 46.67% ⚠️ 40 Missing and 5 partials
_batcher.py 47.50% ⚠️ 42 Missing and 1 partials
__init__.py 8.51% ⚠️ 43 Missing
utils.py 24.07% ⚠️ 41 Missing and 1 partials
asgi.py 69.72% ⚠️ 33 Missing and 7 partials
client.py 0.00% ⚠️ 40 Missing
_sync_common.py 22.00% ⚠️ 39 Missing
client.py 0.00% ⚠️ 38 Missing
_span_batcher.py 35.71% ⚠️ 36 Missing
serverless.py 0.00% ⚠️ 36 Missing
server.py 0.00% ⚠️ 35 Missing
threading.py 75.79% ⚠️ 23 Missing and 10 partials
sys_exit.py 0.00% ⚠️ 32 Missing
launchdarkly.py 0.00% ⚠️ 31 Missing
session.py 80.00% ⚠️ 18 Missing and 12 partials
trytond.py 0.00% ⚠️ 30 Missing
integration.py 0.00% ⚠️ 30 Missing
serializer.py 89.25% ⚠️ 20 Missing and 9 partials
error_tracing.py 0.00% ⚠️ 29 Missing
asgi.py 87.86% ⚠️ 17 Missing and 11 partials
tools.py 0.00% ⚠️ 27 Missing
ai_client.py 13.33% ⚠️ 26 Missing
execute_tool.py 0.00% ⚠️ 26 Missing
_openai_completions_api.py 19.35% ⚠️ 25 Missing
httpx.py 68.49% ⚠️ 23 Missing and 2 partials
redis_cluster.py 26.47% ⚠️ 25 Missing
_wsgi_common.py 84.25% ⚠️ 20 Missing and 4 partials
typer.py 0.00% ⚠️ 24 Missing
_compat.py 41.03% ⚠️ 23 Missing
statsig.py 0.00% ⚠️ 23 Missing
queries.py 25.81% ⚠️ 23 Missing
logger.py 43.59% ⚠️ 22 Missing
decorator.py 37.14% ⚠️ 22 Missing
_log_batcher.py 0.00% ⚠️ 21 Missing
attachments.py 27.59% ⚠️ 21 Missing
monitor.py 68.85% ⚠️ 19 Missing and 2 partials
__init__.py 85.87% ⚠️ 13 Missing and 8 partials
unraisablehook.py 0.00% ⚠️ 21 Missing
flask.py 89.06% ⚠️ 14 Missing and 6 partials
openfeature.py 0.00% ⚠️ 20 Missing
execute_tool.py 0.00% ⚠️ 20 Missing
unleash.py 0.00% ⚠️ 19 Missing
model_request.py 0.00% ⚠️ 18 Missing
utils.py 0.00% ⚠️ 16 Missing
_lru_cache.py 60.00% ⚠️ 12 Missing and 3 partials
atexit.py 56.25% ⚠️ 14 Missing and 1 partials
excepthook.py 56.25% ⚠️ 14 Missing and 1 partials
redis.py 25.00% ⚠️ 15 Missing
_werkzeug.py 66.67% ⚠️ 9 Missing and 5 partials
wsgi.py 91.41% ⚠️ 11 Missing and 3 partials
scrubber.py 89.86% ⚠️ 7 Missing and 6 partials
__init__.py 27.78% ⚠️ 13 Missing
types.py 0.00% ⚠️ 12 Missing
executing.py 81.58% ⚠️ 7 Missing and 5 partials
middleware.py 93.33% ⚠️ 6 Missing and 6 partials
signals_handlers.py 88.64% ⚠️ 5 Missing and 7 partials
redis_py_cluster_legacy.py 26.67% ⚠️ 11 Missing
api.py 37.50% ⚠️ 10 Missing
utils.py 41.18% ⚠️ 10 Missing
handoff.py 0.00% ⚠️ 10 Missing
metrics.py 47.06% ⚠️ 9 Missing
fastapi.py 97.56% ⚠️ 2 Missing and 7 partials
__init__.py 72.41% ⚠️ 8 Missing and 1 partials
dedupe.py 85.00% ⚠️ 6 Missing and 2 partials
_metrics_batcher.py 65.00% ⚠️ 7 Missing
_types.py 76.67% ⚠️ 7 Missing
_asgi_common.py 94.44% ⚠️ 3 Missing and 4 partials
transactions.py 94.03% ⚠️ 4 Missing and 3 partials
consts.py 0.00% ⚠️ 7 Missing
rb.py 30.00% ⚠️ 7 Missing
_init_implementation.py 75.00% ⚠️ 6 Missing
_openai_responses_api.py 33.33% ⚠️ 6 Missing
views.py 90.00% ⚠️ 5 Missing and 1 partials
feature_flags.py 93.75% ⚠️ 2 Missing and 2 partials
consts.py 0.00% ⚠️ 4 Missing
__init__.py 20.00% ⚠️ 4 Missing
__init__.py 0.00% ⚠️ 4 Missing
__init__.py 0.00% ⚠️ 3 Missing
__init__.py 40.00% ⚠️ 3 Missing
__init__.py 0.00% ⚠️ 3 Missing
__init__.py 0.00% ⚠️ 3 Missing
__init__.py 0.00% ⚠️ 3 Missing
consts.py 99.43% ⚠️ 2 Missing
debug.py 95.65% ⚠️ 1 Missing and 1 partials
argv.py 100.00% ⚠️ 2 partials
modules.py 94.12% ⚠️ 1 Missing and 1 partials
tasks.py 95.83% ⚠️ 1 Missing and 1 partials
agent_workflow.py 71.43% ⚠️ 2 Missing
consts.py 0.00% ⚠️ 1 Missing
consts.py 0.00% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    25.75%    35.11%    +9.36%
==========================================
  Files          189       189         —
  Lines        19765     19758        -7
  Branches      6408      6408         —
==========================================
+ Hits          5090      6938     +1848
- Misses       14675     12820     -1855
- Partials       431       600      +169

Generated by Codecov Action

@alexander-alderman-webb alexander-alderman-webb marked this pull request as ready for review February 12, 2026 10:38
@alexander-alderman-webb alexander-alderman-webb requested a review from a team as a code owner February 12, 2026 10:38
Copy link
Member

@ericapisani ericapisani left a comment

Choose a reason for hiding this comment

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

Small things, but otherwise LGTM 🚀

@wraps(original_fetch_response)
async def wrapped_fetch_response(*args: "Any", **kwargs: "Any") -> "Any":
response = await original_fetch_response(*args, **kwargs)
if hasattr(response, "model") and response.model:
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: I think an alternative approach that you could take here in order to make this conditional more concise (by removing the and part of the conditional) is to do the following:

Suggested change
if hasattr(response, "model") and response.model:
if getattr(response, "model", None):

This would also make things consistent with what you have on line 119 within the wrapped_get_response function.

Copy link
Contributor Author

@alexander-alderman-webb alexander-alderman-webb Feb 13, 2026

Choose a reason for hiding this comment

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

We need to rethink this response model business because we probably shouldn't be setting response models on agent spans either.

This was put in before I knew as much about agents, but there are libraries that let you vary the request model during agent execution as well (in particular Claude Code wrapped by the Claude Agent SDK).

Created an issue to track #5458

(and the plan would be to clean up as part of that issue).

Comment on lines +136 to +137
# Uses explicit try/finally instead of context manager to ensure cleanup
# even if the consumer abandons the stream (GeneratorExit).
Copy link
Member

Choose a reason for hiding this comment

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

This comment looks like it needs to be updated or removed as there's no try/finally below and the code uses a context manager 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're completely right, and it doesn't look like we catch GeneratorExit anywhere for that matter 😅 .

I'll keep this commit atomic since we're moving the contents of wrapped_get_model() to _get_model() as is now, and follow up with a PR after this first train is merged 🚅

Base automatically changed from webb/openai-agents/tool-patches to master February 13, 2026 08:15
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@alexander-alderman-webb alexander-alderman-webb merged commit a5c2906 into master Feb 13, 2026
153 checks passed
@alexander-alderman-webb alexander-alderman-webb deleted the webb/openai-agents/model-patches branch February 13, 2026 13:34
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.

3 participants