Repository navigation
fix(chat): preserve final answers after tool calls - #55
Closed
1052326311 wants to merge 7 commits into
Closed
1052326311 wants to merge 7 commits into
1052326311 wants to merge 7 commits into
Conversation
1052326311
marked this pull request as ready for review
September 30, 2026 18:15
This was referenced Oct 1, 2026
Author
|
Superseded by #59, which consolidates this final-response fix with the related lifecycle/session repairs in one clean commit. Closing this duplicate to avoid overlapping merges. |
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.
Problem
A read-only request such as “inspect the project files, then describe the app” completes its tools but shows no visible answer. The final ordinary-text segment is provisionally stored as thinking, and the end-of-stream branch only promotes it when
hadToolCallsis false. A reproduced turn persisted zero content characters and 286 thinking characters.Change
Promote the final provisional ordinary-text segment after successful completion even when earlier segments invoked tools. Preserve explicit reasoning and tool-confirmed intermediate text, leave deferred-error segments alone, and use the existing
thinking_to_textSSE event. Remove the exact buffered segment instead of blindly trimming the thinking suffix. Preserve thinking markers until the channel router classifies them, and track complete-message catch-up offsets per SDK message so earlier reasoning cannot swallow a later non-streamed answer. Offsets use raw SDK text before sanitization, preventing repeated tails when a split term such aspackage.jsonexpands only in the complete message.Validation
src/index.tsandsrc/routes/preview-proxy/proxy-handler.ts(the affected source is unchanged from main); no changed reply module reports an error. This is not a clean full type-check.thinking_to_text,onDonefired, and the answer remained visible after reauthentication/history reload. The persisted record has 185 content characters, 26 reasoning characters, and tool calls; its final marker occurs once.No automatic history migration is included in this change.