Skip to content

fix: normalize nullable Chat Completions token counts - #5238

Merged
jbeckwith-oai merged 1 commit into
mainfrom
codex/fix-null-chat-usage
Sep 29, 2026
Merged

jbeckwith-oai merged 1 commit into
mainfrom
codex/fix-null-chat-usage

Conversation

@jbeckwith-oai

Copy link
Copy Markdown
Collaborator

Summary

This pull request fixes valid non-streaming answers failing when an OpenAI-compatible provider returns null token counts. The OpenAI and AnyLLM Chat Completions adapters now normalize those counts to zero, matching streaming behavior while preserving supplied counts, token details, request accounting, and raw usage.

The change is limited to Chat Completions usage conversion; AnyLLM mapping validation and Responses handling are unchanged.

Test plan

  • Added 12 Runner-level regression cases covering each nullable count, all-null counts, valid counts, and absent usage.
  • Confirmed the new null-count cases fail before the fix.
  • Focused adapter and streaming tests: 273 passed.
  • Full repository verification: formatting, lint, mypy, pyright, and tests passed. Native macOS sandbox tests are skipped inside Codex per repository policy.
  • Independent review of the complete change.

Issue number

Closes #5229

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • If using Codex, I've run /review before submitting this PR

@jbeckwith-oai
jbeckwith-oai requested review from a team, rm-openai and seratch as code owners September 29, 2026 16:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 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-09-29T16:02:11.436187Z d6b52f9 PR opened
🔒 Security Review ✅ Completed 2026-09-29T16:03:11.090885Z d6b52f9 PR opened
ℹ️ 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.

@markstuart-oai markstuart-oai left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the complete diff at d6b52f9. No actionable findings. The two adapters normalize null token counts at their existing usage-conversion boundary, matching streaming while preserving supplied counts, token details, request accounting, and unmodified raw usage. The Runner-level regressions cover each null count, all-null counts, valid counts, and absent usage.

Verified all 23 hosted checks succeeded on this commit. This was a source and hosted-CI review; I did not run local tests.

@jbeckwith-oai
jbeckwith-oai merged commit 1ac6d82 into main Sep 29, 2026
23 checks passed
@jbeckwith-oai
jbeckwith-oai deleted the codex/fix-null-chat-usage branch September 29, 2026 16:22
@openai-sdks openai-sdks Bot mentioned this pull request Sep 29, 2026
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.

Non-streaming Chat Completions run fails when provider usage has null token counts (streaming handles it since #1179)

2 participants