Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates prompt discovery debug logging in the chat prompts service to avoid awaiting discovery info computation on the critical path, so agent/skill/hook/instruction resolution can return sooner while discovery details are collected asynchronously.
Changes:
- Make discovery-info collection fire-and-forget for custom agents, skills, hooks, and instruction files.
- Keep existing discovery log entries, but emit them after discovery info resolves.
Comments suppressed due to low confidence (3)
src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts:1201
- getHookDiscoveryInfo() is now executed without await, but the promise rejection isn’t handled. If it rejects (IO/JSON parse errors outside the inner try, or cancellation), this will produce an unhandled promise rejection. Add a rejection handler (ignore CancellationError, log others) to keep this safe.
void this.getHookDiscoveryInfo(token).then((discoveryInfo) => {
const details = hookCount === 1
? localize("promptsService.resolvedHook", "Resolved {0} hook in {1}ms", hookCount, elapsed.toFixed(1))
: localize("promptsService.resolvedHooks", "Resolved {0} hooks in {1}ms", hookCount, elapsed.toFixed(1));
this._onDidLogDiscovery.fire({
sessionResource,
name: localize("promptsService.loadHooks", "Load Hooks"),
details,
discoveryInfo,
category: 'discovery',
});
});
src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts:1222
- Fire-and-forget getInstructionsDiscoveryInfo() call doesn’t handle rejection. If listPromptFiles/_collectSourceFolderDiagnostics fails or the token is cancelled, this can create an unhandled promise rejection. Add a .catch (and ignore CancellationError) so discovery logging doesn’t destabilize the request path.
void this.getInstructionsDiscoveryInfo(token).then((discoveryInfo) => {
const details = result.length === 1
? localize("promptsService.resolvedInstruction", "Resolved {0} instruction in {1}ms", result.length, elapsed.toFixed(1))
: localize("promptsService.resolvedInstructions", "Resolved {0} instructions in {1}ms", result.length, elapsed.toFixed(1));
this._onDidLogDiscovery.fire({
sessionResource,
name: localize("promptsService.loadInstructions", "Load Instructions"),
details,
discoveryInfo,
category: 'discovery',
});
});
src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts:659
- These fire-and-forget discoveryInfo calls don’t handle rejections. If getAgentDiscoveryInfo() throws (e.g. listPromptFiles / diagnostics collection fails or token cancellation), this becomes an unhandled promise rejection and can surface as noisy errors or crash telemetry. Add a rejection handler (and consider ignoring CancellationError) so failures are logged/ignored and don’t go unobserved.
void this.getAgentDiscoveryInfo(token).then((discoveryInfo) => {
const details = result.length === 1
? localize("promptsService.resolvedAgent", "Resolved {0} agent in {1}ms", result.length, elapsed.toFixed(1))
: localize("promptsService.resolvedAgents", "Resolved {0} agents in {1}ms", result.length, elapsed.toFixed(1));
this._onDidLogDiscovery.fire({
sessionResource,
name: localize("promptsService.loadAgents", "Load Agents"),
details,
discoveryInfo,
category: 'discovery',
});
});
lramos15
approved these changes
Mar 10, 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.