Skip to content

fix(openai-agents): Record reasoning tokens as metric - #2805

Merged
Abhijeet Prasad (AbhiPrasad) merged 2 commits into
braintrustdata:mainfrom
dylanpulver:deep/openai-agents-reasoning-tokens
Nov 18, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 2 commits into
braintrustdata:mainfrom
dylanpulver:deep/openai-agents-reasoning-tokens

Conversation

@dylanpulver

Copy link
Copy Markdown
Contributor

The Agents SDK's response span carries usage.output_tokens_details.reasoning_tokens, and parseUsageMetrics in the trace processor never read it, so agent LLM spans had no completion_reasoning_tokens. The OpenAI wrapper already records it from the same usage shape (parseMetricsFromUsage in js/src/openai-utils.ts), and #2393 did the same for LangChain.

Zero is recorded, not dropped, matching prompt_cached_tokens: 0 in the existing snapshots. Snapshot churn is 8 added lines, all completion_reasoning_tokens, both sides of each span-tree pair, no cassette changes.

Ran the instrumentation test file (the new test fails on main on its assertion), check:typings, formatting, lint, and the openai-agents e2e scenario twice. Not run: the full unit and e2e suites.

@AbhiPrasad

Copy link
Copy Markdown
Member

thanks for the PR Dylan Pulver (@dylanpulver)!

@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit d0207e3 into braintrustdata:main Nov 18, 2026
56 checks passed
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.

2 participants