Support markdown fallback in agent debug panel#301634
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors chat debug event rendering to centralize formatting + syntax-highlighting logic for tool call, message, and model turn sections, and expands tokenization to cover non-JSON content using markdown tokenization.
Changes:
- Introduces a shared
tokenizeContenthelper that pretty-prints JSON and otherwise tokenizes as markdown. - Updates tool call, user/agent message, and model turn renderers to reuse the helper and remove duplicated JSON/tokenization logic.
- Adjusts imports accordingly (removes direct
tokenizeToStringusage from call sites).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugToolCallContentRenderer.ts |
Adds tokenizeContent helper and uses it for tool call input/output sections. |
src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugModelTurnContentRenderer.ts |
Switches section rendering to use tokenizeContent instead of inline JSON parsing/tokenization. |
src/vs/workbench/contrib/chat/browser/chatDebug/chatDebugMessageContentRenderer.ts |
Switches prompt/response/resolve section rendering to use tokenizeContent instead of inline JSON parsing/tokenization. |
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
135
to
142
| if (content.input) { | ||
| const result = tryParseJSON(content.input); | ||
| const plainText = result.isJSON ? JSON.stringify(result.parsed, null, 2) : content.input; | ||
| const tokenizedHtml = result.isJSON | ||
| ? await tokenizeToString(languageService, plainText, 'json') | ||
| : undefined; | ||
| const { plainText, tokenizedHtml } = await tokenizeContent(content.input, languageService); | ||
| renderSection(sectionsContainer, localize('chatDebug.toolCall.arguments', "Arguments"), plainText, tokenizedHtml, disposables, false, clipboardService); | ||
| } | ||
|
|
||
| if (content.output) { | ||
| const result = tryParseJSON(content.output); | ||
| const plainText = result.isJSON ? JSON.stringify(result.parsed, null, 2) : content.output; | ||
| const tokenizedHtml = result.isJSON | ||
| ? await tokenizeToString(languageService, plainText, 'json') | ||
| : undefined; | ||
| const { plainText, tokenizedHtml } = await tokenizeContent(content.output, languageService); | ||
| renderSection(sectionsContainer, localize('chatDebug.toolCall.output', "Output"), plainText, tokenizedHtml, disposables, false, clipboardService); |
Comment on lines
82
to
86
|
|
||
| for (const section of content.sections) { | ||
| const result = tryParseJSON(section.content); | ||
| const plainText = result.isJSON ? JSON.stringify(result.parsed, null, 2) : section.content; | ||
| const tokenizedHtml = result.isJSON | ||
| ? await tokenizeToString(languageService, plainText, 'json') | ||
| : undefined; | ||
| const { plainText, tokenizedHtml } = await tokenizeContent(section.content, languageService); | ||
| renderSection(sectionsContainer, section.name, plainText, tokenizedHtml, disposables, false, clipboardService); | ||
| } |
Comment on lines
30
to
36
| DOM.append(sectionsContainer, $('div.chat-debug-message-sections-label', undefined, | ||
| localize('chatDebug.promptSections', "Prompt Sections ({0})", event.sections.length))); | ||
|
|
||
| for (const section of event.sections) { | ||
| const result = tryParseJSON(section.content); | ||
| const plainText = result.isJSON ? JSON.stringify(result.parsed, null, 2) : section.content; | ||
| const tokenizedHtml = result.isJSON | ||
| ? await tokenizeToString(languageService, plainText, 'json') | ||
| : undefined; | ||
| const { plainText, tokenizedHtml } = await tokenizeContent(section.content, languageService); | ||
| renderSection(sectionsContainer, section.name, plainText, tokenizedHtml, disposables, false, clipboardService); | ||
| } |
vijayupadya
approved these changes
Mar 14, 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.
No description provided.