{"record":{"id":"794d2ad539419fa6","repo":"can1357/oh-my-pi","slug":"instruction-count-is-required-for-disassemble","errorCode":null,"errorMessage":"instruction_count is required for disassemble","messagePattern":"instruction_count is required for disassemble","errorType":"validation","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/debug.ts","lineNumber":1001,"sourceCode":"\t\t\t\tconst response = await dapSessionManager.scopes(params.frame_id, combinedSignal, timeoutSec * 1000);\n\t\t\t\tdetails.snapshot = response.snapshot;\n\t\t\t\tdetails.scopes = response.scopes;\n\t\t\t\treturn result.text(formatScopes(response.scopes)).done();\n\t\t\t}\n\t\t\tcase \"variables\": {\n\t\t\t\tconst variableReference = params.variable_ref ?? params.scope_id;\n\t\t\t\tif (variableReference === undefined) {\n\t\t\t\t\tthrow new ToolError(\"variables requires variable_ref or scope_id\");\n\t\t\t\t}\n\t\t\t\tconst response = await dapSessionManager.variables(variableReference, combinedSignal, timeoutSec * 1000);\n\t\t\t\tdetails.snapshot = response.snapshot;\n\t\t\t\tdetails.variables = response.variables;\n\t\t\t\treturn result.text(formatVariables(response.variables)).done();\n\t\t\t}\n\t\t\tcase \"disassemble\": {\n\t\t\t\trequireCapability(\"supportsDisassembleRequest\", \"disassembly\");\n\t\t\t\tif (params.instruction_count === undefined) {\n\t\t\t\t\tthrow new ToolError(\"instruction_count is required for disassemble\");\n\t\t\t\t}\n\t\t\t\tconst response = await dapSessionManager.disassemble(\n\t\t\t\t\tresolveDisassemblyReference(params.memory_reference),\n\t\t\t\t\tparams.instruction_count,\n\t\t\t\t\tparams.offset,\n\t\t\t\t\tparams.instruction_offset,\n\t\t\t\t\tparams.resolve_symbols,\n\t\t\t\t\tcombinedSignal,\n\t\t\t\t\ttimeoutSec * 1000,\n\t\t\t\t);\n\t\t\t\tdetails.snapshot = response.snapshot;\n\t\t\t\tdetails.disassembly = response.instructions;\n\t\t\t\treturn result.text(formatDisassembly(response.instructions)).done();\n\t\t\t}\n\t\t\tcase \"read_memory\": {\n\t\t\t\trequireCapability(\"supportsReadMemoryRequest\", \"memory reads\");\n\t\t\t\tif (!params.memory_reference) {\n\t\t\t\t\tthrow new ToolError(\"memory_reference is required for read_memory\");","sourceCodeStart":983,"sourceCodeEnd":1019,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/debug.ts#L983-L1019","documentation":"The disassemble action throws this ToolError when params.instruction_count is undefined. Disassembly is bounded by an explicit instruction count; the tool refuses an unbounded request. The adapter capability supportsDisassembleRequest is checked before this validation.","triggerScenarios":"Calling action=disassemble without params.instruction_count (or with undefined); memory_reference and offsets are optional but count is not.","commonSituations":"Caller assumes a default window of instructions exists; params object built conditionally drops the count; confusion between instruction_offset (positioning) and instruction_count (window size).","solutions":["Pass instruction_count (positive integer), e.g. {memory_reference: '0x00400a10', instruction_count: 32}","Provide memory_reference (or a prior instruction address) to anchor the disassembly region","Keep instruction_count modest; use instruction_offset to page through larger regions"],"exampleFix":"// before\nawait debugTool.run({ action: 'disassemble', memory_reference: '0x00400a10' });\n// after\nawait debugTool.run({ action: 'disassemble', memory_reference: '0x00400a10', instruction_count: 32 });","handlingStrategy":"validation","validationCode":"if (typeof params.instruction_count !== 'number' || !Number.isInteger(params.instruction_count) || params.instruction_count <= 0) {\n  throw new Error('disassemble needs a positive integer instruction_count');\n}","typeGuard":"function hasInstructionCount(p) {\n  const c = (p as { instruction_count?: unknown }).instruction_count;\n  return typeof p === 'object' && p !== null && typeof c === 'number' && Number.isInteger(c) && c > 0;\n}","tryCatchPattern":"try {\n  await debugTool.run({ action: 'disassemble', ...params });\n} catch (err) {\n  if (err instanceof ToolError && err.message.includes('instruction_count is required')) {\n    // retry with an explicit window size, e.g. instruction_count: 32\n  } else throw err;\n}","preventionTips":["Always specify a bounded instruction_count; there is no default window","Anchor with memory_reference from a prior frame or disassemble result","Use instruction_offset for paging instead of growing the count unboundedly","Verify supportsDisassembleRequest capability before calling"],"tags":["debug","dap","parameter-validation","disassembly"],"backgroundTag":"missing-required-parameter","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}