Skip to content

feat: add ReasoningToken as LLMRequestCostType#1913

Open
mtparet wants to merge 3 commits intoenvoyproxy:mainfrom
blackfuel-ai:add-reasoning-token-cost-type
Open

feat: add ReasoningToken as LLMRequestCostType#1913
mtparet wants to merge 3 commits intoenvoyproxy:mainfrom
blackfuel-ai:add-reasoning-token-cost-type

Conversation

@mtparet
Copy link
Contributor

@mtparet mtparet commented Mar 3, 2026

Description

Add ReasoningToken as a 7th cost type to enable cost-based routing and rate limiting for reasoning tokens (used by OpenAI o1/o3, Gemini with thoughts, Claude with extended thinking).

@mtparet mtparet requested a review from a team as a code owner March 3, 2026 17:12
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 3, 2026
Copy link
Contributor

@aabchoo aabchoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add tests for translator?

@mtparet
Copy link
Contributor Author

mtparet commented Mar 5, 2026

I just added the tests @aabchoo

@codecov-commenter
Copy link

codecov-commenter commented Mar 8, 2026

Codecov Report

❌ Patch coverage is 67.50000% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.29%. Comparing base (98200a4) to head (bd49e45).

Files with missing lines Patch % Lines
internal/metrics/metrics.go 45.45% 5 Missing and 1 partial ⚠️
internal/metrics/metrics_impl.go 0.00% 4 Missing and 1 partial ⚠️
internal/extproc/processor_impl.go 50.00% 2 Missing ⚠️

❌ Your patch status has failed because the patch coverage (67.50%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1913      +/-   ##
==========================================
- Coverage   84.33%   84.29%   -0.04%     
==========================================
  Files         130      130              
  Lines       17987    18024      +37     
==========================================
+ Hits        15170    15194      +24     
- Misses       1873     1884      +11     
- Partials      944      946       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@aabchoo aabchoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please address the failing tests?

Add ReasoningToken as a 7th cost type to enable cost-based routing and
rate limiting for reasoning tokens (used by OpenAI o1/o3, Gemini with
thoughts, Claude with extended thinking).

Thread reasoning tokens through all layers: CRD API types, TokenUsage
struct, OTel metrics, filter config, CEL evaluation, cost calculation,
and translators (OpenAI chat/completions/responses, GCP Vertex AI).

Signed-off-by: Matthieu Paret <mp@blackfuel.ai>
@mtparet mtparet force-pushed the add-reasoning-token-cost-type branch 2 times, most recently from 5a04beb to cf58222 Compare March 12, 2026 11:43
Signed-off-by: Matthieu Paret <mp@blackfuel.ai>
@mtparet mtparet force-pushed the add-reasoning-token-cost-type branch from cf58222 to 175afcd Compare March 12, 2026 14:12
Copy link
Contributor

@aabchoo aabchoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, could you please avoid force-pushing your changes? It is hard to track what has changed when the commit history is forcibly changed.

Thank you for the contribution!

@mtparet
Copy link
Contributor Author

mtparet commented Mar 20, 2026

Yes of course, thanks @aabchoo

@aabchoo
Copy link
Contributor

aabchoo commented Mar 23, 2026

Could you please run make precommit @mtparet? That will resolve the failing checks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants