Skip to content

Enhance Python environment configuration tools with optional interpreter path support for direct setup#25939

Draft
eleanorjboyd wants to merge 4 commits intomicrosoft:mainfrom
eleanorjboyd:technological-worm
Draft

Enhance Python environment configuration tools with optional interpreter path support for direct setup#25939
eleanorjboyd wants to merge 4 commits intomicrosoft:mainfrom
eleanorjboyd:technological-worm

Conversation

@eleanorjboyd
Copy link
Copy Markdown
Member

@eleanorjboyd eleanorjboyd commented Apr 28, 2026

fixes #25940

Co-authored-by: Copilot copilot@github.com

…ter path support for direct setup

Co-authored-by: Copilot <copilot@github.com>
@eleanorjboyd eleanorjboyd self-assigned this Apr 28, 2026
@eleanorjboyd eleanorjboyd requested a review from Copilot April 28, 2026 21:39
@eleanorjboyd eleanorjboyd added the bug Issue identified by VS Code Team member as probable bug label Apr 28, 2026
Copy link
Copy Markdown

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 enhances the Python environment configuration chat tools to optionally accept a pythonPath so the interpreter can be set directly (skipping interactive UI), which is particularly useful for autopilot/bypass-approvals flows.

Changes:

  • Add optional pythonPath support to configure_python_environment and selectEnvironment tools (plus input schema updates in package.json).
  • Wrap additional operations with raceCancellationError to better respect cancellation tokens.
  • Fix virtual environment resolution polling loop condition and adjust venv creation options.
Show a summary per file
File Description
src/client/chat/selectEnvTool.ts Adds pythonPath fast-path and wraps UI selection flows with cancellation handling.
src/client/chat/createVirtualEnvTool.ts Improves cancellation handling, tweaks venv creation options, and fixes the env-resolution polling loop condition.
src/client/chat/configurePythonEnvTool.ts Adds pythonPath argument + direct interpreter setup path, updates tool argument typing.
package.json Extends language model tool schemas/descriptions to document and accept pythonPath.

Copilot's findings

Comments suppressed due to low confidence (1)

src/client/chat/selectEnvTool.ts:87

  • After calling updateActiveEnvironmentPath, the code immediately calls getActiveEnvironmentPath()/resolveEnvironment(). updateActiveEnvironmentPath only updates configuration; the active environment change is asynchronous (see code that waits on onDidChangeActiveEnvironmentPath, e.g. venvSwitchPython.ts). This fast-path can therefore resolve and return details for the previous environment. Wait for this.api.onDidChangeActiveEnvironmentPath (matching pythonPath) or otherwise confirm the switch before resolving/returning environment details.
            await raceCancellationError(
                this.api.updateActiveEnvironmentPath(options.input.pythonPath, resource),
                token,
            );
            const env = await raceCancellationError(
                this.api.resolveEnvironment(this.api.getActiveEnvironmentPath(resource)),
                token,
            );
  • Files reviewed: 4/4 changed files
  • Comments generated: 3

Comment thread src/client/chat/configurePythonEnvTool.ts Outdated
Comment thread src/client/chat/createVirtualEnvTool.ts Outdated
Comment thread src/client/chat/selectEnvTool.ts
@eleanorjboyd eleanorjboyd added the skip tests Updates to tests unnecessary label May 6, 2026
@eleanorjboyd eleanorjboyd added skip package*.json package.json and package-lock.json don't both need updating labels May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug skip package*.json package.json and package-lock.json don't both need updating skip tests Updates to tests unnecessary

Projects

None yet

Development

Successfully merging this pull request may close these issues.

not requiring mcp tool user input

2 participants