{"record":{"id":"bd347d043bbe138f","repo":"can1357/oh-my-pi","slug":"no-active-stack-frame-run-stack-trace-first-or-su","errorCode":null,"errorMessage":"No active stack frame. Run stack_trace first or supply frame_id.","messagePattern":"No active stack frame\\. Run stack_trace first or supply frame_id\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/dap/session.ts","lineNumber":1067,"sourceCode":"\t\t\t\t...(frameCount !== undefined ? { levels: frameCount } : {}),\n\t\t\t} satisfies DapStackTraceArguments,\n\t\t\tsignal,\n\t\t\ttimeoutMs,\n\t\t);\n\t\tsession.lastStackFrames = response?.stackFrames ?? [];\n\t\tthis.#applyTopFrame(session, session.lastStackFrames[0]);\n\t\treturn {\n\t\t\tsnapshot: buildSummary(session),\n\t\t\tstackFrames: session.lastStackFrames,\n\t\t\ttotalFrames: response?.totalFrames,\n\t\t};\n\t}\n\n\tasync scopes(frameId: number | undefined, signal?: AbortSignal, timeoutMs: number = 30_000) {\n\t\tconst session = this.#touchActiveSession();\n\t\tconst resolvedFrameId = frameId ?? session.stop.frameId;\n\t\tif (resolvedFrameId === undefined) {\n\t\t\tthrow new Error(\"No active stack frame. Run stack_trace first or supply frame_id.\");\n\t\t}\n\t\tconst response = await this.#sendRequestWithConfig<DapScopesResponse>(\n\t\t\tsession,\n\t\t\t\"scopes\",\n\t\t\t{ frameId: resolvedFrameId } satisfies DapScopesArguments,\n\t\t\tsignal,\n\t\t\ttimeoutMs,\n\t\t);\n\t\treturn { snapshot: buildSummary(session), scopes: response?.scopes ?? [] };\n\t}\n\n\tasync variables(variableReference: number, signal?: AbortSignal, timeoutMs: number = 30_000) {\n\t\tconst session = this.#touchActiveSession();\n\t\tconst response = await this.#sendRequestWithConfig<DapVariablesResponse>(\n\t\t\tsession,\n\t\t\t\"variables\",\n\t\t\t{ variablesReference: variableReference } satisfies DapVariablesArguments,\n\t\t\tsignal,","sourceCodeStart":1049,"sourceCodeEnd":1085,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/dap/session.ts#L1049-L1085","documentation":"DapSessionManager.scopes needs a stack frame id to request variable scopes from the adapter. It resolves frameId from the argument or from the session's last recorded stop (set by stack_trace). If neither exists — the session never stopped or stack_trace was never run — there is no frame to query, so it throws.","triggerScenarios":"Calling scopes() on a session that has not hit a breakpoint/stop and without a frameId argument; calling scopes() after the stop state was cleared (resumed/terminated); passing frameId: undefined explicitly while no stack trace was captured.","commonSituations":"Tool flow calls scopes before running stack_trace; evaluating scopes after the program resumed so stop.frameId was invalidated; session attached but program running (no stop events yet); new session created without any stop recorded.","solutions":["Run the stack_trace tool/request first so the session records a stop frame, then call scopes()","Pass an explicit numeric frameId obtained from a previous stack_trace response","Only call scopes() while the debuggee is stopped (after a stopped event); check session status first","If the program resumed, break again before querying scopes"],"exampleFix":"// before\nconst scopes = await manager.scopes(undefined); // no stop recorded\n// after\nconst trace = await manager.stackTrace(undefined);\nconst frameId = trace.stackFrames[0]?.id;\nif (frameId === undefined) throw new Error('debuggee not stopped');\nconst scopes = await manager.scopes(frameId);","handlingStrategy":"validation","validationCode":"const active = session.status === 'stopped' ? session.stop?.frameId : undefined;\nif (active === undefined) {\n  await manager.stackTrace(); // record the stop frame first\n}","typeGuard":"function hasActiveFrame(session: DapSession): session is DapSession & { stop: { frameId: number } } {\n  return typeof session.stop?.frameId === 'number';\n}","tryCatchPattern":"try {\n  return await manager.scopes(frameId);\n} catch (err) {\n  if (String((err as Error).message).includes('No active stack frame')) {\n    await manager.stackTrace();\n    return await manager.scopes(undefined); // retry with recorded frame\n  }\n  throw err;\n}","preventionTips":["Always run stack_trace immediately after a stopped event before scopes/variables","Only call scopes while the debuggee is paused; resume invalidates frame ids","Pass explicit frameId from prior stack_trace output rather than relying on session state","Check session status before variable queries in tool flows"],"tags":["dap","state","prerequisite","debug-adapter"],"backgroundTag":"missing-prerequisite-state","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}