google / google/adk-python

Live Mode is missing usage_metadata and telemetry tracing

Đang mở
#2,323 5 bình luận 2 reaction 1 người được giao Được @allen-stephen nhận Xem trên GitHub
live needs review
Ngôn ngữ chính
Python
Star
21.5k
Fork
4k
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
37

Mô tả

**Describe the bug**
When using ADK with Gemini Live API, the `usage_metadata` field is always `None` in Event objects, making it impossible to track token usage for cost monitoring and observability. Additionally, telemetry tracing doesn't work properly for live events, with token usage data being lost instead of creating individual spans for each event.

**To Reproduce**
Steps to reproduce the behavior:
1. Install `google-adk`
2. Create a voice agent using `gemini-live-2.5-flash` model:
```python
from google.adk.agents import Agent
agent = Agent(
name="voice_assistant_agent",
model="gemini-live-2.5-flash", # or any other live model
tools=[some_tool]
)
```
3. Run the agent and process live events:
```python
async for event in live_events:
print(f"Usage metadata: {event.usage_metadata}") # Always None
```
4. CheckOpenTelemetry traces for token usage
5. Observe that token usage is not tracked in telemetry spans

**Expected behavior**
- `event.usage_metadata` should contain actual token usage data from the Gemini Live API response
- Each live event should create a separate OpenTelemetry span with token usage metrics (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.usage.total_tokens`)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.