can1357/oh-my-pi · error · ToolError
No active debug session. Launch or attach first.
Error message
No active debug session. Launch or attach first.
What it means
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.
Source
Thrown at packages/coding-agent/src/tools/debug.ts:558
function validateLaunchProgram(
program: string,
cwd: string,
programKind: LaunchProgramKind,
adapter: DapResolvedAdapter,
): void {
if (programKind !== "directory" || adapter.acceptsDirectoryProgram) return;
const displayPath = formatPathRelativeToCwd(program, cwd, { trailingSlash: true });
throw new ToolError(
`launch program resolves to a directory: ${displayPath}. Pass an executable file path or choose an adapter that supports package directories.`,
);
}
interface DebugRenderArgs extends Partial<DebugParams> {}
function getActiveSessionSnapshot(): DapSessionSummary {
const snapshot = dapSessionManager.getActiveSession();
if (!snapshot) {
throw new ToolError("No active debug session. Launch or attach first.");
}
return snapshot;
}
function requireCapability(capability: keyof DapCapabilities, description: string): DapSessionSummary {
const snapshot = getActiveSessionSnapshot();
if (dapSessionManager.getCapabilities()?.[capability] !== true) {
throw new ToolError(`Current adapter does not support ${description}`);
}
return snapshot;
}
function resolveDisassemblyReference(memoryReference: string | undefined): string {
if (memoryReference) {
return memoryReference;
}
const snapshot = getActiveSessionSnapshot();
if (snapshot.instructionPointerReference) {View on GitHub (pinned to 9690622007)
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.
Example fix
// before
debugTool({ action: "stack_trace" })
// after
debugTool({ action: "launch", program: "./app.py" });
debugTool({ action: "stack_trace" }) Defensive patterns
Strategy: validation
Validate before calling
// Only issue non-launch/attach actions after a successful launch/attach:
const launched = await debugTool({ action: "launch", program });
if (!launched.snapshot) throw new Error("no session established"); Type guard
function hasActiveSession(s: { snapshot?: unknown } | undefined): s is { snapshot: object } {
return !!s && "snapshot" in s && s.snapshot != null;
} Try / catch
try {
return await debugTool({ action });
} catch (e) {
if (String(e).includes("No active debug session")) {
await debugTool({ action: "launch", program });
return await debugTool({ action });
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- launch program resolves to a directory: ${displayPath}. Pass
- Current adapter does not support ${description}
- disassemble requires memory_reference unless the current sto
- program is required for launch
- No debugger adapter available. Installed adapters: ${getConf
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/df973a6fc6db3f93.
Report an issue: GitHub.