Skip to content

Fix tests for openai v2.45.0 cache_write_tokens compatibility#453

Merged
fanzeyi merged 1 commit into
databricks:mainfrom
fanzeyi:fix/openai-v2.45-compat
Jul 16, 2026
Merged

Fix tests for openai v2.45.0 cache_write_tokens compatibility#453
fanzeyi merged 1 commit into
databricks:mainfrom
fanzeyi:fix/openai-v2.45-compat

Conversation

@fanzeyi

@fanzeyi fanzeyi commented Jul 16, 2026

Copy link
Copy Markdown
Member

Problem

CI started failing for the langchain tests and type checks due to a breaking change in openai v2.45.0 (released July 9, 2026).

openai v2.45.0 added a new required field cache_write_tokens: int to InputTokensDetails in openai.types.responses.response_usage:

# v2.44.0
class InputTokensDetails(BaseModel):
    cached_tokens: int

# v2.45.0
class InputTokensDetails(BaseModel):
    cache_write_tokens: int   # NEW, required, no default
    cached_tokens: int

Existing tests construct InputTokensDetails(cached_tokens=...) without cache_write_tokens, causing ValidationError on v2.45.0.

Failures

This causes 6 test failures and 4 ty type-check errors:

  • test_convert_responses_usage_to_usage_metadata (2 parametrized)
  • test_extract_response_usage_from_chunk (2 parametrized)
  • test_build_usage_chunk_from_responses (1 parametrized)
  • test_chat_databricks_responses_api_invoke_returns_usage_metadata

The langchain_test and langchain_test_with_extras jobs fail with uv: highest resolution (which picks up v2.45.0), while lowest-direct still passes (uses older version).

Fix

Pass cache_write_tokens=0 to all InputTokensDetails constructions.

This is backward compatible: openai's BaseModel uses extra='allow', so the extra field is silently accepted on older versions (e.g. v2.44.0) that don't define it.

Verified passing on both openai==2.44.0 and openai==2.45.0.

openai v2.45.0 added a required  field to
 in .
Existing tests construct  without
this field, causing ValidationError on the newer version.

Pass  to all InputTokensDetails constructions.
This is backward compatible because openai's BaseModel uses
, so the extra field is silently accepted on older
versions that don't define it.

Verified passing on both openai v2.44.0 and v2.45.0.
@fanzeyi
fanzeyi enabled auto-merge (squash) July 16, 2026 21:36
@nisha2003
nisha2003 self-requested a review July 16, 2026 21:37
@fanzeyi
fanzeyi merged commit 1d05c1f into databricks:main Jul 16, 2026
42 of 46 checks passed
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.

2 participants