Skip to content

Runner.run() crashes with openai 2.45.0: InputTokensDetails now requires cache_write_tokens #3772

Description

@arashne

Describe the bug

openai 2.45.0 (released 2026-07-09) added cache_write_tokens to openai.types.responses.response_usage.InputTokensDetails as a required field. The SDK constructs InputTokensDetails(cached_tokens=0) in several places, starting with the Usage default factory (agents/usage.py:112), so every run now fails immediately:

pydantic_core._pydantic_core.ValidationError: 1 validation error for InputTokensDetails
cache_write_tokens
  Field required [type=missing, input_value={'cached_tokens': 0}, input_type=dict]

The crash happens at Runner.run() entry, when RunContextWrapper builds its default Usage(). No model call is made, so this is independent of model or provider. The current dependency pin (openai<3,>=2.36.0) admits 2.45.0, so any fresh install is broken.

Debug information

  • Agents SDK version: 0.18.0
  • Python version: 3.12

Repro steps

# pip install openai-agents==0.18.0 openai==2.45.0
from agents.usage import Usage

Usage()  # raises ValidationError

Expected behavior

Usage() constructs and runs work under openai 2.45.0. Fix is probably passing cache_write_tokens=0 at the construction sites (about 10, across agents/usage.py, models/chatcmpl_stream_handler.py, and extensions/models/), or capping the openai pin until that lands.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions