Skip to content

Make output parsing robust to multi-line JSON and code blocks - #62

Merged
dwilding merged 1 commit into
mainfrom
robust-output-parsing
Aug 25, 2026
Merged

Make output parsing robust to multi-line JSON and code blocks#62
dwilding merged 1 commit into
mainfrom
robust-output-parsing

Conversation

@dwilding

Copy link
Copy Markdown
Owner

The agent emitted IMPLEMENTATION_RESULT with a multi-line JSON object wrapped in a code block and invented its own fields (charms_modified, claim_tested, etc.) instead of using the required title and body. Two fixes:

1. Parser robustness

The regex now handles:

  • Single-line JSON (original format)
  • Multi-line JSON
  • JSON wrapped in a ```json code block

This is a safety net — the prompt should prevent it, but the parser should not fail if the agent formats the JSON differently.

2. Stronger output contract

The prompt now explicitly states:

  • The JSON must have exactly two fieldstitle and body
  • Do not invent other fields (no charms_modified, claim_tested, run_tox_result, etc.)
  • The JSON must be on a single line — do not wrap in a code block
  • Escape newlines inside body as \n

The agent emitted IMPLEMENTATION_RESULT with a multi-line JSON object
wrapped in a json code-block wrapping (in addition to the original single-line
   format). This is a safety net — the prompt should prevent it, but
   the parser should not fail if the agent formats the JSON differently.

2. Output contract: explicitly states the JSON must have exactly two
   fields (title and body), must not invent other fields, and must be
   on a single line without code-block wrapping. Added concrete examples
   of what not to do.
@dwilding
dwilding merged commit 5d502ee into main Aug 25, 2026
2 checks passed
@dwilding
dwilding deleted the robust-output-parsing branch August 25, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant