Skip to content

Fix final answer detection in markdown rendering logic#293746

Merged
justschen merged 2 commits intomicrosoft:mainfrom
tamuratak:fix_codeblock_rendering_in_final_response_b
Feb 15, 2026
Merged

Fix final answer detection in markdown rendering logic#293746
justschen merged 2 commits intomicrosoft:mainfrom
tamuratak:fix_codeblock_rendering_in_final_response_b

Conversation

@tamuratak
Copy link
Contributor

@tamuratak tamuratak commented Feb 8, 2026

This PR updates renderMarkdown to identify the final answer by finding content after the last pinned thinking or tool part, replacing the previous "last element" check. Fix #293700

Without this PR, codeblocks in the final response will be rendered in the lastThinking part.

cc: @justschen

Copilot AI review requested due to automatic review settings February 8, 2026 10:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes chat markdown rendering so the “final answer” portion is identified as the content after the last pinned thinking/tool-related part, instead of assuming it’s always the last content element. This addresses cases where the final message (e.g., a trailing code block) was incorrectly routed into the last thinking part and not rendered as expected.

Changes:

  • Update ChatListItemRenderer.renderMarkdown to compute a “final answer” region based on the last thinking/tool invocation content index.
  • Gate “final answer” detection to the final (non-progressive) render pass for completed responses.

Copy link
Collaborator

@justschen justschen left a comment

Choose a reason for hiding this comment

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

thanks, i saw this issue once or twice!

@vs-code-engineering vs-code-engineering bot added this to the February 2026 milestone Feb 9, 2026
DonJayamanne
DonJayamanne previously approved these changes Feb 9, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@justschen justschen left a comment

Choose a reason for hiding this comment

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

thanks @tamuratak

@justschen justschen enabled auto-merge (squash) February 15, 2026 06:39
@justschen justschen merged commit dfd7335 into microsoft:main Feb 15, 2026
17 checks passed
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.

The last code block in the chat is not rendered

5 participants