Commit 089efc1
authored
refactor: consolidate on_schema_mismatch into reprompt config (#493)
* refactor(config): move on_schema_mismatch + strict_schema into RepromptConfig
Remove on_schema_mismatch and strict_schema from ActionConfig and DefaultsConfig.
Add on_schema_mismatch: Literal['reject', 'reprompt'] | None to RepromptConfig.
Schema conformance checking is now declared inside reprompt: block only.
* refactor(processing): _resolve_schema_mismatch_mode reads reprompt config
Read on_schema_mismatch from reprompt dict instead of top-level key.
Remove ON_SCHEMA_MISMATCH_KEY and STRICT_SCHEMA_KEY imports from helpers.py
and factory.py. Update warning messages to reference new config location.
* refactor(validation): granularity validator uses reprompt.on_schema_mismatch
Remove old top-level on_schema_mismatch check. Add check that
reprompt.on_schema_mismatch: reprompt/reject requires a schema defined.
* chore: remove ON_SCHEMA_MISMATCH_KEY + STRICT_SCHEMA_KEY constants
Both constants are dead — no production code references them after
the config model and processing changes.
* test: migrate on_schema_mismatch fixtures to reprompt config
Update all test fixtures from top-level on_schema_mismatch/strict_schema
to reprompt: {on_schema_mismatch: reject/reprompt}. Remove tests for
warn mode and strict_schema alias. 189 tests pass.
* docs: update output-validation + reprompt-patterns for new config shape
Move on_schema_mismatch inside reprompt: block in all examples.
Remove warn mode and strict_schema references.
* refactor(test): extract shared _make_schema_config helper
De-duplicate _make_config which was copied verbatim across
TestValidateSchemaSkip and TestRepromptFallbackWarning.
* chore: add changie breaking change entry for reprompt consolidation
* fix: changie timestamp to valid ISO-8601
* fix: add isinstance guard for non-dict reprompt + extra=forbid on RepromptConfig
Granularity validator now uses isinstance(reprompt_raw, dict) instead of
truthy-or to prevent AttributeError when reprompt is a non-dict value.
RepromptConfig gains extra='forbid' to catch typos like on_schema_mistmatch.
* fix: improve reprompt CLI output clarity
- Client parse warnings downgraded to debug (reprompt loop owns the messaging)
- Remove redundant 'Validation failed' after 'Invalid JSON' (one message per event)
- Add 'Retrying with feedback (attempt N/M)' before each retry
- Only log 'Reprompt passed on attempt N/M' when it took >1 attempt
- 'Schema validation failed' only shown for schema errors, not parse errors
* fix: include expected schema fields in JSON parse error feedback
When the model returns empty/invalid JSON, the reprompt feedback now
includes the expected field names from the schema. This guides the model
on WHAT to produce, not just 'return JSON'.
Example feedback:
Your previous response was not valid JSON. Return only a JSON object...
Expected JSON fields: summary, exam_density, key_topics
* fix: forceful JSON parse feedback with expected field names
When the model returns empty/invalid JSON, the reprompt feedback is now
assertive and includes the exact fields expected from the schema.
Example:
CRITICAL: Your previous response was empty or not valid JSON.
This is a strict JSON pipeline — every response MUST be a single
JSON object. No markdown. No code fences. No explanation.
You MUST return a JSON object with these fields: summary, exam_density
Example structure:
{
"summary": "...",
"exam_density": "...",
}
* docs: fix dangling reprompt blocks missing on_schema_mismatch
Every reprompt: example now includes on_schema_mismatch: reprompt or
validation: to match actual framework behavior. A bare reprompt block
without either does not create a RepromptService.
Also added on_schema_mismatch, use_self_reflection, use_llm_critique,
and critique_after_attempt to the reprompt-patterns field reference table.1 parent 84be3b8 commit 089efc1
18 files changed
Lines changed: 261 additions & 276 deletions
File tree
- .changes/unreleased
- agent_actions
- config
- llm/providers
- ollama
- openai
- processing
- invocation
- recovery
- skills/agac-agent-skills/references
- utils
- validation/action_validators
- docs.agent-actions/docs/reference/validation
- tests
- integration
- unit
- config
- core
- processing
- validation
- validation
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
93 | | - | |
| 92 | + | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
96 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
97 | 103 | | |
98 | 104 | | |
99 | 105 | | |
| |||
187 | 193 | | |
188 | 194 | | |
189 | 195 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | 364 | | |
369 | 365 | | |
370 | 366 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 73 | + | |
86 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
87 | 81 | | |
88 | 82 | | |
89 | 83 | | |
| |||
96 | 90 | | |
97 | 91 | | |
98 | 92 | | |
99 | | - | |
100 | | - | |
101 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
102 | 96 | | |
103 | 97 | | |
104 | 98 | | |
| |||
108 | 102 | | |
109 | 103 | | |
110 | 104 | | |
111 | | - | |
112 | | - | |
113 | | - | |
| 105 | + | |
| 106 | + | |
114 | 107 | | |
115 | 108 | | |
116 | 109 | | |
| |||
141 | 134 | | |
142 | 135 | | |
143 | 136 | | |
144 | | - | |
145 | | - | |
| 137 | + | |
| 138 | + | |
146 | 139 | | |
147 | 140 | | |
148 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
| 95 | + | |
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 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 | + | |
26 | 62 | | |
27 | 63 | | |
28 | 64 | | |
| |||
206 | 242 | | |
207 | 243 | | |
208 | 244 | | |
209 | | - | |
| 245 | + | |
210 | 246 | | |
211 | 247 | | |
212 | 248 | | |
| |||
216 | 252 | | |
217 | 253 | | |
218 | 254 | | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
225 | 262 | | |
226 | 263 | | |
227 | 264 | | |
| |||
231 | 268 | | |
232 | 269 | | |
233 | 270 | | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
240 | 278 | | |
241 | 279 | | |
242 | 280 | | |
243 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
244 | 289 | | |
245 | | - | |
| 290 | + | |
246 | 291 | | |
247 | 292 | | |
248 | 293 | | |
| |||
Lines changed: 9 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
41 | | - | |
| 45 | + | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
47 | | - | |
48 | 51 | | |
| 52 | + | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| |||
101 | 105 | | |
102 | 106 | | |
103 | 107 | | |
104 | | - | |
| 108 | + | |
105 | 109 | | |
106 | 110 | | |
107 | 111 | | |
108 | 112 | | |
109 | | - | |
110 | 113 | | |
| 114 | + | |
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
| |||
189 | 193 | | |
190 | 194 | | |
191 | 195 | | |
192 | | - | |
193 | 196 | | |
| 197 | + | |
194 | 198 | | |
195 | 199 | | |
196 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | 15 | | |
18 | 16 | | |
19 | 17 | | |
| |||
Lines changed: 6 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
66 | 62 | | |
67 | 63 | | |
68 | 64 | | |
69 | 65 | | |
70 | 66 | | |
71 | | - | |
72 | | - | |
73 | | - | |
| 67 | + | |
| 68 | + | |
74 | 69 | | |
75 | 70 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | 71 | | |
86 | 72 | | |
87 | 73 | | |
| |||
0 commit comments