Repository navigation
Closed
Labels
priority/p1-highPriority P1: high-impact work for the next planned milestonescope/aiAI review pipeline, personas, prompts, LLM client, or RAGtype/bugType bug: the code does not do what it must
Milestone
Description
Summary
Found in the release/v0.2.23 review (line numbers at 7fdaa9d).
- Model replies that put JSON inside a fence lose data. Given a
json fence whose first finding has apython block in itsfixfield,repair_json_stringreturns 1 of 3 findings, and that finding hasfix: "". This was reproduced directly.- It is reached from
parse_review_response(src/devops_cli/ai/review_schema.py:1336-1340) and from agent tool-call parsing (src/devops_cli/ai/agents/agent.py:896,:1084). write_filetool arguments that contain a fence are cut short in the same way, so the target file is overwritten with truncated content.mainkept the whole object.
- It is reached from
- Retry reflections name the wrong error. When the repaired data fails a field check, the reflection reports
root: Invalid JSONinstead of the field that failed (e.g.count: valid integer), so the model spends its retries on the wrong problem. - Agents with plain-text output now make two model calls and raise.
PydanticAgent(output_type=str)andTextOutputagents raiseUnexpectedModelBehavior, wheremainreturned the text after one call.
Root Cause
_JSON_FENCEinsrc/devops_cli/ai/response_repair.py:48is a non-greedy match that ends at the next triple backtick anywhere, including inside a JSON string.repair_json_string(:61-66) returns the repaired fragment before it ever tries the whole text._parse_schema_model(response_repair.py:373-379) setslast_err = json_err or last_err. Thejson_invaliderror from validating the raw text replaces the field-levelValidationErrorfrom the repaired data.- The schema-retry stage (
ai/agents/agent.py:960-972,ai/agents/runner.py:455-482) treatsparsed_model is Noneas a validation failure. Forstroutputs, validation fails becauseTypeAdapter(str).validate_jsonrejects plain text. ForTextOutputwith aRunContextor async function,_text_only_functiondeliberately returnsNone.
Remediation Plan
- Parse the whole cleaned text first. Fall back to fenced blocks only when that yields no dict or list, and anchor closing fences to a line of their own.
- Prefer the most specific validation error: field-level errors from the repaired data win over raw-text JSON errors.
- Run schema retries only for structured output types. Plain-text outputs return after one call.
- Add regression tests:
- a nested fence inside
fix: all findings survive andfixis intact; write_filearguments containing a fence arrive whole;- the reflection names the failing field;
- an
output_type=stragent makes one call.
- a nested fence inside
Metadata
Metadata
Assignees
Labels
priority/p1-highPriority P1: high-impact work for the next planned milestonescope/aiAI review pipeline, personas, prompts, LLM client, or RAGtype/bugType bug: the code does not do what it must
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(review): remediate response repair, review pipeline and verifier …
dan-petty commentedon Sep 28, 2026
Closed by #675, merged into
release/v0.2.23.GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by
devops gh issues close-merged.