Skip to content

[local-verify-review-agents-must-return-json-ve] Verify/review agents must return JSON verdict, not ReportFindings tool output - #856

Open
danii1 wants to merge 1 commit into
mainfrom
feature/local-verify-review-agents-must-return-json-ve
Open

danii1 wants to merge 1 commit into
mainfrom
feature/local-verify-review-agents-must-return-json-ve

Conversation

@danii1

@danii1 danii1 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Why

Task local-verify-review-agents-must-return-json-ve: Verify/review agents must return JSON verdict, not ReportFindings tool output

Run 1674 escalated because the verify agent sent its findings through Claude Code's built-in ReportFindings tool. That output never reaches stdout, so parseReviewFeedback found no approved JSON. The retry used the same prompt and failed the same way.

What changed

  • Harness: packages/agent-harness has a new AgentRunOptions.disallowedTools. claude-code turns it into --disallowedTools a,b, and other harnesses ignore it. I checked the installed claude 2.1.336. An unknown tool name only prints a warning, so the flag is safe on CLIs that lack the tool.
  • New module: review/verdict-delivery.ts holds VERDICT_DISALLOWED_TOOLS (ReportFindings), VERDICT_DELIVERY_NOTE and buildVerdictFollowUpPrompt.
  • Plumbing: a new verdict option on runAgentPrompt and address.ts's runAgent sets the restriction. It is passed for verify and auto-review turns. The merge-safety review in auto-merge.ts also passes it.
  • Pipeline types: pipeline-registry.ts and run-harness-finalize.ts pass verdict through, so verify reaches runAgentPrompt with it.
  • Auto-review fix turns: these edit code and are unchanged.
  • Prompts: verify appends the note that the JSON must be the final text and must not go through ReportFindings. prompts/review.md says the same.
  • Retry: if the first verify reply has no parseable JSON, verify sends one short follow-up asking only for the verdict, using the tail of the previous reply. It does not re-run the full review. The existing two-attempt loop is unchanged.
  • Tests: a harness test for the flag and two verify tests (prompt text with the verdict flag, and the follow-up path).

Scope

Included: verify, auto-review and merge-safety turns, the claude-code flag, prompts, and tests. Not changed: the verdict schema, the approval policy, and the merge-safety prompt text and rules. webhook/agent-review.ts is untouched because it posts prose and has no JSON verdict.

Tradeoffs

  • I didn't edit merge-safety.md, because a test pins that prompt's text and the task puts auto-merge safety rules out of scope. That turn is protected only by the tool restriction.
  • The follow-up reuses the tail of the previous reply (last 4000 characters), so it may lose context on very long reviews.
  • A small comment in run-harness-finalize.ts was shortened to stay under the 1000-line lint limit.

Blast Radius

  • Callers of runAgentPrompt, address.ts's runAgent and the pipeline runAgentPrompt gain an optional field.
  • Without verdict, argv is unchanged, so implementation turns do not get the flag.
  • On claude-code, review, verify and merge-safety invocations gain --disallowedTools ReportFindings.
  • Verify can now spend one extra agent call before its existing retry.

Verification

  • Ran bun run test in packages/code: 6529 pass, 0 fail. An earlier run had one failure, the merge-safety prompt-equality test, which came from my edit to that prompt. I reverted the edit and the test passes.
  • Ran bun test tests/harnesses.test.ts in packages/agent-harness: 110 pass.
  • bun run typecheck and bun run lint pass in packages/code. Lint had flagged run-harness-finalize.ts at 1001 lines against the 1000-line limit, and it passes after the comment trim.
  • There is no test that inspects the runAgentPrompt arguments to show verify turns get the restriction and implementation turns don't. That behavior is covered by the harness flag test and the verify test that checks the verdict option is passed.
  • I haven't run a live Claude Code review against a real PR.

🤖 Opened by DevIntern from local-verify-review-agents-must-return-json-ve

…fy/review agents must return JSON verdict, not ReportFindings tool output
@danii1 danii1 added the devintern-authored Pull request written by DevIntern working its own backlog label Dec 4, 2026
@danii1

danii1 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Artifacts & verification

Run: 1737 · Commit: c03a50d3ca7226ce74cfb93b09708e63a2a6ad20

Verification report

Produced by __verify-1, execution 1 at c03a50d3ca7226ce74cfb93b09708e63a2a6ad20.

Show artifact
{
  "summary": "The core fix is in place and checks out. ClaudeCodeHarness gets a typed `disallowedTools` option that emits `--disallowedTools`. Verdict turns in verify, auto-review and auto-merge set `verdict: true`. The verify prompt and review.md now say the JSON must be the final text and that ReportFindings must not be used. Verify retries once with a JSON-only follow-up prompt. I ran `bun run test tests/verify-step.test.ts` in packages/code (22 pass) and the agent-harness harnesses test file (110 pass). I confirmed that the installed claude CLI lists `--disallowedTools`. I did not run it with an unknown tool name, which the task asked to check first. I did not run typecheck, lint or the full suite. Gaps: nothing tests the verdict-to-disallowedTools wiring in runAgentPrompt or address.runAgent, and the merge-safety prompts were not updated.",
  "items": [
    {
      "priority": "medium",
      "confidence": "medium",
      "category": "testing",
      "file": "packages/code/src/lib/review/auto-review-loop.ts",
      "line": "372",
      "issue": "The acceptance criterion 'the claude-code invocation for verify/review includes the restriction, and implementation turns do not' has no test at the code-package level. The new tests cover ClaudeCodeHarness.buildArgs and the verify-step `verdict` flag, but not the conversion from `verdict: true` to `disallowedTools` in runAgentPrompt or address.runAgent.",
      "evidence": "grep -rn disallowedTools src tests in packages/code: only src hits, no test hits.",
      "suggestion": "Add a test that runAgentPrompt with verdict:true builds args containing --disallowedTools ReportFindings, and that without it they are absent."
    },
    {
      "priority": "medium",
      "confidence": "low",
      "category": "bug",
      "file": "packages/code/prompts/merge-safety.md",
      "line": "1",
      "issue": "The auto-merge turn now disables ReportFindings via `verdict:true`, but the merge-safety prompts were not given the final-message-JSON / no-ReportFindings instruction. The task lists the PR auto-merge review as exposed. Only the tool ban protects it, and only on claude-code. No parse-failure retry exists for auto-review or auto-merge (item 3 was implemented for verify only).",
      "evidence": "The diff touches prompts/review.md only. VERDICT_DELIVERY_NOTE is used only in verify.ts (grep). I did not confirm how merge-safety.md is assembled.",
      "suggestion": "Append the same delivery note to the merge-safety prompt, and consider the follow-up retry for the auto-review loop."
    },
    {
      "priority": "info",
      "confidence": "high",
      "category": "style",
      "file": "packages/code/src/lib/agent/run-harness-finalize.ts",
      "line": "363",
      "issue": "An unrelated comment rewrite in commitImplementation adds diff noise.",
      "evidence": "The diff hunk changes comment text only.",
      "suggestion": "Revert it."
    }
  ],
  "approved": false
}

Auto-review summary

Produced by auto-review, execution 1 at c03a50d3ca7226ce74cfb93b09708e63a2a6ad20.

Show artifact
{
  "iterations": 0,
  "success": true,
  "finalFeedback": {
    "summary": "The PR makes review and verify turns return the JSON verdict as final text. It does this by passing `--disallowedTools ReportFindings` to claude-code, adding a prompt note, and giving verify a one-shot JSON-only follow-up when the first reply has no parseable verdict. The change is safe because `disallowedTools` is opt-in. It is only emitted when a caller passes `verdict: true`, and `buildArgs` otherwise emits nothing new (`claude-code.ts:154`). All other harnesses ignore the field. I confirmed this by reading the source and did not run the tests, so the claim is pointed, not ran-it.",
    "items": [
      {
        "priority": "low",
        "confidence": "medium",
        "category": "bug",
        "file": "packages/code/src/lib/agent/verify.ts",
        "line": "289-304",
        "issue": "The follow-up catch is bare, so any parse error triggers it, including a deliberately rejected verdict. The follow-up prompt carries only the last 4000 characters of the previous output. A review whose JSON was cut off can lose its context, and the model may invent a verdict from a truncated tail. The failure is bounded because the second parse is still strict.",
        "evidence": "verify.ts:289-304 and verdict-delivery.ts:15 (`slice(-4000)`). Not run.",
        "suggestion": "Optionally include the head of the prior output as well, or tell the model to answer 'no verdict' when the tail is insufficient."
      },
      {
        "priority": "info",
        "confidence": "medium",
        "category": "code-quality",
        "file": "packages/code/src/lib/agent/run-harness-finalize.ts",
        "line": "925",
        "issue": "`...options` is now forwarded to `runAgentPrompt`. Before this change, pipeline steps could not pass `verdict`, so the new field only takes effect through this spread. The behavior is correct, but the comment-only edit above (lines 360-367) in the same file is unrelated churn.",
        "evidence": "Diff hunks at run-harness-finalize.ts:360 and :923.",
        "suggestion": "Drop the unrelated comment rewording to keep the diff focused."
      },
      {
        "priority": "info",
        "confidence": "low",
        "category": "testing",
        "file": "packages/code/src/lib/review/auto-merge.ts",
        "line": "953",
        "issue": "The `verdict: true` flag is added for the merge-safety review and the auto-review loop, but no test asserts that those two call sites pass it. Only verify.ts and the harness arg builder are covered.",
        "evidence": "The diff's tests touch only verify-step.test.ts and harnesses.test.ts.",
        "suggestion": "Add a small assertion that `runAgent` and `runAgentPrompt` receive `verdict: true` from these paths."
      }
    ],
    "approved": true
  },
  "unresolved": [],
  "stopReason": "approved",
  "commitSha": "c03a50d3ca7226ce74cfb93b09708e63a2a6ad20",
  "history": [
    {
      "iteration": 1,
      "feedback": {
        "summary": "The PR makes review and verify turns return the JSON verdict as final text. It does this by passing `--disallowedTools ReportFindings` to claude-code, adding a prompt note, and giving verify a one-shot JSON-only follow-up when the first reply has no parseable verdict. The change is safe because `disallowedTools` is opt-in. It is only emitted when a caller passes `verdict: true`, and `buildArgs` otherwise emits nothing new (`claude-code.ts:154`). All other harnesses ignore the field. I confirmed this by reading the source and did not run the tests, so the claim is pointed, not ran-it.",
        "items": [
          {
            "priority": "low",
            "confidence": "medium",
            "category": "bug",
            "file": "packages/code/src/lib/agent/verify.ts",
            "line": "289-304",
            "issue": "The follow-up catch is bare, so any parse error triggers it, including a deliberately rejected verdict. The follow-up prompt carries only the last 4000 characters of the previous output. A review whose JSON was cut off can lose its context, and the model may invent a verdict from a truncated tail. The failure is bounded because the second parse is still strict.",
            "evidence": "verify.ts:289-304 and verdict-delivery.ts:15 (`slice(-4000)`). Not run.",
            "suggestion": "Optionally include the head of the prior output as well, or tell the model to answer 'no verdict' when the tail is insufficient."
          },
          {
            "priority": "info",
            "confidence": "medium",
            "category": "code-quality",
            "file": "packages/code/src/lib/agent/run-harness-finalize.ts",
            "line": "925",
            "issue": "`...options` is now forwarded to `runAgentPrompt`. Before this change, pipeline steps could not pass `verdict`, so the new field only takes effect through this spread. The behavior is correct, but the comment-only edit above (lines 360-367) in the same file is unrelated churn.",
            "evidence": "Diff hunks at run-harness-finalize.ts:360 and :923.",
            "suggestion": "Drop the unrelated comment rewording to keep the diff focused."
          },
          {
            "priority": "info",
            "confidence": "low",
            "category": "testing",
            "file": "packages/code/src/lib/review/auto-merge.ts",
            "line": "953",
            "issue": "The `verdict: true` flag is added for the merge-safety review and the auto-review loop, but no test asserts that those two call sites pass it. Only verify.ts and the harness arg builder are covered.",
            "evidence": "The diff's tests touch only verify-step.test.ts and harnesses.test.ts.",
            "suggestion": "Add a small assertion that `runAgent` and `runAgentPrompt` receive `verdict: true` from these paths."
          }
        ],
        "approved": true
      },
      "addressed": [],
      "commitSha": "c03a50d3ca7226ce74cfb93b09708e63a2a6ad20"
    }
  ]
}

@danii1

danii1 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

🛑 Auto-merge: left open for human review (checked c03a50d).

The merge-safety review (standard policy) found: The PR modifies packages/code/src/lib/review/auto-merge.ts, changing how the merge-safety agent run is invoked (verdict: true, which disables ReportFindings). Auto-merge machinery changes always require a human.

1 changed file(s) match auto_merge_review_paths, so the review ran even if they are safe:

  • packages/code/prompts/review.md

Review and merge it yourself if you disagree.

devintern checks each pull request once and does not check again after new commits; a change to the auto-merge policy re-checks it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devintern-authored Pull request written by DevIntern working its own backlog needs-human-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant