What Is Agent Mode?
GitHub Copilot Agent Mode transforms VS Code from an autocomplete tool into an autonomous coding partner. Instead of suggesting single lines, Agent Mode:
- Plans multi-step changes across files
- Creates, edits, and deletes files autonomously
- Runs terminal commands (build, test, lint)
- Iterates on errors until tests pass
- Understands your full workspace context
Enabling Agent Mode
Prerequisites
- VS Code 1.99+ (April 2026 or later)
- GitHub Copilot subscription (Individual, Business, or Enterprise)
- GitHub Copilot extension v1.250+
Activation
- Open the Chat panel (Ctrl+Shift+I or Cmd+Shift+I)
- Click the mode selector dropdown (top of chat)
- Select βAgentβ mode
Or use the keyboard shortcut: Ctrl+Shift+P β βChat: Switch to Agent Modeβ
Core Capabilities
1. Multi-File Editing
Agent Mode understands your entire workspace. Ask it to refactor across files:
Prompt: "Refactor the authentication module to use JWT tokens instead of sessions.
Update all route handlers, middleware, and tests."Agent Mode will:
- Analyze existing auth code
- Propose a plan
- Edit auth middleware, route files, test files
- Run tests to verify
2. Terminal Integration
Agent Mode can run shell commands with your approval:
Prompt: "Set up a new Express.js API with TypeScript, ESLint, Prettier, and Jest.
Initialize the project, install dependencies, and create the folder structure."It will run npm init, npm install, create tsconfig.json, configure ESLint, etc.
3. Autonomous Error Resolution
When Agent Mode encounters errors, it iterates automatically:
- Makes code change
- Runs build/test
- Sees error output
- Fixes the error
- Re-runs until success
4. Context-Aware Planning
Agent Mode reads:
- Open files and workspace structure
package.json,tsconfig.json, config files- Git history and branch context
- Terminal output from previous commands
- Your instructions in
.github/copilot-instructions.md
Configuration
Workspace Instructions
Create .github/copilot-instructions.md:
# Project Conventions
- Use TypeScript strict mode
- Follow functional programming patterns
- Tests in __tests__/ directories with .test.ts extension
- Use pnpm as package manager
- API routes follow REST conventions
- Error handling uses Result<T, E> patternSettings
// .vscode/settings.json
{
"github.copilot.chat.agent.enabled": true,
"github.copilot.chat.agent.maxIterations": 10,
"github.copilot.chat.agent.autoApproveTerminal": false,
"github.copilot.chat.agent.autoApproveFileChanges": false
}Security Controls (Enterprise)
// For GitHub Copilot Business/Enterprise
{
"github.copilot.chat.agent.terminalCommands.blocklist": [
"rm -rf",
"sudo",
"curl | sh",
"wget | bash"
]
}Agent Mode vs Edit Mode vs Chat
| Feature | Chat | Edit | Agent |
|---|---|---|---|
| Answers questions | β | β | β |
| Edits current file | β | β | β |
| Multi-file edits | β | β | β |
| Runs terminal | β | β | β |
| Iterates on errors | β | β | β |
| Plans autonomously | β | β | β |
| Uses MCP tools | β | β | β |
MCP Server Integration
Agent Mode supports Model Context Protocol servers for extended capabilities:
// .vscode/mcp.json
{
"servers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-filesystem", "/workspace"]
},
"github": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-github"],
"env": {
"GITHUB_TOKEN": "${env:GITHUB_TOKEN}"
}
}
}
}Best Practices
Effective Prompts
Good:
Add pagination to the /api/products endpoint.
Use cursor-based pagination with 20 items per page.
Include total count in response headers.
Add tests for edge cases (empty results, last page, invalid cursor).Bad:
Fix the APIIteration Control
- Review each step before approving
- Use
@workspaceto provide full context - Break large tasks into focused sub-tasks
- Check the βChangesβ tab to review all modifications before accepting
Token Optimization (Cost Control)
{
"github.copilot.chat.agent.contextWindow": "medium",
"github.copilot.chat.agent.includeTests": true,
"github.copilot.chat.agent.maxFilesInContext": 20
}Troubleshooting
Agent Mode Not Available
- Verify VS Code version:
code --version(need 1.99+) - Check extension: GitHub Copilot Chat v0.24+
- Verify subscription: Settings β GitHub Copilot β Account status
- Restart VS Code after updates
Agent Gets Stuck in Loop
- Click βStopβ to halt iteration
- Provide clearer constraints in your prompt
- Break the task into smaller steps
- Check if the error is environmental (missing dependency, wrong Node version)
Terminal Commands Fail
- Ensure your workspace terminal profile is correct
- Agent uses the default shell β verify with
echo $SHELL - Grant terminal access when prompted (donβt auto-approve blindly)
Token Billing (June 2026 Changes)
GitHub Copilot moved to token-based billing:
| Plan | Monthly Tokens | Agent Mode |
|---|---|---|
| Individual ($10/mo) | 2,000 premium | Included |
| Business ($19/mo) | 5,000 premium | Included |
| Enterprise ($39/mo) | 10,000 premium | Included + Admin controls |
Agent Mode uses 5-20x more tokens than Chat mode due to multi-turn reasoning. Monitor usage in GitHub Settings β Copilot β Usage.