Files
gemini-cli[bot] 88a12098d4 fix(core): prevent text duplication in AfterAgent hook prompt_response
Fixed a logic error in `Turn.getResponseText()` where all individual streaming chunks were being joined with a space. This lead to two issues:
1. Extra spaces between words/chunks in the output.
2. Massive duplication of the entire response text because the final consolidated response (yielded by some content generators or logic) was being joined with the individual chunks.

The new implementation uses a robust heuristic: if a chunk's text starts with the accumulated text so far, it is treated as a cumulative update and replaces the current buffer; otherwise, it is treated as a delta and appended. This handles delta chunks, cumulative chunks, and redundant consolidated responses gracefully.

Fixes #27030

cc @spencertang @mbleigh
2026-05-14 23:43:01 +00:00
..