v0.9.2 — cost on the GenAI usage span
v0.9.2 — cost on the GenAI usage span
Tiny patch. The loop-level chat and agent.turn spans now record gen_ai.usage.cost when the provider reports a usage cost alongside token counts.
What's Changed
gen_ai.usage.cost on telemetry spans
ModelTurnEvent::Usage(usage), the streaming usage frame, and the buffered turn result all flow usage.cost.amount through to the relevant spans. Both span sites — the agent.turn outer span and the per-request chat {model} span — declare the field up front and record() it when present, matching how gen_ai.usage.input_tokens / output_tokens are handled.
// agentkit-loop/src/lib.rs
tracing::info_span!(
"agent.turn",
// ...
gen_ai.usage.input_tokens = tracing::field::Empty,
gen_ai.usage.output_tokens = tracing::field::Empty,
gen_ai.usage.cost = tracing::field::Empty,
)Providers that already populate Usage::cost (OpenRouter is the main one — generation prices come back on the streaming usage frame) now expose that number to OTel without any host code change.
Commits
- fix(loop): add cost otel (2ba148a)
Full Changelog: v0.9.1...v0.9.2