Skip to content

fix(sessions): include compaction usage in run totals - #4446

Merged
seratch merged 1 commit into
mainfrom
fix/count-compaction-run-usage
Aug 15, 2026
Merged

seratch merged 1 commit into
mainfrom
fix/count-compaction-run-usage

Conversation

@seratch

@seratch seratch commented Aug 15, 2026

Copy link
Copy Markdown
Member

This pull request supersedes #4435 and fixes run-wide usage accounting for OpenAI Responses compaction. Automatic compaction now passes the current run wrapper only to the compaction method, converts the official response usage through the existing Responses usage pipeline, and records one request with its token details in result.context_wrapper.usage.

Legacy session history calls remain unscoped, and the public compaction-aware session protocol stays unchanged.

Fixes #4434

@seratch seratch added this to the 0.21.x milestone Aug 15, 2026
@seratch
seratch merged commit 583fede into main Aug 15, 2026
14 checks passed
@seratch
seratch deleted the fix/count-compaction-run-usage branch August 15, 2026 23:12
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.

Compaction tokens are billed but never counted: run usage omits every responses.compact call

1 participant