Skip to content

implement vscode_askQuestions tool in core - #296135

Merged
Megan Rogge (meganrogge) merged 8 commits into
mainfrom
merogge/questions-core
Feb 19, 2026
Merged

Megan Rogge (meganrogge) merged 8 commits into
mainfrom
merogge/questions-core

Conversation

@meganrogge

@meganrogge Megan Rogge (meganrogge) commented Feb 18, 2026 •

Copy link
Copy Markdown
Collaborator

fixes #291349

Tested by setting github.copilot.chat.askQuestions.enabled: false

Follow-ups here #296134 as some things in chat depend upon it

cc Karthik Nadig (@karthiknadig)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 implements the vscode_askQuestions tool in VS Code core, moving it from extension-based implementation. The tool allows agents to ask structured clarifying questions (single-select, multi-select, or freeform) before proceeding with tasks. This addresses tight coupling issues with the UI and "stream" concept mentioned in issue #291349.

Changes:

  • Added AskQuestionsTool implementation with support for question carousels, answer conversion, validation, and telemetry
  • Extended IChatService with findRequestById method to locate requests across sessions
  • Updated UI components to recognize both the new vscode_askQuestions and legacy copilot_askQuestions tool IDs for backward compatibility

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/vs/workbench/contrib/chat/common/tools/builtinTools/askQuestionsTool.ts Core implementation of the AskQuestionsTool with schema definition, question carousel conversion, answer parsing logic, and telemetry
src/vs/workbench/contrib/chat/test/common/tools/builtinTools/askQuestionsTool.test.ts Comprehensive unit tests for the answer conversion logic covering all question types and edge cases
src/vs/workbench/contrib/chat/common/tools/builtinTools/tools.ts Registration of AskQuestionsTool with the language model tools service and agent tool set
src/vs/workbench/contrib/chat/common/tools/builtinTools/runSubagentTool.ts Exclusion of both old and new ask questions tool IDs from subagent mode tools
src/vs/workbench/contrib/chat/common/chatService/chatService.ts Added findRequestById interface method for locating requests by ID across sessions
src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts Implementation of findRequestById that searches all session models
src/vs/workbench/contrib/chat/test/common/chatService/mockChatService.ts Added mock implementations of findRequestById and getLatestRequest for tests
src/vs/workbench/contrib/chat/test/browser/agentSessions/localAgentSessionsController.test.ts Added mock implementations of findRequestById and getLatestRequest for tests
src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts Updated to check for both old and new tool IDs when determining whether to pin tool invocations
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolProgressPart.ts Updated to check for both old and new tool IDs when rendering progress content
Comments suppressed due to low confidence (4)

src/vs/workbench/contrib/chat/test/browser/agentSessions/localAgentSessionsController.test.ts:115

  • The getLatestRequest method appears to be unused and is not part of the IChatService interface. This method should be removed from the mock service unless it's needed for a specific test case. If it was used during development but is no longer needed, it should be cleaned up.
	getLatestRequest(): IChatRequestModel | undefined {
		return undefined;
	}

src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatToolProgressPart.ts:108

  • Consider importing and using the AskQuestionsToolId constant from askQuestionsTool.ts instead of using the string literal 'vscode_askQuestions'. This would improve maintainability by having a single source of truth for the tool ID. The old 'copilot_askQuestions' ID should continue to use a string literal for backward compatibility with serialized data, but the new ID should use the constant.
		const isAskQuestionsTool = this.toolInvocation.toolId === 'copilot_askQuestions' || this.toolInvocation.toolId === 'vscode_askQuestions';

src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts:1473

  • Consider importing and using the AskQuestionsToolId constant from askQuestionsTool.ts instead of using the string literal 'vscode_askQuestions'. This would improve maintainability by having a single source of truth for the tool ID. The old 'copilot_askQuestions' ID should continue to use a string literal for backward compatibility with serialized data, but the new ID should use the constant.
		const isAskQuestionsTool = (part.kind === 'toolInvocation' || part.kind === 'toolInvocationSerialized') && (part.toolId === 'copilot_askQuestions' || part.toolId === 'vscode_askQuestions');

src/vs/workbench/contrib/chat/test/common/chatService/mockChatService.ts:55

  • The getLatestRequest method appears to be unused and is not part of the IChatService interface. This method should be removed from the mock service unless it's needed for a specific test case. If it was used during development but is no longer needed, it should be cleaned up.
	getLatestRequest(): IChatRequestModel | undefined {
		return undefined;
	}

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (6)

src/vs/workbench/contrib/chat/common/tools/builtinTools/askQuestionsTool.ts:193

  • The schema/documentation requires header to be unique, but the implementation doesn’t validate this. Duplicate headers will overwrite entries in answers and can cause incorrect results. Add a validation step (ideally in prepareToolInvocation) that rejects duplicate header values.
		for (const question of questions) {
			if (question.options && question.options.length === 1) {
				throw new Error(localize('askQuestionsTool.invalidOptions', 'Question "{0}" must have at least two options, or none for free text input.', question.header));
			}
		}

src/vs/workbench/contrib/chat/common/tools/builtinTools/askQuestionsTool.ts:276

  • answers is built as a plain object and indexed by question.header, which is tool input. Using special keys like __proto__/constructor can lead to prototype pollution or surprising behavior. Consider using Object.create(null) (or a Map) for answers/skippedAnswers to avoid prototype-key issues before stringifying.
	protected convertCarouselAnswers(questions: IQuestion[], carouselAnswers: Record<string, unknown> | undefined): IAnswerResult {
		const result: IAnswerResult = { answers: {} };

		if (carouselAnswers) {

src/vs/workbench/contrib/chat/test/common/tools/builtinTools/askQuestionsTool.test.ts:33

  • This test suite already uses ensureNoDisposablesAreLeakedInTestSuite() and registers tool in that store, which disposes it automatically in the suite teardown. The explicit tool?.dispose() in teardown is redundant and can be removed to reduce noise.
	teardown(() => {
		tool?.dispose();
	});

src/vs/workbench/contrib/chat/test/common/chatService/mockChatService.ts:52

  • This mock generally throws for unimplemented IChatService methods; returning undefined here can hide unexpected calls and make failures harder to diagnose. Consider throwing new Error('Method not implemented.') (or implementing it) to keep mock behavior consistent and fail fast if the method is used.
	getLatestRequest(): IChatRequestModel | undefined {
		return undefined;
	}

src/vs/workbench/contrib/chat/test/browser/agentSessions/localAgentSessionsController.test.ts:111

  • This is a stub implementation that always returns undefined. If getLatestRequest is expected to be used by the code under test, consider either implementing it to return the latest request from sessions or throwing to fail fast when called unexpectedly.
	getLatestRequest(): IChatRequestModel | undefined {
		return undefined;
	}

src/vs/workbench/contrib/chat/common/tools/builtinTools/askQuestionsTool.ts:293

  • convertCarouselAnswers logs the raw answer value for each question (including freeform text) with trace. This may capture sensitive user input in logs. Please remove/redact answer values in logs (e.g. log only the question header and the answer shape or whether it was skipped).
			const answer = carouselAnswers[question.header];
			this.logService.trace(`[AskQuestionsTool] Processing question "${question.header}", raw answer: ${JSON.stringify(answer)}, type: ${typeof answer}`);

@roblourens roblourens left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, thanks for the edits

@meganrogge
Megan Rogge (meganrogge) merged commit 92e2edc into main Feb 19, 2026
18 checks passed
@meganrogge
Megan Rogge (meganrogge) deleted the merogge/questions-core branch February 19, 2026 18:25
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Apr 5, 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.

Move ask_questions tool implementation into VS Code core

5 participants