KEMBAR78
tools: add postapproval step for tool calls by connor4312 · Pull Request #272628 · microsoft/vscode · GitHub
Skip to content

Conversation

@connor4312
Copy link
Member

Closes #270618

@connor4312 connor4312 marked this pull request as ready for review October 22, 2025 15:22
@Copilot Copilot AI review requested due to automatic review settings October 22, 2025 15:22
@connor4312 connor4312 enabled auto-merge (squash) October 22, 2025 15:22
Copy link
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 adds a post-execution approval step for tool calls, allowing users to review and approve tool results before they are sent to the language model. This is particularly useful for tools marked with openWorldHint that may return sensitive or extensive data.

Key Changes:

  • Added confirmResults flag to IToolConfirmationMessages for post-execution confirmation
  • Introduced new state WaitingForPostApproval in tool invocation lifecycle
  • Created separate storage for pre-execution and post-execution auto-confirmation settings
  • Implemented UI for reviewing tool output before sending to the model

Reviewed Changes

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

Show a summary per file
File Description
mcpLanguageModelToolContribution.ts Updated MCP tool confirmation logic to use separate pre/post confirmation flags based on tool annotations
languageModelToolsService.ts Made confirmation messages optional and added confirmResults flag for post-execution approval
chatService.ts Added WaitingForPostApproval state and helper functions for post-execution confirmation workflow
chatProgressTypes/chatToolInvocation.ts Refactored completion logic to handle post-approval state and serialize skipped results
languageModelToolsService.ts (browser) Implemented post-execution confirmation flow with separate storage and auto-confirmation handling
chatToolPostExecuteConfirmationPart.ts New UI component for displaying and approving tool results before sending to model
abstractToolConfirmationSubPart.ts New base class abstracting common confirmation widget functionality
chatToolConfirmationSubPart.ts Refactored to use base class and support conditional result review
chatToolOutputContentSubPart.ts Extracted reusable component for rendering tool output with code blocks and resources
chatToolInputOutputContentPart.ts Refactored to use the extracted output subpart component
mockLanguageModelToolsService.ts Added mock implementation for new post-execution confirmation methods
languageModelToolsService.test.ts Removed tests for deprecated auto-confirmation methods

Comment on lines +81 to +83
{ label: localize('allowSession', 'Allow Without Review in this Session'), data: ConfirmationOutcome.AllowSession, tooltip: localize('allowSessionTooltip', 'Allow results from this tool to be sent without confirmation in this session.') },
{ label: localize('allowWorkspace', 'Allow Without Review in this Workspace'), data: ConfirmationOutcome.AllowWorkspace, tooltip: localize('allowWorkspaceTooltip', 'Allow results from this tool to be sent without confirmation in this workspace.') },
{ label: localize('allowGlobally', 'Always Allow Without Review'), data: ConfirmationOutcome.AllowGlobally, tooltip: localize('allowGloballyTooltip', 'Always allow results from this tool to be sent without confirmation.') },
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

These action definitions are duplicated from chatToolConfirmationSubPart.ts (lines 89-91). Consider extracting these common action definitions into a shared constant or helper function to avoid duplication and ensure consistency.

Copilot uses AI. Check for mistakes.

@@ -0,0 +1,267 @@
/*---------------------------------------------------------------------------------------------
Copy link
Member Author

Choose a reason for hiding this comment

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

This file is a mostly literal move from chatToolInputOutputContentPart.ts, doesn't need granular review

@vs-code-engineering vs-code-engineering bot added this to the October 2025 milestone Oct 22, 2025
@connor4312 connor4312 merged commit 9b98fab into main Oct 22, 2025
28 checks passed
@connor4312 connor4312 deleted the connor4312/tool-postapproval branch October 22, 2025 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make approval for read tools happen after rather than before the tool call

3 participants