{"record":{"id":"df973a6fc6db3f93","repo":"can1357/oh-my-pi","slug":"no-active-debug-session-launch-or-attach-first-df973a","errorCode":null,"errorMessage":"No active debug session. Launch or attach first.","messagePattern":"No active debug session\\. Launch or attach first\\.","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/debug.ts","lineNumber":558,"sourceCode":"function validateLaunchProgram(\n\tprogram: string,\n\tcwd: string,\n\tprogramKind: LaunchProgramKind,\n\tadapter: DapResolvedAdapter,\n): void {\n\tif (programKind !== \"directory\" || adapter.acceptsDirectoryProgram) return;\n\tconst displayPath = formatPathRelativeToCwd(program, cwd, { trailingSlash: true });\n\tthrow new ToolError(\n\t\t`launch program resolves to a directory: ${displayPath}. Pass an executable file path or choose an adapter that supports package directories.`,\n\t);\n}\n\ninterface DebugRenderArgs extends Partial<DebugParams> {}\n\nfunction getActiveSessionSnapshot(): DapSessionSummary {\n\tconst snapshot = dapSessionManager.getActiveSession();\n\tif (!snapshot) {\n\t\tthrow new ToolError(\"No active debug session. Launch or attach first.\");\n\t}\n\treturn snapshot;\n}\n\nfunction requireCapability(capability: keyof DapCapabilities, description: string): DapSessionSummary {\n\tconst snapshot = getActiveSessionSnapshot();\n\tif (dapSessionManager.getCapabilities()?.[capability] !== true) {\n\t\tthrow new ToolError(`Current adapter does not support ${description}`);\n\t}\n\treturn snapshot;\n}\n\nfunction resolveDisassemblyReference(memoryReference: string | undefined): string {\n\tif (memoryReference) {\n\t\treturn memoryReference;\n\t}\n\tconst snapshot = getActiveSessionSnapshot();\n\tif (snapshot.instructionPointerReference) {","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/debug.ts#L540-L576","documentation":"The debug tool has no active DAP session, but the requested action (snapshot, set breakpoints, continue, evaluate, disassemble, etc.) requires one. dapSessionManager.getActiveSession() returned undefined because neither a launch nor an attach has completed in this session. The tool intentionally refuses to act on a nonexistent debug target rather than silently returning empty data.","triggerScenarios":"Calling any debug action other than launch/attach (e.g. action=snapshot, stack_trace, evaluate) before a successful launch or attach, or after the debug session has ended/exited.","commonSituations":"Forgetting to run launch first; the launched process already exited so the session was cleared; the agent session restarted and lost the previous debug session; attach failed earlier so no session ever became active.","solutions":["Run the debug tool with action=\"launch\" (with program) or action=\"attach\" (with pid/port) first.","Re-launch if the previous debuggee terminated, then retry the action.","Check the adapter actually started by inspecting the launch/attach result snapshot before issuing follow-up actions."],"exampleFix":"// before\ndebugTool({ action: \"stack_trace\" })\n// after\ndebugTool({ action: \"launch\", program: \"./app.py\" });\ndebugTool({ action: \"stack_trace\" })","handlingStrategy":"validation","validationCode":"// Only issue non-launch/attach actions after a successful launch/attach:\nconst launched = await debugTool({ action: \"launch\", program });\nif (!launched.snapshot) throw new Error(\"no session established\");","typeGuard":"function hasActiveSession(s: { snapshot?: unknown } | undefined): s is { snapshot: object } {\n  return !!s && \"snapshot\" in s && s.snapshot != null;\n}","tryCatchPattern":"try {\n  return await debugTool({ action });\n} catch (e) {\n  if (String(e).includes(\"No active debug session\")) {\n    await debugTool({ action: \"launch\", program });\n    return await debugTool({ action });\n  }\n  throw e;\n}","preventionTips":["Always launch or attach first; sequence subsequent actions after confirmation.","Track session lifetime — re-launch after the debuggee exits.","Handle agent/tool-session restarts by re-establishing the debug session."],"tags":["debug","dap","state-error","missing-session"],"backgroundTag":"no-active-debug-session","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}