Skip to content

Fix print TTFT message in debug. - #162

Open
aelissee wants to merge 1 commit into
google-gemini:mainfrom
aelissee:rebased
Open

Fix print TTFT message in debug.#162
aelissee wants to merge 1 commit into
google-gemini:mainfrom
aelissee:rebased

Conversation

@aelissee

Copy link
Copy Markdown
Collaborator

Small fix on the message for TTFT in debug.py: reset the TTFT for new calls.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request modifies genai_processors/debug.py to use a local variable message instead of mutating self._message directly, preventing the accumulation of TTFT suffixes across multiple calls. However, the reviewer noted that self._start and self._ttft are still not reset between calls, which can lead to incorrect TTFT calculations on subsequent calls, and suggested resetting them to None at the start of each call.

Comment thread genai_processors/debug.py
content: processor.ProcessorStream,
) -> AsyncIterable[ProcessorPartTypes]:
first_part = True
message = self._message

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

While this change successfully prevents the self._message string from accumulating TTFT suffixes across multiple calls, the actual self._start and self._ttft state variables are still not reset between calls. Because self._start remains set from the previous call, any subsequent call to the same TTFTSingleStream instance will immediately compute an incorrect TTFT based on the previous call's end time. To fully fix this, self._start and self._ttft should be reset to None at the beginning of each call (for example, in the call method of TTFTSingleStream).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Nope, self._start is update in log_on_close which is always called before log_on_first, we're good here.

@aelissee
aelissee requested a review from kibergus June 30, 2026 11:57
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