AI coding agents are becoming a regular part of software development. Developers can now ask agents to inspect repositories, modify source files, run tests, and complete tasks across multiple projects. Visual Studio Code supports these workflows through its Agents window, where developers can manage agent sessions separately from traditional editor windows.
This creates a new consideration for extension developers. An extension that works well in a normal VS Code window may need to behave differently when the same workspace is opened in an agent-managed environment.
For example, an extension might display interactive notifications, prompt developers to configure a project, or start background processes. These behaviors may be unnecessary when an agent is managing the workspace. In some cases, they can interrupt the agent's workflow or create duplicate operations.
Visual Studio Code addresses this requirement with a new workspace API: workspace.isAgentManaged.
The API was finalized in the VS Code 1.150 Insiders development cycle on December 1, 2026. It allows extensions to identify agent-managed workspaces without using a proposed API.
This article explains what the property does, how to use it in an extension, and how to adapt extension behavior for agent-managed environments.
What Is an Agent-Managed Workspace?
An agent-managed workspace is a workspace associated with an AI agent workflow in Visual Studio Code.
In a traditional editor window, the developer directly controls most interactions. The developer opens files, runs commands, reviews changes, and decides when to execute operations.
In an agent-managed workspace, an agent may perform many of these activities as part of an assigned task. It can inspect the project, modify files, execute commands, and continue working while the developer monitors its progress.
Visual Studio Code provides an Agents window for managing these sessions across projects and execution environments.
The important distinction is that an agent-managed workspace is not simply a workspace containing AI-generated code. It refers to the workspace environment identified by VS Code as being managed through its agent workflow.
An extension may need to know about this environment to avoid displaying unnecessary user-facing interactions or starting operations that conflict with the agent's work.
Why Does Workspace Detection Matter?
Consider an extension that displays a notification whenever a project opens.
In a normal development session, the notification might help the developer configure the project. However, when an agent opens or manages the same project, the notification may provide little value.
Other examples include:
Showing setup instructions that an agent does not need.
Starting duplicate background processes.
Opening interactive dialogs during automated tasks.
Displaying notifications that interrupt agent workflows.
Running project initialization commands more than once.
Activating features intended only for direct developer interaction.
Without a reliable way to identify the workspace environment, extension developers may depend on indirect checks or custom configuration settings.
The new API provides a direct way to detect this condition.
Understanding workspace.isAgentManaged
The workspace namespace in the VS Code Extension API provides information about the currently opened workspace.
It includes properties such as workspaceFolders, name, isTrusted, and workspaceFile.
The new isAgentManaged property extends this information.
An extension can read it directly:
import * as vscode from 'vscode';
export function activate(
context: vscode.ExtensionContext
) {
const isAgentManaged =
vscode.workspace.isAgentManaged;
if (isAgentManaged) {
console.log(
'Extension is running in an agent-managed workspace.'
);
} else {
console.log(
'Extension is running in a regular workspace.'
);
}
}
The property returns a Boolean value:
Value | Meaning |
|---|
true | The current workspace is agent-managed |
false | The current workspace is not agent-managed |
This makes the implementation straightforward. An extension can check the property and decide which features should be enabled.
The property identifies the workspace environment. It does not tell the extension which AI model is being used, what prompt was submitted, or which task the agent is currently performing.
Those responsibilities belong to other parts of the agent workflow.
Creating a VS Code Extension That Detects Agent-Managed Workspaces
Let's create a small extension that detects the workspace environment and displays the result in the VS Code status bar.
The extension will:
Read the isAgentManaged property.
Display whether the current workspace is agent-managed.
Register a command to show the detected environment.
Avoid displaying unnecessary setup information in agent-managed workspaces.
Step 1: Create the Extension Project
You can create a VS Code extension using the official extension generator.
Install the generator:
npm install -g yo generator-code
Run the generator:
yo code
Select the TypeScript extension template and provide a project name.
The generated project includes the extension entry point, package.json, and TypeScript configuration.
Step 2: Configure the Extension Manifest
Open package.json and configure the extension metadata and command contribution.
{
"name": "agent-workspace-detector",
"displayName": "Agent Workspace Detector",
"description": "Detects agent-managed VS Code workspaces",
"version": "1.0.0",
"engines": {
"vscode": "^1.150.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onStartupFinished"
],
"main": "./out/extension.js",
"contributes": {
"commands": [
{
"command": "agentWorkspaceDetector.showStatus",
"title": "Show Agent Workspace Status"
}
]
}
}
The engines property declares the minimum VS Code API version required by the extension.
Because workspace.isAgentManaged was finalized in the 1.150 development cycle, extensions that depend on this property should target a VS Code release that includes the finalized API.
During development, use the corresponding Insiders build if the stable release does not yet contain the property.
Step 3: Implement Workspace Detection
Open src/extension.ts and add the following implementation:
import * as vscode from 'vscode';
export function activate(
context: vscode.ExtensionContext
) {
const isAgentManaged =
vscode.workspace.isAgentManaged;
const statusBarItem =
vscode.window.createStatusBarItem(
vscode.StatusBarAlignment.Left,
100
);
statusBarItem.text = isAgentManaged
? '$(hubot) Agent Workspace'
: '$(code) Regular Workspace';
statusBarItem.tooltip = isAgentManaged
? 'This workspace is managed by an agent.'
: 'This is a regular development workspace.';
statusBarItem.show();
context.subscriptions.push(statusBarItem);
const command = vscode.commands.registerCommand(
'agentWorkspaceDetector.showStatus',
() => {
const message = isAgentManaged
? 'Current workspace is agent-managed.'
: 'Current workspace is not agent-managed.';
vscode.window.showInformationMessage(message);
}
);
context.subscriptions.push(command);
}
export function deactivate() {}
This example reads the property during extension activation and uses the result to configure a status bar item.
The extension also registers a command that displays the detected state.
The status bar is only a demonstration. A production extension may choose to hide this indicator and use the property internally to control notifications, initialization, or other behavior.
Step 4: Run and Test the Extension
Open the project in VS Code and press F5 to launch the Extension Development Host.
Test the extension in a regular VS Code workspace first.
Then open an agent-managed workspace using a VS Code build that supports the new property.
Check the status bar and run the command from the Command Palette:
Agent Workspace Detector: Show Agent Workspace Status
The extension should display the environment reported by the API.
When testing, make sure you use the actual agent-managed workflow rather than assuming that opening a normal folder containing AI-generated code makes it agent-managed.
Using Agent Detection to Control Extension Behavior
Detecting the workspace is only the first step. The real benefit comes from adapting extension behavior based on the result.
An extension may have features that are useful for developers but unnecessary for agents.
For example, a project setup extension might normally display a welcome message when a workspace opens. In an agent-managed workspace, it may be better to avoid that notification and allow the agent to work without unnecessary interaction.
Consider this example:
import * as vscode from 'vscode';
export function activate(
context: vscode.ExtensionContext
) {
const isAgentManaged =
vscode.workspace.isAgentManaged;
if (isAgentManaged) {
console.log(
'Skipping interactive project setup.'
);
registerAgentFriendlyFeatures(context);
return;
}
vscode.window.showInformationMessage(
'Welcome! Configure your project to get started.'
);
registerInteractiveFeatures(context);
}
function registerAgentFriendlyFeatures(
context: vscode.ExtensionContext
) {
console.log(
'Registering agent-friendly features.'
);
}
function registerInteractiveFeatures(
context: vscode.ExtensionContext
) {
console.log(
'Registering interactive developer features.'
);
}
This structure separates interactive functionality from features that are suitable for agent-managed workspaces.
The approach is especially useful for extensions that perform project initialization, display notifications, or require user interaction.
However, do not disable essential language support, diagnostics, or build functionality simply because the workspace is agent-managed. Agents often depend on these capabilities to understand and validate code.
Avoiding Unnecessary Notifications in Agent Workflows
Notifications are a common source of interruptions in developer tools.
An extension may display a message when a project opens, when dependencies are missing, or when an update is available.
These notifications can be useful in a normal editor session. However, repeated interactive messages may interrupt an agent's work.
The following example shows how to control a notification based on the workspace environment:
import * as vscode from 'vscode';
export function activate() {
if (vscode.workspace.isAgentManaged) {
return;
}
vscode.window.showInformationMessage(
'Project tools are ready.'
);
}
This is a simple example, but the same condition can be applied to more complex extension behavior.
For example, an extension can:
Avoid displaying optional welcome messages.
Skip interactive setup prompts.
Disable developer-only reminders.
Avoid opening unnecessary editor panels.
Keep background initialization independent of user interaction.
Be careful not to suppress messages that report important errors or security problems. Agent-managed workspaces still need useful diagnostic information.
Supporting Older VS Code Versions
The finalized API is available in the VS Code 1.150 development cycle. Extensions that support older VS Code releases may need to handle environments where the property does not exist.
There are two common approaches.
Set a Minimum VS Code Version
If agent-workspace detection is essential to the extension, declare a minimum VS Code version that includes the API.
For example:
{
"engines": {
"vscode": "^1.150.0"
}
}
This is the simplest approach when older versions are not supported.
Use Runtime Feature Detection
If the extension needs to support older VS Code versions, check whether the property exists before reading it.
import * as vscode from 'vscode';
type AgentWorkspaceApi = typeof vscode.workspace & {
readonly isAgentManaged?: boolean;
};
export function activate() {
const workspaceApi =
vscode.workspace as AgentWorkspaceApi;
const isAgentManaged =
workspaceApi.isAgentManaged === true;
if (isAgentManaged) {
console.log('Agent-managed workspace detected.');
} else {
console.log(
'Agent-managed workspace not detected.'
);
}
}
This approach treats an unavailable property as false.
That does not prove that the workspace is a regular developer workspace. It only means that the extension could not confirm that it is agent-managed.
This distinction matters when supporting multiple VS Code versions. An extension should not make security or permission decisions based on an unknown environment being treated as a confirmed regular workspace.
Agent-Managed Workspace Detection vs. Other Workspace Properties
VS Code provides several workspace properties that may appear similar but represent different conditions.
An extension should not use one property as a substitute for another.
API or concept | What it identifies | Typical use |
|---|
workspace.isAgentManaged | Whether the workspace is agent-managed | Adapting extension behavior for agent workflows |
workspace.isTrusted | Whether the user trusts the workspace contents | Controlling trust-sensitive functionality |
workspace.workspaceFolders | Folders opened in the current workspace | Finding project directories |
Virtual workspace | A workspace backed by a non-local file system provider | Supporting remote or virtual files |
Remote Development | Where the workspace or extension host runs | Supporting SSH, WSL, and containers |
For example, a workspace can be remote without being agent-managed. Similarly, an agent-managed workspace may use a local or remote execution environment.
The isAgentManaged property should be used only for its intended purpose.
Agent-Managed Workspace vs. Workspace Trust
Workspace Trust is a security feature that controls how extensions behave when the user has not trusted a project's contents.
It helps prevent extensions from automatically executing potentially unsafe code from an untrusted workspace.
Agent-managed workspace detection serves a different purpose. It tells extensions whether the current workspace belongs to an agent-managed workflow.
These properties should be evaluated independently.
An extension should not assume that an agent-managed workspace is trusted, and it should not bypass Workspace Trust checks because an AI agent is working in the project.
Best Practices for Extension Developers
When adding agent-aware behavior to an extension, keep the implementation simple and predictable.
Consider these practices:
Use workspace.isAgentManaged instead of relying on window names or other indirect checks.
Keep interactive developer features separate from agent-friendly functionality.
Avoid unnecessary notifications and dialogs during agent workflows.
Preserve essential diagnostics, language services, and build support.
Continue respecting Workspace Trust and other security controls.
Use runtime feature detection if older VS Code versions must be supported.
Test the extension in both regular and agent-managed workspaces.
Do not assume that remote, virtual, or container-based workspaces are automatically agent-managed.
Keep the agent-specific behavior small so it remains easy to maintain.
One important consideration is extension activation. Do not delay essential functionality until a user opens a particular editor if the extension must support agent operations from the beginning. Choose activation events that match the extension's actual responsibilities.
Also, avoid running expensive initialization tasks simply because the workspace is agent-managed. Agent sessions may open multiple projects, and unnecessary background work can affect startup time and resource usage.
Common Mistakes to Avoid
Checking Window Names Instead of the API
An extension might attempt to detect an agent environment by checking the application name, window title, or folder path.
These values are not reliable indicators of an agent-managed workspace. They may change across VS Code releases and execution environments.
Use the dedicated API instead.
Treating Every Remote Workspace as Agent-Managed
Remote workspaces can run through SSH, WSL, Dev Containers, or other supported environments.
These environments do not automatically mean that an AI agent manages the workspace.
Use the property specifically designed for agent-managed workspace detection.
Disabling Too Much Functionality
An extension should not assume that agents do not need interactive or developer-oriented features.
For example, diagnostics, code navigation, formatting, and language support may be essential to an agent's work.
Disable only the features that are genuinely unnecessary or disruptive.
Ignoring Older API Versions
If an extension supports older VS Code releases, directly accessing a property that is unavailable in those releases can cause compatibility problems.
Declare the appropriate minimum version or use runtime feature detection.
Using the Property as a Security Boundary
The isAgentManaged property describes the workspace environment. It does not provide authentication, authorization, or sandboxing.
Continue using Workspace Trust, permission controls, and appropriate execution restrictions for security-sensitive functionality.
Advantages and Limitations
The new API provides a simple and reliable way for extensions to recognize agent-managed workspaces.
Its main advantages include:
Direct detection through the VS Code Extension API.
No need to inspect window titles or internal application details.
Better control over notifications and interactive features.
Cleaner separation between developer-focused and agent-focused behavior.
Improved compatibility with VS Code's growing agent workflow.
There are also limitations.
The property only identifies the workspace environment. It does not expose agent prompts, session history, execution permissions, or the identity of the agent.
It also does not replace Workspace Trust or other security mechanisms. Extensions must continue to handle remote environments, virtual workspaces, and older VS Code versions appropriately.
Summary
AI agents are changing how developers interact with Visual Studio Code. Extensions that previously assumed every workspace was controlled directly by a developer may now need to adapt to agent-managed workflows.
The new workspace.isAgentManaged property provides a straightforward way to detect this environment. Extension developers can use it to avoid unnecessary notifications, control interactive features, and provide a smoother experience when an agent is working on a project.
The property was finalized in the VS Code 1.150 Insiders development cycle, making it available as a stable Extension API rather than a proposed API.
For extension developers, the best approach is to use this property only where it improves the workflow. Keep essential development features available, respect Workspace Trust, and test the extension in both regular and agent-managed workspaces.
Join the conversation! Your thoughts help the community grow.