Skip to content

MCP pylanceRunCodeSnippet timeout units are undocumented (milliseconds); timeout=0 causes immediate cancellation #7869

@AssortedFantasy

Description

@AssortedFantasy

I was using GPT 5.3 Codex and it keeps screwing up the pylanceRunCodeSnippet tool because it provides the
timeout option, I think the tool needs a better prompt.

Current prompt:

Description:
Execute Python code snippets directly in the workspace environment. PREFERRED over terminal commands for running Python code. This tool automatically uses the correct Python interpreter configured for the workspace, eliminates shell escaping/quoting problems that plague terminal execution, and provides clean, properly formatted output with stdout/stderr correctly interleaved. Use this instead of python -c "code" or terminal commands when running Python snippets. Ideal for: testing code, running quick scripts, validating Python expressions, checking imports, and any Python execution within the workspace context. No temporary files needed - code runs directly in memory.

Parameters:

workspaceRoot (string): The root directory uri of the workspace.
codeSnippet (string): The code snippet to run.
workingDirectory (string, optional): The working directory to use for the code snippet. If the code snippet is pulled from a file, this should be the directory for the file. Especially if the snippet has imports.
timeout (number, optional): The timeout for the code snippet execution. minimum: 0.0

Note the prompt just says timeout is number, which causes problems.

Environment data

  • Pylance version: 1.16.0
  • OS and version: Linux (Ubuntu 24.04)
  • Python version (CPython 3.12 UV)

Code Snippet

print("hello")

Repro Steps

  1. Use the Pylance MCP server pylanceRunCodeSnippet method with:
    • workspaceRoot: /home/jehan/ml_experiments/
    • codeSnippet: print("hello")
    • timeout: 10
  2. Observe the request is cancelled.
  3. Run the same request again with no timeout field (or with timeout=30000).
  4. Observe it succeeds.

Expected behavior

  • Timeout units for pylanceRunCodeSnippet should be clearly documented.
  • It should be explicit that timeout is in milliseconds.
  • It should be explicit that timeout=0 means immediate cancel, not “no timeout”.
  • Ideally, cancellation/error text should hint when timeout is likely too small.

Actual behavior

  • With small timeout values like 10, request returns request cancelled.
  • With timeout=0, request is cancelled immediately.
  • With no timeout (or large values like 30000), same snippet succeeds.
  • Current behavior is easy to misinterpret as flaky execution unless timeout semantics are already known.

Logs

request cancelled

Metadata

Metadata

Labels

ai-triage-respondedIndicate whether the AI triage agent has responded to this issue.bugSomething isn't workingfixed in next version (main)A fix has been implemented and will appear in an upcoming version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions