Language Model Tools (#wTasks / #runWTask)

Table of Contents

  1. Overview
    1. #wTasks β€” Get Workspace Tasks
    2. #runWTask β€” Run Workspace Task
  2. Typical Workflow
  3. Example Prompts
  4. Response Schemas
    1. #wTasks response
    2. #runWTask response
  5. Task Lookup Priority
  6. Guarded Tasks
  7. Limitations

Workspace Tasks exposes two language model tools that let GitHub Copilot (and other VS Code LM-powered agents) discover and run tasks directly from the chat interface β€” no manual browsing of the task tree required.

Tool Reference name Purpose
workspaceTasks_getTasks #wTasks List all runnable tasks in the workspace
workspaceTasks_runTask #runWTask Execute a specific workspace task

Overview

#wTasks β€” Get Workspace Tasks

Returns a JSON array of every runnable task discovered by Workspace Tasks, including tasks found in package.json, Taskfile.yml, GitHub Actions workflows, shell scripts, and every other supported task type. Each entry contains:

  • id β€” stable portable identifier (use this with #runWTask)
  • label β€” human-readable task name
  • type β€” task type (e.g. npm, shell, github-actions)
  • source β€” relative path to the source file (or null for global tasks)
  • workspaceFolder β€” name of the workspace folder (multi-root workspaces only)

Optional input parameters allow the model to filter results before they are returned:

Parameter Type Description
query string Case-insensitive label substring filter
taskType string Task type filter (e.g. npm, shell)

#runWTask β€” Run Workspace Task

Executes a workspace task. The tool shows a confirmation dialog before running any task, so you remain in control. When the task is marked as guarded, the confirmation message includes a warning.

⚠️ Asynchronous execution: The tool returns immediately after starting the task. It does not wait for the task to finish and does not report completion status.

Required inputs (at least one of id or label must be provided):

Parameter Type Description
id string Stable task ID from #wTasks. Preferred β€” avoids ambiguity.
label string Task label. May match multiple tasks.
taskType string Narrows label-based matches to a specific type.

Typical Workflow

  1. Ask Copilot to list your tasks: β€œWhat tasks are available in this workspace?”
  2. Copilot invokes #wTasks and returns a structured list with IDs.
  3. Ask Copilot to run a specific task: β€œRun the build npm task.”
  4. Copilot invokes #runWTask with the stable id from step 2.
  5. VS Code shows a confirmation dialog. After you approve, the task starts.

Example Prompts

Which tasks are available in this workspace?
Run the build task.
Find all npm tasks in the project.
Run the deploy task in the my-app workspace folder.
What shell script tasks do I have?

Response Schemas

#wTasks response

{
  "isTrusted": true,
  "isLoading": false,
  "tasks": [
    {
      "id": "npm:build:package.json",
      "label": "build",
      "type": "npm",
      "source": "package.json",
      "workspaceFolder": "my-app"
    }
  ],
  "truncated": false,
  "totalBeforeTruncation": 1
}

When isLoading is true, the task cache is still being populated β€” re-invoke after a short delay. When truncated is true, apply query or taskType filters to narrow results (the maximum returned is 500 tasks).

#runWTask response

{
  "started": true,
  "message": "Task 'build' has been started. It runs asynchronously; completion is not reported here.",
  "task": {
    "id": "npm:build:package.json",
    "label": "build",
    "type": "npm",
    "source": "package.json"
  }
}

When started is false, the message field explains why (e.g. guarded task declined, ambiguous label match, task not found). A candidates array is included when multiple tasks match the provided label.


Task Lookup Priority

When calling #runWTask, the tool resolves the target task in this order:

  1. By id (exact, O(1) lookup) β€” preferred and most reliable.
  2. By label (exact case-insensitive match) β€” narrowed by taskType if provided.
  3. If no exact match, the tool returns a candidates list with a β€œDid you mean…?” message rather than running an unintended task.

Always use #wTasks first to obtain a stable id, then pass that id to #runWTask.


Guarded Tasks

Tasks protected by a Run Guard are handled safely:

  • The confirmation dialog shown before execution includes a ⚠️ warning when the task is guarded.
  • The user must explicitly confirm before the task runs.
  • If the tool is invoked programmatically (without a prior confirmation dialog), the run-guard modal is triggered automatically.

Limitations

  • Asynchronous execution: #runWTask returns immediately after starting the task. There is no way to query task completion status through the LM tool interface.
  • 500-task cap: #wTasks returns at most 500 tasks per invocation. Use query and taskType filters to retrieve a focused list.
  • Untrusted workspaces: Both tools are disabled in untrusted workspaces. The tools return an explanatory message and take no action.
  • Task ID stability: Task IDs encode the type, label, and source file path. They remain stable as long as the source file is not moved or renamed.
  • taskType with id: When a task is located by id, the taskType parameter is ignored. It is only used to disambiguate label-based matches.

© 2026 Ryan Conrad. All rights reserved.

This site uses Just the Docs, a documentation theme for Jekyll.