Repository navigation
Python: [Python] Clarify optional usage counter handling - #9783
Open
LI (ktz03) wants to merge 1 commit into
Open
LI (ktz03) wants to merge 1 commit into
LI (ktz03) wants to merge 1 commit into
Conversation
LI (ktz03)
requested review from
SergeyMenshykh,
Eduard van Valkenburg (eavanvalkenburg),
Roger Barreto (rogerbarreto) and
westey (westey-m)
as code owners
October 28, 2026 07:31
LI (ktz03)
temporarily deployed
to
github-app-auth
October 28, 2026 07:31 — with
GitHub Actions
Inactive
LI (ktz03)
requested review from
Darren Cohen (dargilco),
Jose Alvarez (jpalvarezl) and
sophia-ramsey
as code owners
October 28, 2026 07:31
LI (ktz03)
temporarily deployed
to
github-app-auth
October 28, 2026 07:31 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for this documentation-only clarification of optional usage-counter handling.
No open issues 🎉
What changed in this PR
This documentation-only PR clarifies how add_usage_details handles optional usage counters in the Python SDK. Runtime behavior, signatures, and return types remain unchanged.
Changes:
- Documents that missing keys and
Nonevalues contribute zero. - Clarifies that other non-integer values, including booleans, cause the key to be skipped.
| File | Description |
|---|---|
python/packages/core/agent_framework/_types.py |
Updates the add_usage_details docstring to describe existing value handling. |
Review effort: Balanced
This branch was previously 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
The
add_usage_detailsdocstring says a key is skipped when either value is not an integer. Its existing implementation instead treatsNoneas zero, and the publicUsageDetailsfields allowint | None. For example, merging an input count ofNonewith3returns3; the current wording incorrectly suggests that key is skipped.Description & Review Guide
Nonecontribute zero, other non-integer values cause the key to be skipped, and booleans are skipped.Validation: four ordinary integer/optional/missing-key inputs passed against the exact extracted complete helper and real
UsageDetailsdefinition both before and after the documentation change. Input dictionaries were preserved. Whole-file ASTs are identical after removing docstrings, and both versions parse with Python 3.10 syntax. Ruff 0.17.1 single-file lint and format checks passed using the current repository configuration and the unchanged package marker. The initial missing-package-marker INP001 diagnostic was retained locally; supplying the real unchanged marker resolved the frozen-layout issue without disabling a rule.These are local Windows checks with an existing interpreter and dependency set. Full SDK import, provider calls, services, package builds, the full test suite and official CI were not run. The existing runtime already handles these inputs correctly.
Related Issue
N/A - trivial change. This is an obvious correction of existing documentation to match the already-implemented handling of optional values and booleans. It introduces no behavior or design change. A search for an open PR covering
add_usage_detailsandNonefound none.AI Assistance
AI assistance details: AI assisted the documentation correction, source comparison, local validation and this PR description. The accountable human has reviewed this contribution and its validation materials. No personal execution of the automated checks is claimed.
Contribution Checklist