Improved Usage Tracking#274
Merged
TonsOfFun merged 3 commits intoactiveagents:mainfrom Nov 20, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces normalized usage statistics across all providers (OpenAI, Anthropic, Ollama, and OpenRouter) by adding a unified Usage model. The changes enable consistent access to token usage statistics regardless of which provider is being used.
Key changes:
- Added comprehensive unit tests for provider transform modules to verify gem-to-hash conversions and parameter normalization
- Implemented
Usagemodel tests covering all provider formats with auto-detection capabilities - Added integration tests with VCR cassettes for all providers to validate response handling
- Updated documentation and added inline documentation for model classes
Reviewed Changes
Copilot reviewed 214 out of 216 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/providers/open_router/transforms_test.rb | Unit tests for OpenRouter-specific transforms including parameter extraction, serialization, and response format handling |
| test/providers/open_ai/responses/transforms_test.rb | Unit tests for OpenAI Responses API transforms covering input normalization, response format handling, and message simplification |
| test/providers/open_ai/embedding/transforms_test.rb | Unit tests for OpenAI Embedding transforms including input normalization, parameter handling, and serialization cleanup |
| test/providers/open_ai/chat/transforms_test.rb | Comprehensive unit tests for OpenAI Chat transforms covering message normalization, content handling, and instruction processing |
| test/providers/ollama/embedding/transforms_test.rb | Unit tests for Ollama Embedding transforms including Ollama-specific parameter extraction and input validation |
| test/providers/ollama/chat/transforms_test.rb | Unit tests for Ollama Chat transforms covering message grouping and Ollama-specific parameter handling |
| test/providers/common/usage_test.rb | Core unit tests for Usage model covering all provider formats, auto-detection, and field normalization |
| test/providers/anthropic/transforms_test.rb | Unit tests for Anthropic transforms covering message normalization, content handling, and response cleanup |
| test/integration/* | Integration tests with VCR cassettes validating real API response handling across all providers |
| test/fixtures/vcr_cassettes/* | VCR cassettes capturing real API responses for reliable integration testing |
| test/docs/providers/anthropic_examples_test.rb | Fixed assertion argument order to follow Minitest conventions |
| lib/active_agent/providers/open_router/requests/prediction.rb | Added comprehensive inline documentation for Prediction model |
| lib/active_agent/providers/open_router/requests/message.rb | Removed unused require statement |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
73106c7 to
f0ace9a
Compare
3dfd9fd to
2825f2c
Compare
fe978d9 to
1818c1c
Compare
1818c1c to
4d0268b
Compare
Contributor
Author
|
Took some back and fourth with New Relic Support, but I'm now able to confirm that these Notifications allow you to correctly hook into all the details that are needed for at least supporting New Relic's APM. |
Contributor
|
I have heard honey badger support too
…On Wed, Nov 19, 2025 at 5:42 PM Zane Pickett ***@***.***> wrote:
*sirwolfgang* left a comment (activeagents/activeagent#274)
<#274 (comment)>
Took some back and fourth with New Relic Support, but I'm now able to
confirm that these Notifications allow you to correctly hook into all the
details that are needed for at least supporting New Relic's APM.
—
Reply to this email directly, view it on GitHub
<#274 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG4S3DMGDPTRWZ5VNH7JKD35UL7JAVCNFSM6AAAAACL6DW4PSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKNJVGM4TAMRTGE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
superconductor-for-github Bot
pushed a commit
that referenced
this pull request
Feb 13, 2026
PR #274 (Improved Usage Tracking) introduced Usage#+ for combining statistics across multi-turn tool-calling conversations, but shipped without tests for this feature. This adds: - Basic addition combining two usage objects - Addition with nil optional fields - Addition with nil operand returns self - Chained addition simulating multi-turn accumulation cc @TheRealNeil Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is to improved usage tracking and instrumentation for cost monitoring and APM integration. The original instrumentation was a slop coded prototype, that didn't actually work in a way that is useful. This cuts it down and restructures it for APM integration while adding usage normalization.
Multi-Turn Usage Tracking
Cumulative token tracking across tool calling cycles:
Usage Statistics
Consistent token tracking across all providers:
Provider-specific fields:
reasoning_tokens,audio_tokens,cache_creation_tokens,service_tier,duration_msCombine usage objects:
APM Integration
Unified instrumentation events with comprehensive payloads:
Top-level events (overall request lifecycle):
Provider-level events (per API call):
Event payloads include:
model,temperature,max_tokens,top_p,stream,message_count,has_toolsinput_tokens,output_tokens,total_tokens,cached_tokens,reasoning_tokens,audio_tokens,cache_creation_tokensfinish_reason,response_model,response_id,embedding_countEmbedding events:
New response methods:
Breaking Change