fix(e13-s5): accept markdown-fenced JSON from real LLMs in --ai parse - #63
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Live-testing the
--aipath against a real Anthropic model (claude-sonnet-4-5, via a relay) surfaced a bug that mocked tests could not: the model returns perfectly correct content but wraps the JSON in a```json…```markdown fence, despite the system prompt asking for no markdown.ParseCoreJSON's strict decode then failed on the leading fence, so--airefused every real response — the feature was effectively unusable against live models.Fix
internal/aiparsenow strips a single outer markdown code fence before the strict JSON decode. Strictness is not weakened: after stripping it stillDisallowUnknownFields, rejects nested objects / arrays / nulls / trailing data / empty objects, and only peels one well-formed outer fence (multiple/incomplete/odd-language fences fall through to refusal).Evidence
```fence parses;fenced_unknown_fieldstill refuses (strictness not bypassed); all prior non-conforming cases still refuse.base_url=https://api.anthropic.com model=claude-3-5-sonnet-20241022 api_key={{CLAUDECM_SECRET_1}} small_fast_model=claude-3-5-haiku-20241022— parsed successfully; placeholder preserved for local re-injection.Response-parse side only; no change to the outbound redaction, secret handling, or credential path.
🤖 Generated with Claude Code