Skip to content

chore: add cached tokens props into RabbitMQ agent message#4086

Open
forestileao wants to merge 1 commit intomainfrom
feat/add-cached-tokens-into-rabbit-mq-message
Open

chore: add cached tokens props into RabbitMQ agent message#4086
forestileao wants to merge 1 commit intomainfrom
feat/add-cached-tokens-into-rabbit-mq-message

Conversation

@forestileao
Copy link
Copy Markdown
Collaborator

Summary

  • Add cache_read_tokens and cache_write_tokens fields to the AgentRunFinishedMessage
    protobuf message (fields 7 and 8)
  • Propagate cached token counts through the AgentUsagePublisher protocol, UsagePublisher,
    and NoopUsagePublisher
  • Pass cache_read_tokens and cache_write_tokens from RunUsage to the RabbitMQ message
    in _record_usage

Why

Previously, total_tokens in pydantic_ai's RunUsage only includes input_tokens + output_tokens — cached tokens were tracked in the DB (update_run_usage) but never
published to the RabbitMQ usage message. This means the SaaS usage service had no visibility
into prompt caching costs.

Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
@superplanehq-integration
Copy link
Copy Markdown

👋 Commands for maintainers:

  • /sp start - Start an ephemeral machine (takes ~30s)
  • /sp stop - Stop a running machine (auto-executed on pr close)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants