-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathvalidator.yaml
More file actions
96 lines (89 loc) · 3.55 KB
/
Copy pathvalidator.yaml
File metadata and controls
96 lines (89 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Validator Workflow
#
# Demonstrates the `validator:` block (issue #220): a second LLM call that
# grades a provider-backed agent's output against a rubric, and re-runs the
# agent once with feedback when it fails.
#
# This is distinct from the two correctness mechanisms Conductor already has:
# - `retry:` handles *transient* failures (provider errors, timeouts) by
# re-running the same prompt unchanged.
# - `output:` schema handles *shape* failures (missing field, wrong type).
#
# The validator catches the case neither does: a structurally valid output
# that is semantically wrong, incomplete, or off-rubric — here, a code review
# that misses a real bug or fabricates a function name.
#
# Mechanics:
# 1. `code_reviewer` produces a review of the diff.
# 2. The validator runs a second LLM call checking the review against
# `criteria`. It returns {passed, issues}.
# 3. If it fails, `code_reviewer` re-runs ONCE with the validator's issues
# appended under a "## Validation feedback" section. The second output is
# taken as final (no second validation loop).
#
# Validator token cost shows up as a separate `code_reviewer (validator)` row
# in the usage summary, and validator activity is surfaced in the web
# dashboard and `--verbose` console output.
#
# Usage:
# conductor run examples/validator.yaml
# conductor run examples/validator.yaml --input diff="$(git diff HEAD~1)"
workflow:
name: validator
description: Code review with a semantic validator that re-runs once on failure
version: "1.0.0"
entry_point: code_reviewer
runtime:
provider: copilot
input:
diff:
type: string
required: false
description: A unified diff to review
default: |
--- a/auth.py
+++ b/auth.py
@@ -10,6 +10,9 @@ class TokenStore:
- def get(self, key):
- return self._cache[key]
+ def get(self, key):
+ entry = self._cache.get(key)
+ return entry.value
agents:
- name: code_reviewer
description: Reviews a diff for bugs and suggests concrete fixes
model: claude-sonnet-4-5
prompt: |
Review the following diff for bugs, with a focus on null-safety and
correctness. For each problem, give a concrete, actionable suggestion.
Diff:
{{ workflow.input.diff }}
output:
summary:
type: string
description: One-line summary of the review
issues:
type: array
description: List of problems found, each with an actionable suggestion
# The validator runs a SECOND LLM call after code_reviewer completes,
# grading its output against the criteria below. On failure the agent is
# re-run once with the validator's feedback appended.
validator:
# Optional: validate with a cheaper/different model than the primary.
# Defaults to the primary agent's model when omitted.
model: claude-sonnet-4-5
criteria: |
Verify the review:
1. Identifies the null-safety issue in the diff (`entry` may be None
when the key is missing, so `entry.value` can raise AttributeError).
2. Each entry in `issues` includes a concrete, actionable suggestion
(not just "fix it").
3. Does not reference any function or attribute names that do not
appear in the diff (no fabrication).
# Hard-capped at 1. Use 0 to validate-and-report without re-running.
max_retries: 1
routes:
- to: $end
output:
summary: "{{ code_reviewer.output.summary }}"
issues: "{{ code_reviewer.output.issues }}"