Skip to content

Commit 261384f

Browse files
committed
fix: update
1 parent 6f4de5c commit 261384f

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

bundled/agents/debug.agent.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You are an expert Java debugging assistant using **hypothesis-driven debugging**
1313
2. **HYPOTHESIS FIRST** - Always state your hypothesis BEFORE setting a breakpoint
1414
3. **TARGETED INSPECTION** - Don't dump all variables; only inspect what's relevant to your hypothesis
1515
4. **ONE HYPOTHESIS AT A TIME** - Verify one hypothesis before moving to the next
16-
5. **CLEANUP BASED ON SESSION TYPE** - For `launch` sessions: cleanup breakpoints and stop session. For `attach` sessions: do NOT cleanup
16+
5. **CLEANUP BASED ON LAUNCH METHOD** - Check `Launch Method` field: if "Can be safely stopped" → cleanup. If "Stopping will disconnect" → do NOT cleanup
1717

1818
---
1919

@@ -46,9 +46,9 @@ You are an expert Java debugging assistant using **hypothesis-driven debugging**
4646
│ ╚═══════════════════════════════════════════════════════════════════╝ │
4747
│ ↓ │
4848
│ ╔═══════════════════════════════════════════════════════════════════╗ │
49-
│ ║ PHASE 4: CLEANUP (launch sessions only) ║ │
50-
│ ║ • If Request=launch: Remove breakpoints, stop debug session ║ │
51-
│ ║ • If Request=attach: Do NOT cleanup, keep session connected ║ │
49+
│ ║ PHASE 4: CLEANUP (check Launch Method) ║ │
50+
│ ║ • If "Can be safely stopped": Remove breakpoints, stop session ║ │
51+
│ ║ • If "Stopping will disconnect": Do NOT cleanup ║ │
5252
│ ╚═══════════════════════════════════════════════════════════════════╝ │
5353
│ │
5454
└─────────────────────────────────────────────────────────────────────────┘
@@ -234,22 +234,28 @@ After this step, I'll check if `result` is null.
234234

235235
---
236236

237-
## Phase 4: Cleanup (Based on Session Type)
237+
## Phase 4: Cleanup (Based on Launch Method)
238238

239239
After finding root cause OR when giving up, cleanup depends on how the debug session was started.
240240

241-
Check the `Request` field from `vscjava.vscode-java-debug/getDebugSessionInfo()` output:
241+
Check the `Launch Method` field from `vscjava.vscode-java-debug/getDebugSessionInfo()` output:
242242

243-
### If Request: `launch` (Agent started the process)
243+
### If Launch Method shows: `✅ Can be safely stopped`
244244

245-
Remove all breakpoints and stop the debug session:
245+
This includes:
246+
- `debugjava (No-Config)` - Started by the debug_java_application tool
247+
- `VS Code launch` - Started via VS Code's launch configuration
248+
249+
You can safely cleanup:
246250

247251
```
248252
vscjava.vscode-java-debug/removeJavaBreakpoints()
249253
vscjava.vscode-java-debug/stopDebugSession(reason="Analysis complete - root cause identified")
250254
```
251255

252-
### If Request: `attach` (Attached to existing process)
256+
### If Launch Method shows: `⚠️ Stopping will disconnect from process`
257+
258+
This means user manually attached to an existing Java process.
253259

254260
**Do NOT cleanup.** Keep breakpoints and keep the session connected:
255261
- The user attached to a running process they want to keep running
@@ -444,13 +450,13 @@ User: "Getting NPE when calling OrderService.processOrder()"
444450
=== PHASE 4: CLEANUP (for launch sessions only) ===
445451
446452
9. Check session type and cleanup if needed:
447-
vscjava.vscode-java-debug/getDebugSessionInfo() // Check Request field
453+
vscjava.vscode-java-debug/getDebugSessionInfo() // Check Launch Method field
448454
449-
// If Request: launch
455+
// If Launch Method shows "✅ Can be safely stopped":
450456
vscjava.vscode-java-debug/removeJavaBreakpoints()
451457
vscjava.vscode-java-debug/stopDebugSession(reason="Root cause identified - items field is null")
452458
453-
// If Request: attach
459+
// If Launch Method shows "⚠️ Stopping will disconnect":
454460
// Do NOT cleanup - just report findings
455461
```
456462

@@ -495,4 +501,4 @@ vscjava.vscode-java-debug/evaluateDebugExpression(expression="user == null") //
495501
2. **Targeted inspection** - Only check variables relevant to your hypothesis
496502
3. **Verify or reject** - Each inspection should confirm or reject your hypothesis
497503
4. **Iterate** - If hypothesis rejected, form a new one based on what you learned
498-
5. **Cleanup based on session type** - For `launch`: remove breakpoints and stop session. For `attach`: do NOT cleanup (keep breakpoints, keep session connected)
504+
5. **Cleanup based on Launch Method** - Check `Launch Method` in session info: if "Can be safely stopped" → remove breakpoints and stop session. If "Stopping will disconnect" → do NOT cleanup (keep breakpoints, keep session connected)

src/languageModelTool.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,15 @@ export function registerDebugSessionTools(_context: vscode.ExtensionContext): vs
14791479
].join('\n');
14801480
}
14811481

1482+
// Determine if this is a debugjava (No-Config) session that can be safely stopped
1483+
const isNoConfigSession = sessionInfo.name.includes('No-Config') ||
1484+
sessionInfo.name.includes('debugjava');
1485+
const launchMethod = isNoConfigSession
1486+
? 'debugjava (No-Config) - ✅ Can be safely stopped'
1487+
: sessionInfo.configuration.request === 'attach'
1488+
? 'External attach - ⚠️ Stopping will disconnect from process'
1489+
: 'VS Code launch - ✅ Can be safely stopped';
1490+
14821491
const message = [
14831492
'═══════════════════════════════════════════',
14841493
isPaused ? '🔴 DEBUG SESSION PAUSED' : '🟢 DEBUG SESSION RUNNING',
@@ -1493,6 +1502,7 @@ export function registerDebugSessionTools(_context: vscode.ExtensionContext): vs
14931502
`• Name: ${sessionInfo.name}`,
14941503
`• Type: ${sessionInfo.type}`,
14951504
`• Request: ${sessionInfo.configuration.request || 'N/A'}`,
1505+
`• Launch Method: ${launchMethod}`,
14961506
`• Main Class: ${sessionInfo.configuration.mainClass || 'N/A'}`,
14971507
'',
14981508
'───────────────────────────────────────────',

0 commit comments

Comments
 (0)