Skip to content

fix(agents): handle null cache usage counters - #476

Open
00200200 wants to merge 2 commits into
anthropics:mainfrom
00200200:codex/quickstart-optional-cache-usage
Open

00200200 wants to merge 2 commits into
anthropics:mainfrom
00200200:codex/quickstart-optional-cache-usage

Conversation

@00200200

@00200200 00200200 commented Sep 14, 2026

Copy link
Copy Markdown

Anthropic Usage objects permit null cache counters. Adding those fields to input_tokens raises TypeError and interrupts message-history updates. Treat missing or null cache counters as zero and retain populated cache counts when computing total usage.

Validation: PYTHONPATH=agents python -m pytest tests/agents/test_optional_cache_usage.py -q (6 passed in 0.01s). The regression tests fail on the unchanged main branch. Tests use local fixtures; no paid API calls.

Prepared with Codex assistance; the final diff and regression behavior were checked locally.

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