Zero-argument tool bindings always fail in PTC mode: "binding arguments must be lossless JSON" (root cause + suggested fix) #6065
Replies: 1 comment
|
Confirmed against source, precisely. Found the actual TS source behind the lib/worker.cjs bundle you cited, in case it helps whoever picks this up: packages/code-runtime/code-runtime-worker-thread/src/bootstrap.ts, not worker.ts (the compiled filename doesn't map 1:1 to the source filename here). Lines 328-336 are exactly the pattern you describe: let detached: ReturnType And snapshotCodeJsonValue's own doc comment in worker-json.ts says exactly what you'd expect: "@returns a detached lossless-JSON snapshot, or undefined when invalid." For a zero-argument call args really is undefined, so the function's own contract makes "no arguments" and "invalid arguments" produce the identical undefined result, there's no way for the caller to tell them apart after the fact. That's the whole bug in one sentence. Your fix is the minimal correct one, since it intercepts args === undefined before it ever reaches the ambiguous snapshot call, so genuinely invalid (non-JSON, circular, etc.) arguments still fail exactly as before. Nothing about the rest of the binding-call path needs to change. Given you've already verified this locally and offered to send the exact patch, this looks ready to hand to a maintainer as-is. |
Uh oh!
There was an error while loading. Please reload this page.
Environment
run_codecode-runtime worker thread)Repro
run_codeprogram, e.g.tools.mnemon_status()(mnemon_statusdeclares no parameters).binding arguments must be lossless JSON.mnemon_status,mnemon_memory_bodies).Root cause
dsh-code-runtime-worker-thread/lib/worker.cjssnapshots call arguments before posting the call to the host:For a zero-argument call,
args === undefined; the lossless-JSON snapshot ofundefinedisundefined, so the worker rejects before the message ever reaches the host. The binding function itself never runs.Expected
Calling a zero-parameter binding — with no arguments — should invoke the binding with an empty parameter object, mirroring what the same tool receives on the direct (non-PTC) call path.
Suggested fix (applied locally, resolves the failure)
Treat only the absent arguments case as an empty parameter object; genuinely non-JSON arguments keep failing:
Impact
Every zero-parameter tool binding is unusable in PTC mode. Plugin management/status endpoints are typically zero-argument (the "dashboard" surface), so plugins lose that entire surface in PTC mode while read/write paths keep working — which makes the breakage easy to misdiagnose as data corruption.
Happy to send the exact patch as a PR if helpful.
Happy to send the exact one-line patch as a PR if helpful.
All reactions