fix: cap openai <2.45 for openai-agents 0.14.x compatibility#459
Merged
Conversation
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>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
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.
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_streaming10_async/10_temporal/070_open_ai_agents_sdk_tools,080_..._human_in_the_loop10_async/10_temporal/020_state_machine10_async/00_base/040_other_sdksThe 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:
Traceback:
Runner.run_streamed->ensure_context_wrapper->agents/usage.py:112doesInputTokensDetails(cached_tokens=0).openai==2.45.0madeInputTokensDetails.cache_write_tokensa required field (it was optional through 2.44.0).openai-agents==0.14.8(the latest release) still buildsInputTokensDetails(cached_tokens=0)without it, so everyRunner.run_streamedraises at context setup, before any LLM call.Why only the tutorials break: the repo's own
uv.lockpinsopenai 2.40.0, so unit tests pass. The tutorial agents have no lockfile and resolve dependencies fresh, so they pullopenai 2.45.0. Every failing tutorial hits the sameInputTokensDetailserror (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):
Fix
Cap
openai <2.45in theagentex-sdk(adk/pyproject.toml) dependencies. Because the tutorials depend onagentex-sdk, this ceiling flows into their fresh resolves via the built wheel. Verified: a fresh resolve of the tutorial dependency set now lands onopenai 2.44.0.openai-agents 0.14.8is the latest release, so there is no newer version to bump to. The ceiling should be dropped once openai-agents ships a fix for itsInputTokensDetailsconstruction.Verification
InputTokensDetailscrash and confirmed openai 2.44.0 resolves it (no API key required, crash is pre-LLM).openai-agentsdep) and confirmed both now selectopenai 2.44.0.uv lockregenerated; the only changes are theopenaispecifier and a staleagentex-sdkversion sync.🤖 Generated with Claude Code
Greptile Summary
This PR caps the
openaidependency to<2.45inadk/pyproject.tomlto work around a breaking change inopenai 2.45.0that madeInputTokensDetails.cache_write_tokensa required field, whileopenai-agents 0.14.xstill constructsInputTokensDetailswithout it — causing apydantic ValidationErrorin everyRunner.run_streamedcall that was breaking tutorial CI.adk/pyproject.toml: Narrowsopenai>=2.2,<3to>=2.2,<2.45with an explanatory comment; theuv.lockis regenerated accordingly and syncs theagentex-sdkversion from0.13.0to0.17.0.uv.lock: Only theopenaispecifier and the staleagentex-sdkversion 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
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%%{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"] --> BPrompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix: cap openai <2.45 for openai-agents ..." | Re-trigger Greptile