Agent-Powered Debugging: Using VS Code Insiders and GitHub Copilot CLI to Troubleshoot Faster
How to combine VS Code Insiders agent mode, GitHub Copilot CLI, custom agents, MCP servers, and background sessions into a debuggging and customer-issue triage workflow that cuts resolution time dramatically.
Agent-Powered Debugging: VS Code Insiders + GitHub Copilot CLI
Debugging customer issues is frustrating because the hard part isn’t fixing the bug—it’s finding it. You context-switch between log files, dashboards, source code, documentation, and incident threads, assembling the picture one tab at a time. By the time you’ve gathered enough context to understand the problem, you’ve burned half the investigation window.
What if the agent could do the context assembly for you?
VS Code Insiders (v1.110, March 2026) and GitHub Copilot CLI have quietly shipped the features that make this possible: agent mode with session memory, background agents, the Agent Debug panel, MCP tool orchestration, custom agents with scoped tools, and plan mode for structured investigations. This post shows you how to combine them into a debugging workflow that’s measurably faster.
The Problem: Context Assembly Is the Bottleneck
A typical customer issue investigation looks like this:
- Read the incident ticket or support case
- Find the relevant service and time window
- Query logs (Application Insights, Log Analytics, CloudWatch)
- Correlate across multiple telemetry sources
- Find the relevant code path in the repo
- Check recent changes (git log, PRs)
- Reproduce locally or form a hypothesis
- Verify the fix
Steps 1–6 are pure context assembly. They involve no creativity and no engineering judgment—they’re mechanical information gathering. And they consume 60–80% of the investigation time.
Agents are exceptionally good at mechanical information gathering.
The Toolkit
Here’s what’s available as of March 2026:
| Tool | What It Does | Where It Runs |
|---|---|---|
| VS Code Insiders Agent Mode | Multi-step autonomous task execution with tool use | VS Code editor |
| Agent Debug Panel | Real-time visibility into agent events, tool calls, loaded customizations | VS Code sidebar |
| Session Memory | Persist plans and guidance across conversation turns | VS Code chat |
| Context Compaction | Manually compact conversation history to free context space | VS Code chat |
| GitHub Copilot CLI | Terminal-native agent with plan mode, background sessions, repo context | Terminal |
gh agent-task | Kick off and track coding agent sessions from the terminal | GitHub CLI |
Custom Agents (.agent.md) | Specialized personas with restricted tools and scoped instructions | VS Code / CLI |
| MCP Servers | Connect agents to external tools (databases, APIs, observability) | VS Code / CLI |
| Background Agents | Autonomous sessions that run asynchronously, creating PRs when done | VS Code / GitHub |
Workflow 1: The Debug Agent
The most immediate win is building a custom agent specifically for debugging. Instead of starting every investigation in the general-purpose Copilot chat, you @debug and get a persona that’s already loaded with your debugging tools and conventions.
Create .github/agents/debug.agent.md:
---
description: Investigates bugs, analyzes logs, traces errors through the codebase,
and proposes fixes with evidence
tools:
- codebase
- terminal
- fetch
---
# Debug Investigator
You investigate bugs and customer-reported issues. Your goal is to find the root
cause and propose a fix with evidence.
## Investigation Protocol
1. **Understand the symptom**: What is the user experiencing? What's the expected behavior?
2. **Scope the search**: Identify the relevant service, component, and time window
3. **Gather evidence**: Query logs, check recent changes, trace the code path
4. **Form a hypothesis**: What changed? What condition triggers the bug?
5. **Verify**: Can you reproduce it? Does the code confirm your hypothesis?
6. **Propose a fix**: Show the specific code change with reasoning
## Rules
- Always check `git log --oneline -20` for recent changes in the affected area
- When analyzing errors, trace the full call stack—don't stop at the first frame
- Quote specific log lines and code as evidence
- If you can't find the root cause, say so and explain what you've ruled out
- Never guess—if you need more information, say what you need
Now @debug in Copilot chat gives you a focused investigator that follows a consistent protocol every time. No setup, no warm-up prompt.
Workflow 2: MCP-Powered Log Analysis
The real power unlock is connecting agents to your observability stack through MCP servers. Instead of copying log output into chat, the agent queries your logs directly.
Azure Application Insights / Log Analytics
Add to .vscode/mcp.json:
{
"servers": {
"azure-monitor": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@azure/monitor-mcp-server"],
"env": {
"AZURE_SUBSCRIPTION_ID": "${env:AZURE_SUBSCRIPTION_ID}",
"AZURE_RESOURCE_GROUP": "${env:AZURE_RESOURCE_GROUP}"
}
}
}
}
Now your debug agent can run KQL queries directly:
@debug The customer reports intermittent 500 errors on the /api/orders endpoint since yesterday 2pm EST. Check Application Insights for exceptions in that window and correlate with any deployments.
The agent will:
- Formulate a KQL query for exceptions on that endpoint and time range
- Execute it via the MCP server
- Analyze the results in context with the codebase
- Check
git logfor deployments near that timestamp - Correlate the exception with the code change
No tab switching. No manual query construction. No copy-pasting between tools.
GitHub Issues and PRs
Connect the GitHub MCP server to pull issue context directly:
{
"servers": {
"github": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@github/mcp-server"],
"env": {
"GITHUB_TOKEN": "${env:GITHUB_TOKEN}"
}
}
}
}
Now the agent can read the original issue, check linked PRs, review recent merges, and cross-reference—all within the same investigation.
Workflow 3: GitHub Copilot CLI for Terminal-Native Debugging
Not every investigation starts in the editor. When you’re SSH’d into a server, triaging in a terminal, or reviewing logs on a remote machine, Copilot CLI brings agent capabilities to the command line.
Plan Mode for Structured Investigation
Press Shift+Tab in Copilot CLI to enter plan mode. Instead of jumping straight to execution, the agent builds a structured investigation plan:
$ gh copilot
> [Shift+Tab to enter plan mode]
> Customer reports their webhook endpoint stopped receiving events
> after our v2.4.1 release. Investigate.
Plan:
1. Check v2.4.1 release notes and diff for webhook-related changes
2. Review webhook delivery logs for the customer's endpoint
3. Compare webhook payload format between v2.4.0 and v2.4.1
4. Check for breaking changes in serialization or headers
5. Test webhook delivery to a sample endpoint
Shall I proceed with this plan? [Y/n]
You can adjust the plan before execution starts. This prevents the agent from going down a wrong path and burning context on irrelevant investigation.
Background Agent Tasks from the CLI
For longer investigations, kick off a background coding agent that works asynchronously:
# Start a background investigation
gh agent-task create "Investigate why webhook retries are failing
for customers on the v2.4.1 release. Check the retry logic in
src/webhooks/, review the delivery logs, and propose a fix."
# Check progress
gh agent-task list
# Follow the investigation in real-time
gh agent-task view 1234 --log --follow
The agent works in its own branch, investigates autonomously, and opens a draft PR with its findings and proposed fix. You review the PR instead of doing the investigation yourself.
Built-in Agents
Copilot CLI ships with specialized agents you can invoke directly:
# Code review agent — reviews your changes with high-signal feedback
gh copilot --agent code-review
# Use a specific model for complex analysis
gh copilot --model claude-sonnet-4
Workflow 4: The Incident Triage Pipeline
For teams handling customer issues at scale, you can build a full triage pipeline using custom agents, skills, and prompt files.
The Triage Skill
Create .github/skills/incident-triage/SKILL.md:
---
description: "Triage customer incidents: classify severity, gather evidence,
identify root cause, and recommend resolution"
---
# Incident Triage
## Severity Classification
- **P0**: Service down, data loss, security breach → Immediate
- **P1**: Major feature broken, significant user impact → Within 4 hours
- **P2**: Minor feature broken, workaround exists → Within 24 hours
- **P3**: Cosmetic, documentation, enhancement → Next sprint
## Triage Checklist
1. [ ] Classify severity (P0–P3)
2. [ ] Identify affected component and service
3. [ ] Determine scope: single customer or widespread?
4. [ ] Check for known issues or recent deployments
5. [ ] Gather reproduction steps
6. [ ] Query logs for the relevant time window
7. [ ] Review recent git history for the affected component
8. [ ] Identify root cause or escalation path
9. [ ] Document findings in structured format
## Output Format
### Incident Summary
- **Severity**: P0/P1/P2/P3
- **Component**: [affected service/module]
- **Scope**: [single customer / N customers / all users]
- **Root Cause**: [identified cause or "under investigation"]
- **Recent Changes**: [relevant PRs/commits]
- **Evidence**: [log excerpts, stack traces]
- **Recommendation**: [fix / workaround / escalation]
The Triage Prompt
Create .github/prompts/triage.prompt.md:
---
description: "Triage a customer-reported issue"
---
Triage this customer issue:
${input:issueDescription}
Follow the incident triage skill protocol:
1. Classify severity
2. Identify the affected component in our codebase
3. Check git log for recent changes to that component
4. Search for related error patterns in the codebase
5. Produce a structured incident summary
Now any engineer can run /triage in Copilot chat, paste the customer report, and get a structured investigation—same protocol, every time.
Workflow 5: Session Memory + Context Compaction for Long Investigations
Complex bugs take multiple sessions to resolve. VS Code Insiders’ session memory (shipped in v1.110) persists plans and guidance across conversation turns, so you don’t lose context when you come back.
The workflow:
- Start the investigation — the agent builds a plan and begins gathering evidence
- Hit a dead end — compact the conversation with the context compaction feature to free up space without losing key findings
- Resume later — session memory retains your investigation state, hypotheses, and evidence gathered so far
- Fork the session — if you want to explore two hypotheses simultaneously, fork the chat session to create an independent branch of the investigation
This mirrors how experienced engineers actually debug: they maintain a mental model, prune irrelevant details, and sometimes pursue parallel hypotheses.
Workflow 6: The Agent Debug Panel
The Agent Debug Panel (new in v1.110) gives you real-time visibility into what the agent is actually doing:
- Agent events: Every step the agent takes, in order
- Tool calls: Which tools were invoked, with what arguments, and what they returned
- Loaded customizations: Which instructions, skills, and agents were loaded for this interaction
This is invaluable for debugging the debugger. If the agent isn’t finding what you expect, the debug panel shows you whether the right skill was loaded, whether the MCP tool was called correctly, and where the investigation went off track.
Concrete Techniques That Save Time
Beyond the workflows, here are specific techniques I’ve found effective:
1. Correlation Prompts
Instead of asking the agent to “check the logs,” give it a correlation task:
Correlate these three signals: the customer’s 500 error at 14:32 UTC, the deployment at 14:15 UTC, and the spike in database connection pool exhaustion starting at 14:28 UTC. What’s the causal chain?
Agents are remarkably good at connecting dots when you frame the task as correlation rather than search.
2. Diff-Based Investigation
Compare the behavior of the /api/orders endpoint between commit abc123 (last known good) and commit def456 (first known bad). What changed in the request handling path?
The agent can git diff, trace the affected code paths, and explain the behavioral difference.
3. Hypothesis-Driven Prompts
I think the bug is a race condition in the webhook retry queue. Evidence: retries work for single events but fail for batches. Verify or disprove this hypothesis by examining the retry logic in src/webhooks/retry.ts.
Giving the agent a hypothesis to test is more effective than open-ended investigation. It focuses the search and produces a clear yes/no answer with evidence.
4. Customer Context Injection
Create a prompt file that injects customer context automatically:
.github/prompts/customer-debug.prompt.md:
---
description: "Debug a customer issue with full context"
---
## Customer Issue
**Customer**: ${input:customerName}
**Environment**: ${input:environment}
**Issue**: ${input:issueDescription}
**Time Window**: ${input:timeWindow}
Investigate this issue:
1. Query logs for errors in the ${input:timeWindow} window
2. Check for recent deployments or configuration changes
3. Identify if this is isolated to this customer or widespread
4. Trace the relevant code path
5. Produce a structured incident summary with evidence
The ${input:...} variables prompt the engineer for structured input, ensuring every investigation starts with the right context.
5. Post-Mortem Generation
After resolving an issue, use the agent’s accumulated context to generate a post-mortem:
Based on our investigation, generate a post-mortem document with: timeline of events, root cause analysis, impact assessment, resolution steps taken, and preventive measures to avoid recurrence.
The agent has all the evidence in its session—the logs it queried, the code it traced, the fix it proposed. The post-mortem writes itself.
Setting It Up: The Minimal Debugging Toolkit
Here’s the minimum setup to get agent-powered debugging working:
1. Install and Configure
# Install GitHub Copilot CLI
gh extension install github/gh-copilot
# Verify it works
gh copilot --version
# Enable agent mode in VS Code Insiders
# It's on by default in v1.110+
2. Create the Debug Agent
# Create the agent directory
New-Item -ItemType Directory -Force -Path .github/agents
# Create the debug agent (content shown in Workflow 1 above)
3. Connect Your Observability Stack
Add MCP servers for the tools your team actually uses. Start with one — you can always add more:
| Stack | MCP Server | What It Enables |
|---|---|---|
| Azure Monitor | @azure/monitor-mcp-server | KQL queries against App Insights and Log Analytics |
| GitHub | @github/mcp-server | Issue/PR context, code search, deployment history |
| PostgreSQL | @modelcontextprotocol/server-postgres | Direct database queries for data investigation |
| Filesystem | Built-in | Log file analysis on local/mounted volumes |
4. Create the Triage Skill and Prompt
New-Item -ItemType Directory -Force -Path .github/skills/incident-triage
New-Item -ItemType Directory -Force -Path .github/prompts
# Create SKILL.md and prompt files (content shown in Workflow 4 above)
5. Teach the Agent Your Patterns
Add debugging patterns to your docs/debugging.md and reference it from AGENTS.md:
## Debugging Reference
- Debugging patterns: docs/debugging.md
- Common failure modes: docs/known-issues.md
- Runbook: docs/runbook.md
The debug agent navigates to these docs when it needs them — they don’t bloat every interaction.
What Changes
The shift from manual debugging to agent-powered debugging isn’t about replacing engineering judgment. You still form hypotheses, evaluate evidence, and decide on fixes. What changes is the speed of context assembly.
| Before | After |
|---|---|
| Manually write KQL queries | Agent queries logs via MCP |
| Switch between tabs for logs, code, git history | Agent correlates across sources in one session |
| Lose investigation context between sessions | Session memory persists state |
| Every engineer has their own triage approach | Triage skill enforces consistent protocol |
| Copy-paste log output into chat | Agent reads logs directly through tools |
| Start from scratch on every investigation | Self-improvement loop captures patterns |
The engineers I’ve seen adopt this workflow report that investigation time drops significantly — not because the agent has better intuition, but because it eliminates the mechanical context-assembly work that dominates most investigations.
The agent does the gathering. You do the thinking.
For the broader context engineering principles behind these workflows, see Context Engineering > Prompt Engineering. For the full VS Code Insiders setup guide, see The VS Code Insiders + GitHub Copilot Context Engineering Playbook.