Skip to content

feat(models): preserve raw usage payloads - #4279

Merged
seratch merged 1 commit into
mainfrom
feat/preserve-raw-usage
Aug 7, 2026
Merged

feat(models): preserve raw usage payloads#4279
seratch merged 1 commit into
mainfrom
feat/preserve-raw-usage

Conversation

@seratch

@seratch seratch commented Aug 7, 2026

Copy link
Copy Markdown
Member

This pull request adds opt-in preservation of raw provider usage payloads on completed ModelResponse objects so callers can distinguish omitted usage fields from values explicitly reported as zero or null.

  • Adds ModelSettings.preserve_raw_usage and ModelResponse.raw_usage.
  • Captures JSON-compatible usage snapshots before Agents SDK normalization across native OpenAI, AnyLLM, and LiteLLM streaming and non-streaming paths.
  • Keeps normalized Usage, provider request behavior, tracing, and RunState persistence unchanged.
  • Documents the opt-in behavior and its completed-response boundary.

Resolves #4270

@seratch seratch added this to the 0.20.x milestone Aug 7, 2026
@seratch
seratch force-pushed the feat/preserve-raw-usage branch from b60a1f2 to de66303 Compare August 7, 2026 09:58

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de663036cc

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/extensions/models/litellm_model.py Outdated
@seratch
seratch force-pushed the feat/preserve-raw-usage branch from de66303 to c69f4aa Compare August 7, 2026 10:14
@seratch
seratch merged commit 0c60a19 into main Aug 7, 2026
10 checks passed
@seratch
seratch deleted the feat/preserve-raw-usage branch August 7, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add opt-in for preserving the raw usage data in model response

1 participant