exec results containing a BigInt fail to serialize #16

Closed
opened 2026-08-28 17:08:47 +09:00 by floot · 1 comment
Owner

stat() returns BigInt size/mtime/atime, and workflow status() and
journal() return BigInts too. Returning any of them from mcp__endo__exec
gives:

Error: Do not know how to serialize a BigInt

The failure is at the tool boundary, not in the capability, so every caller
pays for it. In session mt82q1ns-l8nrge the agent learned this once and then
carried a hand-rolled replacer into 75 of its 381 exec calls:

const j = v => JSON.stringify(v, (k, x) => (typeof x === 'bigint' ? String(x) : x));

That is pure copy-paste tax on the most-used tool in the system, and it hides
real results behind a stringified blob the agent then has to re-parse.

Wanted: serialize BigInt as a decimal string (or { $bigint }) at the
exec boundary so callers can just return what a capability gave them.

`stat()` returns BigInt `size`/`mtime`/`atime`, and workflow `status()` and `journal()` return BigInts too. Returning any of them from `mcp__endo__exec` gives: ``` Error: Do not know how to serialize a BigInt ``` The failure is at the tool boundary, not in the capability, so every caller pays for it. In session `mt82q1ns-l8nrge` the agent learned this once and then carried a hand-rolled replacer into **75 of its 381 exec calls**: ```js const j = v => JSON.stringify(v, (k, x) => (typeof x === 'bigint' ? String(x) : x)); ``` That is pure copy-paste tax on the most-used tool in the system, and it hides real results behind a stringified blob the agent then has to re-parse. **Wanted:** serialize BigInt as a decimal string (or `{ $bigint }`) at the exec boundary so callers can just `return` what a capability gave them.
Author
Owner

Fixed in 914285f, live on this host since generation 42. renderToolResult renders BigInts as decimal strings at the exec boundary. Verified by returning a stat() record verbatim - { size: "408", mtime: "1786825186213908033" } - with no hand-rolled replacer, which previously threw.

Fixed in 914285f, live on this host since generation 42. `renderToolResult` renders BigInts as decimal strings at the exec boundary. Verified by returning a `stat()` record verbatim - `{ size: "408", mtime: "1786825186213908033" }` - with no hand-rolled replacer, which previously threw.
floot closed this issue 2026-09-01 14:05:21 +09:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
floot/endo#16
No description provided.