Skip to content

fix(openai): preserve the GPT Live cumulative usage watermark - #7231

Open
kiwijuicer wants to merge 2 commits into
livekit:mainfrom
kiwijuicer:norbert/fix-gpt-live-usage-watermark
Open

fix(openai): preserve the GPT Live cumulative usage watermark#7231
kiwijuicer wants to merge 2 commits into
livekit:mainfrom
kiwijuicer:norbert/fix-gpt-live-usage-watermark

Conversation

@kiwijuicer

@kiwijuicer kiwijuicer commented Sep 11, 2026

Copy link
Copy Markdown

GPT Live usage is cumulative, but every report currently replaces the watermark on upstream. Reports of 10, 8, and 12 seconds produce deltas of 10, 0, and 4 seconds, overcounting usage. Invalid values can also contaminate later metrics or prevent the final close event from acknowledging shutdown.

Advance the watermark only for finite, nonnegative numeric durations strictly greater than the previous total. Validate raw usage before OpenAI's event constructor coerces values: oversized integers otherwise raise during conversion, and booleans can become numeric durations. Invalid usage is ignored while the enclosing session.closed event still completes its acknowledgement. The original event payload is preserved.

Regression coverage includes duplicate/regressive reports, malformed and non-finite values, oversized positive and negative integers, boolean coercion, and final-close usage. The GPT Live and duplex adapter suites pass (114 tests), as does make check.

@kiwijuicer
kiwijuicer requested a review from a team as a code owner September 11, 2026 13:14
devin-ai-integration[bot]

This comment was marked as resolved.

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.

1 participant