Workflow StructuredOutput: invalid JSON escapes in a field reported as 'missing required property' — blind retries, occasional schema-valid placeholder output

Status Open
Maintainer reply None cached
Activity 1 comment · opened Jul 19, 2026

Environment

  • Claude Code v2.1.215, Linux 5.15, model claude-fable-5 (orchestrator), workflow subagents on claude-opus

Summary

In a Workflow run, a schema'd agent() (StructuredOutput tool) whose long free-text field contains shell regex/escape sequences (\|, \., \$ — e.g. a fix plan quoting grep/sed patterns) can emit invalid JSON string escapes in the tool call. The runtime appears to salvage the parseable fields and then reports the corrupted field as missing required property instead of an invalid-escape error. The subagent cannot see the real cause, so it retries the same content class until the retry cap (5) is exhausted.

Observed failure modes (3 incidents across 2 runs, ~30 schema'd agents, backslash-dense domain)

  1. Hard failure (2×): agent({schema}): StructuredOutput retry cap (5) exceeded — the pipeline item's whole chain drops.
  2. Silent corruption (1×, worse): after 4 corrupted attempts the model "learned" that shorter passes, and attempt 5 was a schema-valid degenerate placeholder — literally {"rootCause": "test root cause", "fixPlan": "test fix plan", "filesToTouch": ["a.sh", "b.json"], "risks": ["risk one", "risk two"]} — which passed validation and poisoned downstream pipeline stages that consumed it as data.

Evidence (from agent transcript jsonl)

Every attempt included the field the validator called missing; sizes shrank as the model groped for the cause:

SO attempt #1 input keys: [rootCause, risks]              -> ERR: must have required property 'fixPlan', 'filesToTouch'
SO attempt #2 input keys: [rootCause, filesToTouch, risks] -> ERR: must have required property 'fixPlan'
...
SO attempt #5 (compact)                                    -> ERR: must have required property 'fixPlan'

Model text between retries shows it diagnosing blind:

"The parser is choking on the \| escape sequences in fixPlan. Let me resend with those removed." "Persistent parse failure on fixPlan despite valid content — likely a boundary issue with adjacent long fields."

Short enum/verdict schemas were unaffected: 0 failures across ~40 agents in the same runs.

Expected

  • Validation error names the real problem, e.g. invalid JSON string escape '\|' in field 'fixPlan' at offset N, so the model can correct it in one retry.
  • Ideally: reject the whole payload on invalid escapes rather than salvaging sibling fields (salvage + "missing property" is what makes the error misleading).

Repro sketch

Workflow script with agent(prompt, {schema}) where schema requires a long free-text field, and a prompt that makes the agent describe grep/sed patterns verbatim (e.g. "produce a fix plan for these grep assertions: grep -Eq 'LOCAL\|local' ..."). Failure is probabilistic but reproduced 3/~30 in this content domain.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗