Move chat debug logging out of PromptsService#307142
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors prompt discovery debug logging by removing event-based discovery logging from PromptsService and instead having a workbench contribution (PromptsDebugContribution) pull cached discovery info and forward it to IChatDebugService. It also augments discovery results with duration metadata and threads request options through IChatService.onDidSubmitRequest.
Changes:
- Replace
IPromptsService.onDidLogDiscoverywithIPromptsService.getDiscoveryInfo(type, token)and adddurationInMillistoIPromptDiscoveryInfo. - Update
PromptsDebugContributionto log discovery info on chat request submission and enable richer event resolution (including duration). - Extend
IChatService.onDidSubmitRequestpayload to include requestoptions, and update affected tests/mocks.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.ts | Removes discovery log event API; adds durationInMillis and getDiscoveryInfo. |
| src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts | Stops emitting discovery events; records discovery durations; implements getDiscoveryInfo. |
| src/vs/workbench/contrib/chat/browser/promptsDebugContribution.ts | Switches from listening to service events to pulling discovery info on submit and logging via IChatDebugService. |
| src/vs/workbench/contrib/chat/common/chatService/chatService.ts | Expands onDidSubmitRequest event type to include options. |
| src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts | Fires onDidSubmitRequest with options. |
| src/vs/workbench/contrib/chat/common/chatDebugService.ts | Adds durationInMillis to resolved file-list debug event content. |
| src/vs/workbench/contrib/chat/test/browser/promptsDebugContribution.test.ts | Reworks tests to trigger logging via onDidSubmitRequest and assert duration propagation. |
| src/vs/workbench/contrib/chat/test/common/promptSyntax/service/promptsService.test.ts | Updates tests to use getDiscoveryInfo instead of discovery log events. |
| src/vs/workbench/contrib/chat/test/common/promptSyntax/service/mockPromptsService.ts | Updates mock to implement getDiscoveryInfo. |
Comments suppressed due to low confidence (3)
src/vs/workbench/contrib/chat/browser/promptsDebugContribution.ts:45
- This contribution now computes and logs discovery info on every chat submission (5
getDiscoveryInfocalls), regardless of whether Agent Debug Logs are enabled/being used. Previously, prompts discovery logging was caller-scoped viasessionResource. Please gate this work behind the debug-log enablement (e.g.AGENT_DEBUG_LOG_ENABLED_SETTING/ active debug panel), otherwise this adds unnecessary parsing/IO overhead to all chat requests.
this._register(chatService.onDidSubmitRequest(async chatRequest => {
const sessionResource = chatRequest.chatSessionResource;
const cts = new CancellationTokenSource();
try {
for (const promptType of [PromptsType.agent, PromptsType.instructions, PromptsType.prompt, PromptsType.skill, PromptsType.hook]) {
src/vs/workbench/contrib/chat/browser/promptsDebugContribution.ts:160
- In the hooks case,
hookCountfalls back toloadedCountwhenhooksInfois undefined. This produces incorrect messages when hooks are disabled/untrusted (it should be 0 hooks), and also misreports the file count inresolvedHooksWithSkippedby passingloadedCountto the "from {1} files" placeholder. Use an explicit 0 whenhooksInfois missing and use the total file count (e.g.discoveryInfo.files.length) for the "files" value.
case PromptsType.hook: {
const hookDiscoveryInfo = discoveryInfo as IHookDiscoveryInfo;
const hookCount = hookDiscoveryInfo.hooksInfo
? Object.values(hookDiscoveryInfo.hooksInfo.hooks).reduce((total, hooks) => total + hooks.length, 0)
: loadedCount;
const details = skippedCount > 0
? localize('promptsDebugContribution.resolvedHooksWithSkipped', 'Resolved {0} hooks from {1} files in {2}ms, skipped {3}', hookCount, loadedCount, durationInMillis, skippedCount)
: hookCount === 1
? localize('promptsDebugContribution.resolvedHook', 'Resolved {0} hook in {1}ms', hookCount, durationInMillis)
: localize('promptsDebugContribution.resolvedHooks', 'Resolved {0} hooks in {1}ms', hookCount, durationInMillis);
src/vs/workbench/contrib/chat/browser/promptsDebugContribution.ts:190
_resolveDiscoveryEventreturnserrorMessagefrom prompt discovery results verbatim. Parse errors can include sensitive information and this was previously handled via redaction (sanitizePromptDiscoveryInfo). Consider reintroducing redaction/sanitization before storingdiscoveryInfoin_discoveryEventDetailsand/or before returning it fromresolveChatDebugLogEvent, so debug logs don’t leak file content or other sensitive details.
return {
kind: 'fileList',
discoveryType: info.type,
durationInMillis: info.durationInMillis,
files: info.files.map(f => ({
uri: f.promptPath.uri,
name: f.promptPath.name,
status: f.status,
storage: f.promptPath.storage,
extensionId: f.promptPath.extension?.identifier.value,
skipReason: f.skipReason,
errorMessage: f.errorMessage,
duplicateOf: f.duplicateOf,
})),
pwang347
approved these changes
Apr 1, 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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This moves the logging of chat debug events out of the prompt service into the prompts debug contribution. The difference is that log events are now triggered on chat requests issued and no longer when the getter methods of the prompt service are used.
This will ensure that there is only one set of of discovery logs per request.
Also, now the computation time measured is the real time that was used to compute