Problem
gsd_complete_slice fails with Expected ',' or '}' after property value in JSON at position N when a large narrative parameter causes the agent to emit malformed JSON. GSD does not recognise this as a tool-invocation error, so instead of pausing with a clear message it silently retries the unit — requiring manual user intervention.
Root Cause
TOOL_INVOCATION_ERROR_RE in auto-tool-tracking.js line 86 expects Expected ',' or '}' in JSON but Node.js v18+ emits Expected ',' or '}' after property value in JSON at position N. The extra words "after property value" break the substring match.
// auto-tool-tracking.js:86 — current (broken):
const TOOL_INVOCATION_ERROR_RE =
/Validation failed for tool|Expected ',' or '\}' in JSON|Unexpected end of JSON|Unexpected token.*in JSON/i;
// Actual error string that should match but doesn't:
// "Expected ',' or '}' after property value in JSON at position 17663 (line 1 column 17664)"
The failed match means recordToolInvocationError() never sets s.lastToolInvocationError. When artifact verification then fails (no SUMMARY.md written), auto-post-unit.js:489 takes the retry path instead of the pause-with-clear-error path — the user sees a silent retry rather than an actionable error message.
Fix
Drop the trailing in JSON from the Expected ',' or '}' branch so it matches all variants:
// auto-tool-tracking.js:86 — fix:
const TOOL_INVOCATION_ERROR_RE =
/Validation failed for tool|Expected ',' or '\}'|Unexpected end of JSON|Unexpected token.*in JSON/i;
Or equivalently:
/Validation failed for tool|Expected ',' or '\}'.*in JSON|Unexpected end of JSON|Unexpected token.*in JSON/i;
Expected Behavior
When the LLM emits invalid JSON for gsd_complete_slice (or any GSD tool), GSD should:
- Recognise the error via
isToolInvocationError()
- Set
s.lastToolInvocationError
- After artifact verification fails, enter the
if (s.lastToolInvocationError) branch at auto-post-unit.js:489 and pause auto-mode with a clear notification: "Tool invocation failed for complete-slice: … Structured argument generation failed — pausing auto-mode."
Secondary Symptom (not a separate bug)
After the user manually fixed the JSON and gsd_complete_slice succeeded, the agent showed "Working" until cancelled. The handleCompleteSlice post-write pipeline (renderAllProjections → renderStateProjection → deriveState) performs NFS I/O on a hard-mounted NFS share. The idle watchdog (auto-timers.js, interval 15 s, default threshold 10 min) would have recovered the stalled tool after 10 minutes, but the user cancelled first. No code change needed; the watchdog works correctly — the 10-minute threshold just exceeds user patience for a closure unit.
Environment
- GSD version: 2.67.0
- Model: claude-haiku-4-5 (complete-slice unit)
- Unit:
complete-slice/M022/S02
- Milestone: M022, Slice S02
Reproduction Context
complete-slice agent calls gsd_complete_slice with narrative > ~15 KB
- Agent-generated JSON contains a value that causes
JSON.parse to throw Expected ',' or '}' after property value in JSON at position N
- GSD fails to recognise this as a tool-invocation error → retries instead of pausing
Forensic Evidence
auto-tool-tracking.js:86 — TOOL_INVOCATION_ERROR_RE does not match Expected ',' or '}' after property value
auto.js:204 — recordToolInvocationError only sets lastToolInvocationError if isToolInvocationError() returns true
auto-post-unit.js:489 — pause branch never reached because lastToolInvocationError is null
- Activity log
443-complete-slice-M022-S02.jsonl: 22 tool calls, 0 errors, successful completion after user intervention
- Note:
executeCompleteMilestone has a sanitizeCompleteMilestoneParams() call (workflow-tool-executors.js:201) but executeSliceComplete has no equivalent sanitizer — a parallel fix would add one
Auto-generated by /gsd forensics
Problem
gsd_complete_slicefails withExpected ',' or '}' after property value in JSON at position Nwhen a largenarrativeparameter causes the agent to emit malformed JSON. GSD does not recognise this as a tool-invocation error, so instead of pausing with a clear message it silently retries the unit — requiring manual user intervention.Root Cause
TOOL_INVOCATION_ERROR_REinauto-tool-tracking.jsline 86 expectsExpected ',' or '}' in JSONbut Node.js v18+ emitsExpected ',' or '}' after property value in JSON at position N. The extra words "after property value" break the substring match.The failed match means
recordToolInvocationError()never setss.lastToolInvocationError. When artifact verification then fails (no SUMMARY.md written),auto-post-unit.js:489takes the retry path instead of the pause-with-clear-error path — the user sees a silent retry rather than an actionable error message.Fix
Drop the trailing
in JSONfrom theExpected ',' or '}'branch so it matches all variants:Or equivalently:
Expected Behavior
When the LLM emits invalid JSON for
gsd_complete_slice(or any GSD tool), GSD should:isToolInvocationError()s.lastToolInvocationErrorif (s.lastToolInvocationError)branch atauto-post-unit.js:489and pause auto-mode with a clear notification:"Tool invocation failed for complete-slice: … Structured argument generation failed — pausing auto-mode."Secondary Symptom (not a separate bug)
After the user manually fixed the JSON and
gsd_complete_slicesucceeded, the agent showed "Working" until cancelled. ThehandleCompleteSlicepost-write pipeline (renderAllProjections→renderStateProjection→deriveState) performs NFS I/O on a hard-mounted NFS share. The idle watchdog (auto-timers.js, interval 15 s, default threshold 10 min) would have recovered the stalled tool after 10 minutes, but the user cancelled first. No code change needed; the watchdog works correctly — the 10-minute threshold just exceeds user patience for a closure unit.Environment
complete-slice/M022/S02Reproduction Context
complete-sliceagent callsgsd_complete_slicewithnarrative> ~15 KBJSON.parseto throwExpected ',' or '}' after property value in JSON at position NForensic Evidence
auto-tool-tracking.js:86—TOOL_INVOCATION_ERROR_REdoes not matchExpected ',' or '}' after property valueauto.js:204—recordToolInvocationErroronly setslastToolInvocationErrorifisToolInvocationError()returns trueauto-post-unit.js:489— pause branch never reached becauselastToolInvocationErroris null443-complete-slice-M022-S02.jsonl: 22 tool calls, 0 errors, successful completion after user interventionexecuteCompleteMilestonehas asanitizeCompleteMilestoneParams()call (workflow-tool-executors.js:201) butexecuteSliceCompletehas no equivalent sanitizer — a parallel fix would add oneAuto-generated by
/gsd forensics