Skip to content

fix(judge): harden agent_judge JSON output prompt - #260

Merged
zpzjzj merged 1 commit into
alibaba:mainfrom
JHWang-1997:fix/agent-judge-strict-output-contract
Sep 18, 2026
Merged

zpzjzj merged 1 commit into
alibaba:mainfrom
JHWang-1997:fix/agent-judge-strict-output-contract

Conversation

@JHWang-1997

Copy link
Copy Markdown
Collaborator

Summary

  • Share a strict final-message JSON contract between first-attempt and correction judge prompts.
  • Require the final judge message to contain only the JSON response after any tool use, preventing prose prefixes such as I ... from triggering a full correction retry.
  • Add regression coverage that keeps the two prompt contracts aligned.

Fixes #259

Test plan

  • go build ./...
  • go test ./internal/judge/

…fixes

Agentic judges (e.g. qodercli) sometimes close their final message with
natural-language prose ("I ...") instead of the required JSON object. The
decoder strips a leading code fence but no leading prose, so the response
fails with "invalid character 'I' looking for beginning of value" and
AgentJudge.Evaluate burns an extra full model call on the correction retry.

Extract a shared appendStrictOutputRules contract and emit it near the end of
both the first-attempt prompt (buildJudgePrompt) and the correction prompt
(buildAgentJudgeCorrectionPrompt), so the two state the output rules verbatim
and cannot drift. This ports the exact field-casing rule that previously lived
only in the correction prompt into the first attempt, requires the final
message to be JSON-only even after tool use, and reconciles the contradictory
Markdown-fence wording between the two prompts.

Refs alibaba#259

@zpzjzj zpzjzj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zpzjzj
zpzjzj added this pull request to the merge queue Sep 18, 2026
Merged via the queue into alibaba:main with commit 12ad944 Sep 18, 2026
10 checks passed
@zpzjzj zpzjzj mentioned this pull request Sep 18, 2026
3 tasks
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.

fix(judge): strengthen first-attempt agent_judge prompt so agentic judges do not emit a prose prefix

2 participants