AgentOps-AI / AgentOps-AI/agentops

[Bug]: AgentOps does not aggregate Google ADK Gemini token usage because ADK emits gen_ai.usage.input_tokens/output_tokens but AgentOps expects prompt_tokens/completion_tokens

Open
#1,418 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
5.8k
Forks
619
PR merge metrics
No merged PRs in 30d

Description

### Contact Details

k.kalidas@gmail.com

### 📦 Package Version

0.4.21

### 🎞️ Framework Version

google adk

### 🔎 Describe the Bug

AgentOps captures ADK Gemini LLM spans and latency correctly, but trace metrics show zero tokens and zero cost. The issue appears to be a token attribute naming mismatch. Google ADK emits token usage as gen_ai.usage.input_tokens and gen_ai.usage.output_tokens, while AgentOps appears to aggregate only gen_ai.usage.prompt_tokens, gen_ai.usage.completion_tokens, and gen_ai.usage.total_tokens. The ADK trace contains valid Gemini usage_metadata and non-zero token attributes, but AgentOps metrics ignore them.

**Details:**
Agent Framework: google-adk (Version: 2.1.0)
LLM : gemini-2.5-flash-lite
agentops (0.4.21)
Programming Language : Python 3.13

**In AgentOps SpanAttributes, token usage constants are defined as:**
LLM_USAGE_COMPLETION_TOKENS = "gen_ai.usage.completion_tokens"
LLM_USAGE_PROMPT_TOKENS = "gen_ai.usage.prompt_tokens"
LLM_USAGE_TOTAL_TOKENS = "gen_ai.usage.total_tokens"

**But ADK emits:**
gen_ai.usage.input_tokens
gen_ai.usage.output_tokens

**This creates a mismatch:**

ADK emits → gen_ai.usage.input_tokens
AgentOps expects → gen_ai.usage.prompt_tokens
ADK emits → gen_ai.usage.output_tokens
AgentOps expects → gen_ai.usage.completion_tokens

This appears to be why AgentOps trace metrics return zero tokens/cost

Please normalize input_tokens → prompt_tokens, output_tokens → completion_tokens, and compute total_tokens when absent.

[adk single invocation.json](https://github.com/user-attachments/files/29509009/adk.single.invocation.json)

### 🤝 Contribution

- [ ] Yes, I'd be happy to submit a pull request with these changes.
- [ ] I need some guidance on how to contribute.
- [x] I'd prefer the AgentOps team to handle this update.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.