Skip to content

Move chat debug logging out of PromptsService#307142

Merged
aeschli merged 7 commits into
mainfrom
aeschli/forward-hare-729
Apr 1, 2026
Merged

Move chat debug logging out of PromptsService#307142
aeschli merged 7 commits into
mainfrom
aeschli/forward-hare-729

Conversation

@aeschli
Copy link
Copy Markdown
Contributor

@aeschli aeschli commented Apr 1, 2026

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

Copilot AI review requested due to automatic review settings April 1, 2026 13:22
@aeschli aeschli enabled auto-merge (squash) April 1, 2026 13:22
@aeschli aeschli self-assigned this Apr 1, 2026
@aeschli aeschli requested a review from pwang347 April 1, 2026 13:23
Copy link
Copy Markdown
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 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.onDidLogDiscovery with IPromptsService.getDiscoveryInfo(type, token) and add durationInMillis to IPromptDiscoveryInfo.
  • Update PromptsDebugContribution to log discovery info on chat request submission and enable richer event resolution (including duration).
  • Extend IChatService.onDidSubmitRequest payload to include request options, 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 getDiscoveryInfo calls), regardless of whether Agent Debug Logs are enabled/being used. Previously, prompts discovery logging was caller-scoped via sessionResource. 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, hookCount falls back to loadedCount when hooksInfo is undefined. This produces incorrect messages when hooks are disabled/untrusted (it should be 0 hooks), and also misreports the file count in resolvedHooksWithSkipped by passing loadedCount to the "from {1} files" placeholder. Use an explicit 0 when hooksInfo is 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

  • _resolveDiscoveryEvent returns errorMessage from prompt discovery results verbatim. Parse errors can include sensitive information and this was previously handled via redaction (sanitizePromptDiscoveryInfo). Consider reintroducing redaction/sanitization before storing discoveryInfo in _discoveryEventDetails and/or before returning it from resolveChatDebugLogEvent, 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,
			})),

Comment thread src/vs/workbench/contrib/chat/browser/promptsDebugContribution.ts Outdated
@aeschli aeschli merged commit fdaa8c8 into main Apr 1, 2026
19 checks passed
@aeschli aeschli deleted the aeschli/forward-hare-729 branch April 1, 2026 18:54
@vs-code-engineering vs-code-engineering Bot added this to the 1.115.0 milestone Apr 1, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators May 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants