Skip to content

fix(openai): include reasoning tokens reported outside completion_tokens - #13974

Merged
jbg merged 1 commit into
mainfrom
fix/openai-usage-reasoning-tokens
Dec 2, 2026
Merged

jbg merged 1 commit into
mainfrom
fix/openai-usage-reasoning-tokens

Conversation

@filipkujawa

@filipkujawa filipkujawa commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #13970.

openai::get_usage now folds reasoning_tokens (top-level or under completion_tokens_details) into output_tokens as total_tokens - prompt_tokens when prompt_tokens + completion_tokens + reasoning_tokens == total_tokens, so gateways like Databricks AI Gateway MLflow for Gemini no longer undercount output tokens and cost while standard OpenAI responses (where completion_tokens already includes reasoning) are unchanged.

Verified with unit tests in oi-kit-provider-types, clippy, and a live goose run against databricks_v2 system.ai.gemini-4-neon at medium thinking effort confirming input_tokens + output_tokens == total_tokens.

@filipkujawa
filipkujawa requested a review from a team as a code owner December 2, 2026 00:16
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T00:20:05.183003Z fe43892 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@filipkujawa
filipkujawa force-pushed the fix/openai-usage-reasoning-tokens branch from 9b4950b to fe43892 Compare December 2, 2026 00:19
@jbg
jbg requested review from jbg and removed request for lifeizhou-ap December 2, 2026 10:14
@jbg
jbg added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit bafcf88 Dec 2, 2026
44 checks passed
@jbg
jbg deleted the fix/openai-usage-reasoning-tokens branch December 2, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAI-compatible usage parser drops reasoning tokens reported outside completion_tokens

2 participants