Workflow tool: object passed as `args` arrives in the script as a JSON-encoded string
Environment
- Claude Code CLI, model claude-fable-5, Linux (Arch, 6.18.22-1-lts)
- Workflow tool (multi-agent orchestration)
Symptom
Passing a JSON object in the Workflow tool call's args parameter delivers a JSON-encoded string to the script's args global. A script doing args.worktrees.map(...) crashes:
Error: undefined is not an object (evaluating 'worktrees.map')
The failure notification's recovery hint itself shows the value string-wrapped: args: "{\"worktrees\":[...]}" — i.e. the object was serialized somewhere between the tool call and the script sandbox.
Why it matters
The tool description explicitly instructs: "Pass arrays/objects as actual JSON values in the tool call, NOT as a JSON-encoded string — a stringified list reaches the script as one string, so args.filter/args.map throw." The model complies, but the harness stringifies anyway, so every args-driven workflow fails on first run.
Workaround
Guard at the top of every script:
const input = typeof args === 'string' ? JSON.parse(args) : args
(Resume with resumeFromRunId after patching works fine.)
Suggested fix
Either deliver args verbatim as parsed JSON into the script sandbox, or (defensively) auto-JSON.parse in the runtime when args is a string that parses as JSON — matching the documented contract.
🤖 Generated with Claude Code
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗