Skip to content

Include prompt cache token counts in AgentOperator's usage XCom - #74277

Merged
pankajastro merged 2 commits into
apache:mainfrom
pankajastro:afl-340-cache-tokens-xcom
Oct 6, 2026
Merged

pankajastro merged 2 commits into
apache:mainfrom
pankajastro:afl-340-cache-tokens-xcom

Conversation

@pankajastro

Copy link
Copy Markdown
Member

input_tokens already includes tokens billed at the cache-read or cache-write price when cache_prompt is on (default), but the split was only visible in the task log. This pushes cache_read_tokens/cache_write_tokens in the usage XCom too, so downstream cost tracking can tell a cache-priced run from one billed at the plain input-token rate.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Sonnet 5)

Generated-by: Claude Code (Sonnet 5) following the guidelines

pankajastro and others added 2 commits October 6, 2026 10:54
input_tokens already includes tokens billed at the cache-read or
cache-write price when cache_prompt is on, but the split was only
visible in the task log. Push cache_read_tokens/cache_write_tokens
in the usage XCom too, so downstream cost tracking can tell a
cache-priced run from one billed at the plain input-token rate.

Co-Authored-By: Claude <[email protected]>
The prompt-caching doc section showed cache token counts in the task
log and GenAI span but didn't mention the usage XCom, the surface
added for cost tracking. Also drop a test that could not fail without
a logic change, since format_usage_for_xcom builds a flat dict literal
with no conditional on the cache-token keys.

Co-Authored-By: Claude <[email protected]>
@pankajastro
pankajastro force-pushed the afl-340-cache-tokens-xcom branch from 5c4c9a0 to c051bd6 Compare October 6, 2026 05:24
@pankajastro
pankajastro merged commit af61379 into apache:main Oct 6, 2026
85 checks passed
@pankajastro
pankajastro deleted the afl-340-cache-tokens-xcom branch October 6, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants