fix(telemetry): use per-invocation usage in agent span attributes#2017
fix(telemetry): use per-invocation usage in agent span attributes#2017mkmeral merged 5 commits intostrands-agents:mainfrom
Conversation
|
/strands review |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Assessment: Comment The fix correctly identifies and addresses the root cause from #2010 — Review Themes
|
|
@en-yao CI is failing, can you run |
|
Ran |
|
I see, @en-yao can you merge from main then? This is a required workflow, so we need it to be passing before merging |
|
actually no problem, i merged from main. once the CI passes, it will merge automatically. thank you for the contribution :) |
Description
In multi-turn sessions,
end_agent_spanreportsaccumulated_usage(session-lifetime cumulative tokens) instead of per-invocation usage, causing inflated token metrics in OTEL spans. The per-invocation usage is already tracked atresponse.metrics.latest_agent_invocation.usage— this PR pointsend_agent_spanto the correct field.Related Issues
Resolves #2010
Documentation PR
N/A
Type of Change
Bug fix
Testing
Updated existing agent span tests to distinguish between accumulated and per-invocation usage. Added dedicated tests verifying per-invocation values are reported and fallback behavior when no invocations exist.
hatch run prepareChecklist