fix: skip TPOT recording for non-streaming requests - #2167
Merged
Conversation
A non-streaming response arrives as a single body chunk, so the first-token and completion timestamps coincide and RecordRequestTPOT's validity check logged an error-level 'Request latency values are invalid for TPOT calculation' line on every non-streaming request. TPOT has no meaning without inter-token timing, so thread the existing modelServerStreaming flag through (mirroring RecordRequestTTFT) and skip recording silently for non-streaming responses. Fixes llm-d#2166 Signed-off-by: HipHoff <matt.d.hoffman@gmail.com>
HipHoff
force-pushed
the
fix-tpot-nonstreaming
branch
from
July 24, 2026 07:01
a4e5588 to
6d7e89c
Compare
Contributor
Author
|
/kind bug |
ahg-g
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind bug
What this PR does / why we need it:
For a non-streaming completion, the entire body arrives as one chunk —
FirstTokenTimestampis stamped on that chunk and coincides withResponseCompleteTimestamp, soRecordRequestTPOT's validity check (!complete.After(firstToken)) fires and logs an error-levelRequest latency values are invalid for TPOT calculationline on every non-streaming request (~24K lines/day at our modest production traffic, all at error severity — log-indexing cost plus real-error masking). The values aren't invalid; TPOT is simply undefined without inter-token timing.This PR threads the same
streamingflagRecordRequestTTFTalready takes intoRecordRequestTPOT(same parameter position), returning early — no metric, no log — when the response was not streamed:pkg/epp/metrics/metrics.go: addstreaming booltoRecordRequestTPOT; returnfalsebefore any computation when not streaming.pkg/epp/handlers/response.go: passreqCtx.modelServerStreamingat the sole call site.pkg/epp/metrics/metrics_test.go: existing cases updated tostreaming=true; new subtest asserting the non-streaming shape (complete == firstToken) is skipped without an error.go build ./pkg/epp/...andgo test ./pkg/epp/metrics/... ./pkg/epp/handlers/...pass.Which issue(s) this PR fixes:
Fixes #2166
Release note (write
NONEif no user-facing change):Disclosure: this PR was authored by Claude (Anthropic's AI assistant, via Claude Code) on behalf of @HipHoff, who reviewed and takes responsibility for the change.