Expose Codex service tiers for Langfuse pricing#34
Open
wallacelim wants to merge 1 commit into
Open
Conversation
|
|
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.
Context
Codex service tiers can change model pricing, but the tracing plugin currently drops the active tier. As a result, Langfuse cannot distinguish Standard, Fast/Priority, Flex, or catalog-defined tiers when inferring cost.
Codex records tier changes in
thread_settings_applied.service_tier. The first turn of a session may precede that event, so the plugin also needs a configuration fallback. Langfuse pricing-tier conditions operate on numeric usage details, while the raw tier remains useful as metadata.What this changes
config.tomlfor an initial turn whose rollout omits the tierservice_tier/LANGFUSE_CODEX_SERVICE_TIERfallback overridecodex.service_tiergeneration metadatacodex_service_tier_priority = 1The plugin does not hard-code provider prices, credit conversions, or organization-specific discounts. Each Langfuse project remains responsible for its own model rate cards.
Example
A Fast-mode rollout that reports
service_tier: "priority"emits:{ "metadata": { "codex.service_tier": "priority" }, "usageDetails": { "codex_service_tier_priority": 1 } }A custom model can select its higher-rate tier with a condition such as
^codex_service_tier_(fast|priority)$ > 0.Scope and PR split
This PR is intentionally independent of:
Those correctness/reliability changes should remain separately reviewable. The generated bundle is included because this repository requires committed build output.
Validation
corepack pnpm@9.5.0 test— 38 passingcorepack pnpm@9.5.0 run lint— Prettier, TypeScript, and generated-bundle checks pass