Make Module 24 lab scripts tolerate code-fence-wrapped JSON #23
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Both
reviewer.pyandtriage.pycalljson.loads()directly on the saved AI response. Chat assistants very commonly wrap JSON in a ```json fence even when told to "return only the JSON." The canned samples are clean so the loop appears to work, but at the actual point of the lab (save the AI's JSON and apply it) the most likely real output fails with a controlled error ("could not read a JSON … Expecting value: line 1 column 1 (char 0)") and exit 1 — for a persona whose entire prior workflow is copy-pasting from a browser chat.Evidence
modules/24-assistive-agents/lab/reviewer.py(~line 43):review = json.loads(Path(args.response).read_text());modules/24-assistive-agents/lab/triage.pysame (~line 52). README "do it for real" steps tell the persona to save the AI's JSON and apply it.Reproduced: fenced JSON → error message + exit 1.
Why it matters
The module's central "do it for real" step is most likely to fail on the realistic output, while the clean canned samples hide it. The fix is vendor-agnostic robustness.
Proposed change
Before
json.loadsin both scripts, strip a leading/trailing ```json fence (or extract the first{...}block).triage.pyalready importsre; use stdlib only (no new deps). At minimum, also note in the README save step to delete fence lines first — but the in-script tolerant parse is the kinder fix since the persona hits this live.Acceptance criteria
reviewer.pyandtriage.pyparse both clean JSON and ```json-fenced JSON.Affected files
modules/24-assistive-agents/lab/reviewer.py,modules/24-assistive-agents/lab/triage.py,modules/24-assistive-agents/README.mdReferences
Source finding F37 (realVotes 3/3).
Filed from an adversarial multi-agent course review (217 raw findings → 54 adversarially-verified survivors). Scoped for manual review; intentionally not auto-assigned to an agent.