You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
execute/search return formatter errors for non-JSON sandbox results #208
execute and search can return JavaScript values that cross the Worker RPC boundary successfully but are not JSON-stringifiable. The shared response formatter then throws and turns a successful sandbox program into an MCP tool error.
Error: Cannot read properties of undefined (reading 'length')
Error: Do not know how to serialize a BigInt
Error: Converting circular structure to JSON
Reproduction / evidence
Reproduced through the real MCP tool path on the current branch state using Node 22.23.2. Each value fails through both execute and search.
The direct root cause is in src/truncate.ts: every non-string goes through JSON.stringify(content, null, 2), then the result is treated as a string. undefined produces no string; BigInt and cyclic objects make JSON serialization throw.
Existing truncation tests cover strings, objects, large values, empty string, null, and arrays, but not these structured-clone values.
Expected behavior
A sandbox program that completes successfully should produce a valid MCP text result (using a deliberate representation for values JSON cannot encode), rather than an internal response-formatting exception.
Likely scope
This appears narrowly fixable in response formatting plus regression coverage. It should not require auth/token, deployment, dependency, or OpenAPI pipeline changes.
Duplicate / ownership check
I searched open/closed issues and PRs for the exact errors, truncateResponse, undefined/no-return, BigInt, and circular-result behavior and did not find a matching report or active fix. Issue #68 is broader model-evaluation work and does not appear to cover this formatter defect.
If this is a useful fix, I can take it; assignment or maintainer direction would be appreciated before I implement it.
changed the title [-]execute/search return internal error when sandbox code has no return value[/-][+]execute/search return formatter errors for non-JSON sandbox results[/+]on Sep 7, 2026
Activity
[-]execute/search return internal error when sandbox code has no return value[/-][+]execute/search return formatter errors for non-JSON sandbox results[/+]