mirror of
https://github.com/aaddrick/claude-desktop-debian.git
synced 2026-05-17 00:26:21 +03:00
The investigate call was the only Sonnet invocation in v2 without `--json-schema`. After the parser hardening in #461, re-dispatched runs produced valid JSON — but with fields omitted and creative top-level wrappers. The prompt-described schema isn't enforced without the flag, and the model was using the freedom. ## What changed Add `--json-schema "${schema}"` where `schema=$(cat .claude/scripts/schemas/investigate.json)`, matching the classify and doublecheck pattern. Output parsing prefers the CLI-validated `.structured_output` field (populated when schema fit cleanly), falling back to the existing `.result` + `extract-json.py` + shape-check path for the case where the CLI returns prose on schema miss. The hardened extraction from #461 stays in place as the safety net. ## Why post-hoc still helps Per Claude Code CLI docs (and confirmed via the claude-code-guide research), `--json-schema` applies validation after the agent loop ends — not at generation time. That's weaker than the Agent SDK's constrained decoding, but still catches the specific failures seen in the re-dispatch of #424 and #442: - Top-level `pattern_sweep` and `proposed_anchors` omitted - Per-finding `confidence` / `line_end` returned as null (violates required enum / integer) - Extra top-level fields like `summary`, `classification`, `investigation_id` If post-hoc validation isn't enough, the next escalation is the Agent SDK (constrained decoding via grammar compilation). Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>