The Java Debug Agent is an AI-powered debugging assistant that integrates with GitHub Copilot Chat to help you debug Java applications using natural language.
Instead of manually setting breakpoints and inspecting variables, you can simply describe your debugging task in natural language. The agent will:
- Analyze your code to form hypotheses
- Set targeted breakpoints
- Inspect variables and evaluate expressions
- Find the root cause of bugs
- VS Code 1.95.0 or later
- Language Support for Java by Red Hat
- Debugger for Java
- GitHub Copilot Chat extension
Press Ctrl+Shift+I (Windows/Linux) or Cmd+Shift+I (macOS) to open Copilot Chat.
In the Copilot Chat panel, click on the agent selector (usually shows "Copilot" or current agent name) and select JavaDebug from the dropdown list.
Once in JavaDebug mode, simply type your debugging request:
Why am I getting a NullPointerException in OrderService?
The agent will:
- Read relevant code files
- Form a hypothesis about the bug
- Set breakpoints at strategic locations
- Start or attach to a debug session
- Inspect variables to verify the hypothesis
- Report the root cause
I'm getting NPE when calling userService.getUser()
The agent will:
- Read
UserService.java - Hypothesize which variable might be null
- Set a breakpoint before the NPE
- Check variable values
- Report: "The
uservariable is null becausefindById()returns null when ID doesn't exist"
The calculateTotal() method returns wrong value
Debug processOrder with orderId=456
I suspect a race condition in the worker threads
| Capability | Description |
|---|---|
| Start Debug Session | Launch or attach to Java applications |
| Set Breakpoints | Set conditional or unconditional breakpoints |
| Inspect Variables | View local variables, fields, and objects |
| Evaluate Expressions | Execute Java expressions in debug context |
| Step Through Code | Step over, step into, step out |
| Multi-thread Support | Debug concurrent applications |
| Stack Trace Analysis | View and navigate call stacks |
The agent uses hypothesis-driven debugging:
┌─────────────────────────────────────────┐
│ 1. STATIC ANALYSIS │
│ Read code, understand the problem │
└─────────────────┬───────────────────────┘
↓
┌─────────────────────────────────────────┐
│ 2. FORM HYPOTHESIS │
│ "Variable X is null at line Y" │
└─────────────────┬───────────────────────┘
↓
┌─────────────────────────────────────────┐
│ 3. SET BREAKPOINT │
│ At the location to verify │
└─────────────────┬───────────────────────┘
↓
┌─────────────────────────────────────────┐
│ 4. VERIFY │
│ Check if hypothesis is correct │
│ ├─ YES → Report root cause │
│ └─ NO → Form new hypothesis │
└─────────────────────────────────────────┘
Make sure you're in JavaDebug agent mode (check the agent selector in Chat panel). If you switch back to default Copilot mode, the debugging tools won't be available.
✅ Good: "Why does getUserById return null when id=123?"
❌ Vague: "Something is wrong"
✅ Good: "Getting ArrayIndexOutOfBoundsException in processItems()"
❌ Vague: "Debug processItems"
✅ Good: "The order total is $0 instead of $150 for order 456"
❌ Vague: "Wrong calculation"
Make sure the Java project is properly loaded. Check that:
- The Java extension is activated (look for Java icon in status bar)
- The project is imported (check Java Projects view)
Ensure:
- Your project compiles successfully
- No other debug session is running
- The main class can be found
The agent will tell you to trigger the scenario. You need to:
- Run the part of your application that executes the code
- The breakpoint will be hit when the code path is executed
- Requires an active Java project with proper configuration
- Cannot debug remote applications without proper attach configuration
- Performance may vary with large codebases
If you encounter issues or have suggestions, please:
- File an issue on GitHub
- Include the agent's response and your debugging request


