can1357/oh-my-pi · error · ToolError
count is required for read_memory
Error message
count is required for read_memory
What it means
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.
Source
Thrown at packages/coding-agent/src/tools/debug.ts:1022
resolveDisassemblyReference(params.memory_reference),
params.instruction_count,
params.offset,
params.instruction_offset,
params.resolve_symbols,
combinedSignal,
timeoutSec * 1000,
);
details.snapshot = response.snapshot;
details.disassembly = response.instructions;
return result.text(formatDisassembly(response.instructions)).done();
}
case "read_memory": {
requireCapability("supportsReadMemoryRequest", "memory reads");
if (!params.memory_reference) {
throw new ToolError("memory_reference is required for read_memory");
}
if (params.count === undefined) {
throw new ToolError("count is required for read_memory");
}
const response = await dapSessionManager.readMemory(
params.memory_reference,
params.count,
params.offset,
combinedSignal,
timeoutSec * 1000,
);
details.snapshot = response.snapshot;
details.memoryAddress = response.address;
details.memoryData = response.data;
details.unreadableBytes = response.unreadableBytes;
return result.text(formatMemoryRead(response.address, response.data, response.unreadableBytes)).done();
}
case "write_memory": {
requireCapability("supportsWriteMemoryRequest", "memory writes");
if (!params.memory_reference) {
throw new ToolError("memory_reference is required for write_memory");View on GitHub (pinned to 9690622007)
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.
Example fix
// before
await debugTool.run({ action: "read_memory", memory_reference: ref });
// after
await debugTool.run({ action: "read_memory", memory_reference: ref, count: 256 }); Defensive patterns
Strategy: validation
Validate before calling
if (typeof count !== "number" || !Number.isInteger(count) || count <= 0) throw new Error("read_memory requires a positive integer count"); Type guard
function hasCount(p: { count?: number }): p is { count: number } {
return typeof p.count === "number" && p.count > 0;
} Try / catch
try {
await debugTool.run({ action: "read_memory", memory_reference: ref, count: 256 });
} catch (err) {
if (err instanceof ToolError && err.message.includes("count is required")) {
// supply a sensible default byte count and retry once
} else throw err;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- memory_reference is required for read_memory
- memory_reference is required for write_memory
- data is required for write_memory
- command is required for custom_request
- Debugger reported no threads.
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/7801e5ec95476077.
Report an issue: GitHub.