Skip to content

fix: cap openai <2.45 for openai-agents 0.14.x compatibility#459

Merged
declan-scale merged 1 commit into
nextfrom
declan-scale/fix-tutorial-agent-tests
Jul 10, 2026
Merged

fix: cap openai <2.45 for openai-agents 0.14.x compatibility#459
declan-scale merged 1 commit into
nextfrom
declan-scale/fix-tutorial-agent-tests

Conversation

@declan-scale

@declan-scale declan-scale commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Problem

The Test Tutorial Agents workflow has been failing on every branch (next, feature branches, and every release PR such as #457). The same set of tutorials fail deterministically:

  • 00_sync/010_multiturn, 00_sync/020_streaming
  • 10_async/10_temporal/070_open_ai_agents_sdk_tools, 080_..._human_in_the_loop
  • 10_async/10_temporal/020_state_machine
  • 10_async/00_base/040_other_sdks

The failures are not caused by any of those PRs (e.g. #457 is a Stainless release PR that never touches examples/). They are a pre-existing dependency incompatibility.

Root cause

The agent-side logs (printed by the workflow's "Print agent logs on failure" step) show:

pydantic_core.ValidationError: 1 validation error for InputTokensDetails
cache_write_tokens
  Field required

Traceback: Runner.run_streamed -> ensure_context_wrapper -> agents/usage.py:112 does InputTokensDetails(cached_tokens=0).

  • openai==2.45.0 made InputTokensDetails.cache_write_tokens a required field (it was optional through 2.44.0).
  • openai-agents==0.14.8 (the latest release) still builds InputTokensDetails(cached_tokens=0) without it, so every Runner.run_streamed raises at context setup, before any LLM call.

Why only the tutorials break: the repo's own uv.lock pins openai 2.40.0, so unit tests pass. The tutorial agents have no lockfile and resolve dependencies fresh, so they pull openai 2.45.0. Every failing tutorial hits the same InputTokensDetails error (confirmed for the sync direct path, the temporal openai-agents plugin path, and the temporal worker/ADK path).

Reproduced locally with no API key needed (the crash is at run setup, not the LLM call):

openai 2.44.0 + openai-agents 0.14.8  -> Usage() / RunContextWrapper OK
openai 2.45.0 + openai-agents 0.14.8  -> ValidationError: cache_write_tokens Field required

Fix

Cap openai <2.45 in the agentex-sdk (adk/pyproject.toml) dependencies. Because the tutorials depend on agentex-sdk, this ceiling flows into their fresh resolves via the built wheel. Verified: a fresh resolve of the tutorial dependency set now lands on openai 2.44.0.

openai-agents 0.14.8 is the latest release, so there is no newer version to bump to. The ceiling should be dropped once openai-agents ships a fix for its InputTokensDetails construction.

Verification

  • Reproduced the exact InputTokensDetails crash and confirmed openai 2.44.0 resolves it (no API key required, crash is pre-LLM).
  • Dry-run resolved both tutorial dependency shapes (with and without an explicit openai-agents dep) and confirmed both now select openai 2.44.0.
  • uv lock regenerated; the only changes are the openai specifier and a stale agentex-sdk version sync.
  • End-to-end tutorial runs need live LLM keys (CI has them), so CI on this PR is the final verification.

🤖 Generated with Claude Code

Greptile Summary

This PR caps the openai dependency to <2.45 in adk/pyproject.toml to work around a breaking change in openai 2.45.0 that made InputTokensDetails.cache_write_tokens a required field, while openai-agents 0.14.x still constructs InputTokensDetails without it — causing a pydantic ValidationError in every Runner.run_streamed call that was breaking tutorial CI.

  • adk/pyproject.toml: Narrows openai>=2.2,<3 to >=2.2,<2.45 with an explanatory comment; the uv.lock is regenerated accordingly and syncs the agentex-sdk version from 0.13.0 to 0.17.0.
  • uv.lock: Only the openai specifier and the stale agentex-sdk version entry change; no other dependency pins are altered.

Confidence Score: 4/5

Safe to merge — the change is a targeted dependency ceiling with a clear, documented root cause and no impact on existing lockfile-pinned unit tests.

The fix correctly identifies and works around the openai 2.45.0 breaking change. The only gap is that the cleanup reminder comment has no linked ticket, making it easy to overlook when the upstream fix lands.

adk/pyproject.toml — the cleanup reminder comment should be linked to a Linear task so the ceiling does not outlive its usefulness.

Important Files Changed

Filename Overview
adk/pyproject.toml Caps openai dependency at <2.45 to avoid the InputTokensDetails ValidationError introduced in openai 2.45.0; comment explains the reason well but lacks a ticket number for follow-up.
uv.lock Lock file updated to reflect the new <2.45 openai specifier and syncs agentex-sdk version from 0.13.0 to 0.17.0.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Tutorial agent fresh resolve\n(no lockfile)"] --> B{openai version resolved}
    B -- "openai >=2.45\n(before fix)" --> C["InputTokensDetails construction\nagents/usage.py:112\ncached_tokens=0 only"]
    C --> D["pydantic ValidationError\ncache_write_tokens: Field required"]
    D --> E["Runner.run_streamed fails\nbefore any LLM call"]
    B -- "openai <2.45\n(after fix: cap in adk/pyproject.toml)" --> F["InputTokensDetails OK\ncache_write_tokens not required"]
    F --> G["Runner.run_streamed succeeds"]
    H["adk/pyproject.toml\nopenai>=2.2,<2.45"] --> B
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["Tutorial agent fresh resolve\n(no lockfile)"] --> B{openai version resolved}
    B -- "openai >=2.45\n(before fix)" --> C["InputTokensDetails construction\nagents/usage.py:112\ncached_tokens=0 only"]
    C --> D["pydantic ValidationError\ncache_write_tokens: Field required"]
    D --> E["Runner.run_streamed fails\nbefore any LLM call"]
    B -- "openai <2.45\n(after fix: cap in adk/pyproject.toml)" --> F["InputTokensDetails OK\ncache_write_tokens not required"]
    F --> G["Runner.run_streamed succeeds"]
    H["adk/pyproject.toml\nopenai>=2.2,<2.45"] --> B
Loading

Fix All in Claude Code

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
adk/pyproject.toml:42-51
**Missing ticket link on the "drop this ceiling" reminder**

The comment says "drop this ceiling once openai-agents ships a fix," but there is no Linear task number attached to make that cleanup traceable. Per team rules, TODO-style comments must include a ticket number so the follow-up can be found with a quick search. Without it, this ceiling is likely to linger long after `openai-agents` publishes a fix for the `InputTokensDetails` construction.

Reviews (1): Last reviewed commit: "fix: cap openai <2.45 for openai-agents ..." | Re-trigger Greptile

openai 2.45.0 made `InputTokensDetails.cache_write_tokens` a required
field, but openai-agents 0.14.x (the latest release) still constructs
`InputTokensDetails(cached_tokens=0)` in agents/usage.py. As a result
every `Runner.run_streamed` call raises a pydantic ValidationError at
context setup, before any LLM request.

The repo's own uv.lock pins openai 2.40.0 so unit tests pass, but the
tutorial agents resolve their dependencies fresh (no lockfile) and pick
up openai 2.45.0, which is why the "Test Tutorial Agents" workflow fails
on every branch for all openai-agents based tutorials (010_multiturn,
020_streaming, temporal openai-agents tools/HIL, state_machine, and the
other-SDKs base tutorial).

Capping openai <2.45 in the agentex-sdk deps makes fresh resolves land
on openai 2.44.0, which is compatible. Drop the ceiling once openai-agents
ships a fix.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedpypi/​agentex-sdk@​0.13.0 ⏵ 0.17.094 +1100100100 +50100

View full report

@declan-scale declan-scale merged commit 14c124d into next Jul 10, 2026
48 checks passed
@declan-scale declan-scale deleted the declan-scale/fix-tutorial-agent-tests branch July 10, 2026 00:19
@stainless-app stainless-app Bot mentioned this pull request Jul 10, 2026
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.

1 participant