Python: added cache_write_tokens as required field#7049
Open
subhrm wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a compatibility break in the DevUI response mapper where constructing InputTokensDetails without the now-required cache_write_tokens field causes a Pydantic ValidationError, preventing any agent invocation from completing.
Changes:
- Add
cache_write_tokens=0toInputTokensDetails(...)construction in the successful usage path. - Add
cache_write_tokens=0toInputTokensDetails(...)construction in the fallback/estimated usage path. - Add
cache_write_tokens=0toInputTokensDetails(...)construction in the error response path.
moonbox3
approved these changes
Jul 10, 2026
moonbox3
left a comment
Contributor
There was a problem hiding this comment.
Could we add test coverage for the accumulated-usage, fallback, and error-response paths?
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.
Motivation & Context
openai added cache_write_tokens as a required field on InputTokensDetails. agent-framework-devui 1.0.0b260709 predates this change and constructs InputTokensDetails(cached_tokens=0) at three call sites in _mapper.py, omitting the now-required field. This causes a Pydantic ValidationError on every agent invocation, making the devui completely non-functional with current anthropic versions.
Description & Review Guide
Patched three call sites in agent_framework_devui/_mapper.py to pass cache_write_tokens=0 alongside the existing cached_tokens=0:
No logic changes — purely adding the missing required field with a zero value to satisfy the updated Pydantic model contract.
Related Issue
Fixes #7048
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.