Repository navigation
Conversation
WendeelMarinho
force-pushed
the
fix/util-genai-remote-agent-zero-cache
branch
from
November 28, 2026 16:25
87be1f6 to
872ee60
Compare
Pull request dashboard statusMerged · refreshed 2026-11-29 01:11 UTC Status above doesn't look right?
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change to omit zero-valued cache token attributes from remote agent spans.
No open issues 🎉
What changed in this PR
Fixes shared GenAI utilities so remote agent invocation spans omit zero-valued cache token attributes, matching inference span behavior.
Changes:
- Emit cache-read and cache-write token attributes only when non-zero.
- Add a regression test verifying that zero cache counts are omitted while ordinary input-token usage is preserved.
- Document the user-visible fix in the changelog.
| File | Description |
|---|---|
| util/opentelemetry-util-genai/tests/test_handler_agent.py | Adds regression coverage for zero cache token omission. |
| util/opentelemetry-util-genai/src/opentelemetry/util/genai/_agent_invocation.py | Omits zero-valued cache token attributes from remote agent spans. |
| util/opentelemetry-util-genai/.changelog/1141.fixed | Documents the corrected span behavior. |
Review effort: Balanced
lmolkova
approved these changes
Nov 29, 2026
Co-authored-by: Liudmila Molkova <[email protected]>
lmolkova
approved these changes
Nov 29, 2026
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.
Remote agent invocation spans emitted
gen_ai.usage.cache_read.input_tokensandcache_write.input_tokenseven when they were 0. The spec only recommends them "when available and non-zero" (since #548), and inference spans already drop zeros withor None. This happens in practice: google-genai's Interactions API copiestotal_cached_tokens, which is 0 in every recorded cassette.Type of change
How has this been tested?
py311-test-util-genai: 819 passed; the newtest_zero_cache_token_attributes_omittedfails without the fixcheck-util-api: OKChecklist