
Grade Your Agent's Output Automatically: The LLM-as-Judge Pattern with Claude
Chris Harper
4 min read
Jul 24, 2026 · 20:03 UTC
TL;DR: Call Claude with a rubric prompt, temperature=0, and a required JSON output to get consistent, dimension-by-dimension scores for any agent or fine-tune output — at the speed of an API call, not a human review queue.
What you'll be able to do after this:
- Build a rubric-based judge that scores agent outputs on custom dimensions (relevance, groundedness, conciseness) with a single API call each
- Run 50 agent outputs through the judge and get a structured CSV of scores to compare model checkpoints
- Wire the judge into a fine-tuning feedback loop: identify low-scoring examples, use them as hard training cases in the next run
Resource: Demystifying Evals for AI Agents — Anthropic Engineering Blog. This is how Anthropic's own team builds evaluation pipelines for long-horizon agents; the pattern transfers directly to evaluating any fine-tuned model or multi-step workflow.
Why LLM-as-judge
After fine-tuning or building an agent, you face a hard question: how do you know it's actually better? Human evaluation is slow and expensive. Automatic metrics like ROUGE and BLEU miss hallucinations and tone. LLM-as-judge bridges the gap: you define what "good" means, Claude grades it consistently, and the whole pipeline runs in seconds.
The pattern — one judge per dimension
import anthropic, json
client = anthropic.Anthropic()
RUBRIC = """You are a strict evaluator. Score ONLY the dimension you are asked about.
Output JSON: {"score": 1-5, "reason": "one sentence"}
Dimension: {dimension}
Definition: {definition}
"""
def judge_dimension(question, context, response, dimension, definition):
msg = client.messages.create(
model="claude-opus-5",
max_tokens=128,
temperature=0, # deterministic — critical for reproducibility
system=RUBRIC.format(dimension=dimension, definition=definition),
messages=[{
"role": "user",
"content": f"Question: {question}\nContext: {context}\nResponse: {response}"
}]
)
return json.loads(msg.content[0].text)
# Run three isolated judges on the same output
output = "The contract renews annually at the rate locked in at signing."
scores = {}
for dim, defn in [
("relevance", "Does the response directly answer the question?"),
("groundedness", "Are all facts supported by the provided context?"),
("conciseness", "Does the response avoid filler and repetition?"),
]:
scores[dim] = judge_dimension("When does the contract renew?", context_doc, output, dim, defn)
print(scores)
# {"relevance": {"score": 5, "reason": "..."}, "groundedness": {"score": 3, "reason": "says annually but context says every 18 months"}, ...}
Key design decisions
Temperature=0. You need reproducible scores. A judge that gives the same response a 3 one run and a 5 the next is useless for regression testing.
One criterion per call. Anthropic's engineering guidance is clear: grade dimensions in isolation. A single "grade everything" prompt produces correlated scores that hide individual failures. Separate calls reveal which specific dimension regressed between model versions.
Chain-of-thought inside the verdict. The reason field is not optional. A numeric score alone never tells you why — the reasoning surfaces specifics like "response says 2024 but context shows 2026" that let you fix the exact training example.
Validate before you trust
Label 30–50 examples by hand, run them through your judge, and compare. Target 75–90% agreement with human labels. Below 60%? Your rubric is ambiguous — clarify the definition of each dimension before scaling.
Closing the loop with fine-tuning
Once you have a judge harness, wire it to your training pipeline:
- Score outputs from the baseline and from each checkpoint with the judge
- Sort by lowest score per dimension
- Use the lowest-scoring examples as hard negatives in your next DPO or SFT round (mistake amplification)
- Re-score after each run to track per-dimension improvement over time
This turns LLM-as-judge from a one-off tool into a continuous quality feedback loop.
Sources: Demystifying Evals for AI Agents — Anthropic Engineering · LLM-as-Judge Evaluation Guide 2026 — Qaskills · LLM-as-Judge docs — Langfuse