Repository navigation
Conversation
#786) 95ed4cc (#675), the #656 fix, made repair_json_string parse a whole reply before its fenced blocks. json-repair turns bracketed prose into list items, so a reply citing [OWASP A03](...) or items[0] before its ```json block, or request.args["id"] after it, came back as a list such as [["OWASP A03"], {"findings": [...]}]. parse_review_response could not read it and dropped every finding; the agent loop takes the same path for every structured output. Fenced blocks come first again. Each block's value is decoded with json.JSONDecoder.raw_decode, which reads string values whole, so a fence nested in one never ends the block, the case #656 fixed. Only a block that needs repair is cut, at a line holding nothing but the closing fence. Repairing the whole reply stays the last resort. Closes #786
Owner
Author
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.
Summary
This is a critical fix for v0.2.24. 95ed4cc (#675), which fixed #656, made
repair_json_stringparse the whole reply before its fenced blocks. json-repair turns bracketed prose into list items. A reply that cites[OWASP A03](…)oritems[0]before its ```json block, orrequest.args["id"]after it, therefore came back as a list such as `[["OWASP A03"], {"findings": [...]}]`. `parse_review_response` couldn't read that list and dropped every finding in the reply. The agent loop takes the same path for every structured output.Fix
json.JSONDecoder.raw_decode, which reads string values whole, so a fence nested inside a string value never ends the block. That was the case fix(ai): response repair cuts fenced json at inner code fences and misreports validation errors #656 fixed.```pythonline no longer closes it.Verification
Each reply holds the same three findings:
[OWASP A03](https://…)in the prose, then the block`items[0]`in the prose, then the block`request.args["id"]`tests/test_response_repair_fences.pycovers each table row throughparse_review_response, nested fences inside a string value, a json block followed by a python example block, a fencedwrite_filetool call, a malformed block between bracketed prose, and a bare JSON reply. 7 of its 9 tests failed before the fix.tests/test_batch_2_review_defects.pystill pass.devops cipasses; the test stage took 1m 33s.Closes #786