Skip to content

fix(pydantic-ai): prefer normalized reasoning token usage - #1011

Merged
Abhijeet Prasad (AbhiPrasad) merged 1 commit into
mainfrom
abhi/sdk-631-pydantic-ai-read-requestusageoutput_reasoning_tokens-for
Oct 26, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 1 commit into
mainfrom
abhi/sdk-631-pydantic-ai-read-requestusageoutput_reasoning_tokens-for

Conversation

@AbhiPrasad

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

🤖 This text was AI-generated.

Reasoning metrics relied on provider-specific usage.details keys. Providers
that expose only normalized usage could therefore lose reasoning counts.

before: usage.details[provider_key]
after:  usage.output_reasoning_tokens -> legacy details fallback

Read RequestUsage.output_reasoning_tokens first, preserving zero and using
the legacy keys when the field is missing or None. This keeps older
pydantic-ai versions supported.

Fixes #1005.
Linear: SDK-631

> 🤖 **This text was AI-generated.**

Reasoning metrics relied on provider-specific usage.details keys. Providers
that expose only normalized usage could therefore lose reasoning counts.

```text
before: usage.details[provider_key]
after:  usage.output_reasoning_tokens -> legacy details fallback
```

Read RequestUsage.output_reasoning_tokens first, preserving zero and using
the legacy keys when the field is missing or None. This keeps older
pydantic-ai versions supported.

Refs: https://linear.app/braintrustdata/issue/SDK-631
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T13:19:48.268928Z da75d2e PR opened
ℹ️ About Codex in GitHub

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

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

@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit 329926f into main Oct 26, 2026
98 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the abhi/sdk-631-pydantic-ai-read-requestusageoutput_reasoning_tokens-for branch October 26, 2026 15:35
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.

pydantic-ai: read RequestUsage.output_reasoning_tokens for reasoning metrics

1 participant