{"record":{"id":"7801e5ec95476077","repo":"can1357/oh-my-pi","slug":"count-is-required-for-read-memory","errorCode":null,"errorMessage":"count is required for read_memory","messagePattern":"count is required for read_memory","errorType":"validation","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/debug.ts","lineNumber":1022,"sourceCode":"\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\");\n\t\t\t\t}\n\t\t\t\tif (params.count === undefined) {\n\t\t\t\t\tthrow new ToolError(\"count is required for read_memory\");\n\t\t\t\t}\n\t\t\t\tconst response = await dapSessionManager.readMemory(\n\t\t\t\t\tparams.memory_reference,\n\t\t\t\t\tparams.count,\n\t\t\t\t\tparams.offset,\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.memoryAddress = response.address;\n\t\t\t\tdetails.memoryData = response.data;\n\t\t\t\tdetails.unreadableBytes = response.unreadableBytes;\n\t\t\t\treturn result.text(formatMemoryRead(response.address, response.data, response.unreadableBytes)).done();\n\t\t\t}\n\t\t\tcase \"write_memory\": {\n\t\t\t\trequireCapability(\"supportsWriteMemoryRequest\", \"memory writes\");\n\t\t\t\tif (!params.memory_reference) {\n\t\t\t\t\tthrow new ToolError(\"memory_reference is required for write_memory\");","sourceCodeStart":1004,"sourceCodeEnd":1040,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/debug.ts#L1004-L1040","documentation":"For action=\"read_memory\", the tool requires an explicit count of bytes to read; the DAP readMemory request needs it to bound the transfer. The tool rejects the call with a ToolError before any adapter round-trip when params.count is undefined. This prevents unbounded memory reads and matches the DAP request contract.","triggerScenarios":"Calling the debug tool with action=\"read_memory\" and a valid memory_reference but omitting params.count (or passing undefined). Also occurs when count is accidentally placed under a different key (bytes, size, length).","commonSituations":"LLM-generated tool calls that include the memory reference but forget the byte count; scripts ported from DAP clients where count was optional at a higher abstraction layer; callers expecting a default read size that this tool does not provide.","solutions":["Add an explicit byte count to the call, e.g. count: 256, keeping it reasonable (reads are formatted as hex dumps).","Confirm the parameter name is count, not size/length/bytes.","If you want progressive reading, keep count fixed and vary params.offset instead of omitting count.","Pair with a valid memory_reference — the memory_reference check runs first, so this error means that check already passed."],"exampleFix":"// before\nawait debugTool.run({ action: \"read_memory\", memory_reference: ref });\n// after\nawait debugTool.run({ action: \"read_memory\", memory_reference: ref, count: 256 });","handlingStrategy":"validation","validationCode":"if (typeof count !== \"number\" || !Number.isInteger(count) || count <= 0) throw new Error(\"read_memory requires a positive integer count\");","typeGuard":"function hasCount(p: { count?: number }): p is { count: number } {\n  return typeof p.count === \"number\" && p.count > 0;\n}","tryCatchPattern":"try {\n  await debugTool.run({ action: \"read_memory\", memory_reference: ref, count: 256 });\n} catch (err) {\n  if (err instanceof ToolError && err.message.includes(\"count is required\")) {\n    // supply a sensible default byte count and retry once\n  } else throw err;\n}","preventionTips":["Centralize read_memory invocation in a helper whose signature requires count.","Pick bounded chunk sizes (e.g. 64–256 bytes) and iterate with offset for larger regions.","Never rely on defaults — this tool has none for count."],"tags":["debugger","dap","parameter-validation","missing-parameter"],"backgroundTag":"missing-required-parameter","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}