inspect: validate --set-judge agent can write a verdict · Entire
inspect: validate --set-judge agent can write a verdict
6d457bc→main·
dipree·1mo ago·2 files·+24 added/-0 removed
--set-judge accepted any agent name, so a typo or a non-text-gen agent slipped through config and only failed later at synthesis time. Validate up front that the named judge is a known agent that supports text generation (the same capability defaultJudge/promptForJudge require), with a distinct error for an unknown agent vs one without text generation. Adds a regression test.
Sessions
e7e5cd070584View transcript
?\ Checkout the hand off doc that I just added.Pi·Opus 4.8·1 step
Changes
2
cmd/entire/cli/review
Mcmd.go+9
Mconfigure_test.go+15
620 unmodified lines
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
620 unmodified lines
if name == "" {
return settings.ReviewProfileConfig{}, errors.New("--set-judge needs an agent name")
}
// A judge consolidates the inspectors' reports via text generation, so it
// must be a known agent that can write a verdict. Validate up front rather
// than failing at synthesis time.
if !agentSupportsTextGeneration(ctx, name) {
if _, getErr := agent.Get(types.AgentName(name)); getErr != nil {
return settings.ReviewProfileConfig{}, fmt.Errorf("--set-judge %q is not a known agent", name)
}
return settings.ReviewProfileConfig{}, fmt.Errorf("--set-judge %q cannot write a verdict (the agent has no text generation); choose an agent that supports text generation", name)
}
profile.Judge = &settings.ReviewConfig{Agent: name, Model: strings.TrimSpace(model)}
case inspectorCount > 1 && (profile.Judge == nil || profile.Judge.IsZero()):
if j, ok := defaultJudge(ctx, profile.Agents); ok {
Mcmd/entire/cli/review/cmd.go+9
259 unmodified lines
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
259 unmodified lines
}
}
func TestBuildConfiguredProfile_RejectsUnknownJudge(t *testing.T) {
t.Parallel()
deps := configureTestDeps("claude-code")
_, err := buildConfiguredProfile(
context.Background(),
"general",
reviewConfigureOptions{Agents: []string{tAgentClaude}, Judge: "definitely-not-an-agent"},
&settings.EntireSettings{},
deps,
)
if err == nil {
t.Fatal("expected error for --set-judge naming an agent that cannot write a verdict")
}
}
func TestBuildConfiguredProfile_InvalidModelSpec(t *testing.T) {
t.Parallel()
deps := configureTestDeps("claude-code")