Skip to content

refactor(openai): Split token counting by API for easier deprecation#5930

Merged
ericapisani merged 10 commits into
masterfrom
ep/py-2271-refactor-openai-token-counting-8y2
Apr 2, 2026
Merged

refactor(openai): Split token counting by API for easier deprecation#5930
ericapisani merged 10 commits into
masterfrom
ep/py-2271-refactor-openai-token-counting-8y2

Merge branch 'master' into ep/py-2271-refactor-openai-token-counting-8y2

e6cdb18
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden completed Apr 2, 2026 in 3m 48s

1 issue

Medium

Missing manual output token counting for non-streaming Responses API - `sentry_sdk/integrations/openai.py:291-295`

_calculate_responses_token_usage only manually counts output tokens when streaming_message_responses is provided (lines 292-295). Unlike _calculate_completions_token_usage which falls back to counting from response.choices (lines 220-223), this function lacks equivalent logic to extract and count tokens from response.output. For non-streaming Responses API calls that don't include usage data, output tokens will remain 0.

4 skills analyzed
Skill Findings Duration Cost
code-review 1 1m 59s $1.30
find-bugs 0 3m 43s $2.74
skill-scanner 0 1m 3s $0.28
security-review 0 2m 40s $0.35

Duration: 9m 24s · Tokens: 3.7M in / 35.1k out · Cost: $4.68 (+extraction: $0.00, +dedup: $0.00)