{{ message }}
Repository navigation
Python: fix(core): ensure add_usage_details returns copies and skips booleans - #8613
Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit intoSep 22, 2026
Conversation
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
September 21, 2026 17:48 — with
GitHub Actions
Inactive
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
September 21, 2026 17:48 — with
GitHub Actions
Inactive
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
September 21, 2026 17:48 — with
GitHub Actions
Inactive
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
September 21, 2026 17:48 — with
GitHub Actions
Inactive
Member
…ts consistently In add_usage_details, passing None for one of the arguments previously returned the other argument dictionary directly by reference, and early return copies bypassed boolean and non-integer filtering. Normalizing None operands to empty UsageDetails and routing all combinations through the common merge path ensures returned dictionaries are always new copies and that booleans and non-integer values are consistently skipped and logged. Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
Manohar Paturi (ManoharPaturi)
force-pushed
the
fix/add-usage-details-bool-and-copy
branch
from
September 22, 2026 12:47
caf817c to
bddab7e
Compare
Manohar Paturi (ManoharPaturi)
deployed
to
github-app-auth
September 22, 2026 12:47 — with
GitHub Actions
Active
Manohar Paturi (ManoharPaturi)
deployed
to
github-app-auth
September 22, 2026 12:47 — with
GitHub Actions
Active
Contributor
Author
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Sep 22, 2026
Eduard van Valkenburg (eavanvalkenburg)
left a comment
Member
There was a problem hiding this comment.
Manohar Paturi (@ManoharPaturi) Reviewed the complete diff; no high-confidence issues found.
This branch was successfully deployed
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
In
add_usage_details, when one of the arguments isNone, returning the other argument directly allowed callers to mutate the input usage dictionary in place. Returning a newUsageDetailscopy matches the documented contract ("Returns: A new UsageDetails dictionary with summed values").Additionally, because
boolis a subclass ofintin Python, boolean values in usage metadata passed theisinstance(val, int)check and were summed into integer token counts. Early return paths also bypassed filtering when only one usage payload was provided. NormalizingNoneoperands to emptyUsageDetailsand routing all inputs through a common merge and filter path ensures boolean and non-integer values are consistently skipped and logged regardless of operand position.Description & Review Guide
What are the major changes?
Normalized
Noneoperands toUsageDetails()inadd_usage_detailsand removed early return shortcuts, routing all inputs through the common merge path.Explicitly excluded
boolvalues alongside non-integers, logging a warning and skipping them.Added unit tests in
test_types.pycovering copy semantics and filtering when operands areNone.What is the impact of these changes?
Callers can no longer accidentally mutate input usage dictionaries in place, and boolean flags or non-integer metadata are consistently filtered out across all input combinations.
What do you want reviewers to focus on?
The unified normalization and merge path in
python/packages/core/agent_framework/_types.pyand test coverage intest_types.py.Related Issue
None
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.