[rig-sampler] Improve array type description in missing-field error messages - #132
Merged
Merged
Conversation
When a required array field is missing, the validation error now reads 'missing required field (expected array of string)' instead of 'missing required field (expected array)'. This makes repair prompts more precise and helps the model produce the correct item type on retry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅ |
Contributor
Author
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /tdd — approving with one minor suggestion on test completeness.
📋 Key Themes & Highlights
Positive Highlights
- ✅ Root cause correctly addressed:
"items" in schemanow checked before"type" in schema, soArraySchema(which carries both) reaches the richer branch first - ✅ Two new tests pin the changed behaviour for
array of stringandarray of number - ✅ Non-breaking internal change —
describeSchemaTypeis not exported
Minor Gap
- The PR description mentions
"array of object"as a new output, but no test covers it. Low risk sincedescribeSchemaTypefalls through to the"properties" in schemabranch, but a test would make the guarantee explicit.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 26.7 AIC · ⌖ 6.96 AIC · ⊞ 6.3K
Comment /matt to run again
| expect(result.error.message).toContain("$.scores"); | ||
| expect(result.error.message).toContain("array of number"); | ||
| } | ||
| }); |
Contributor
Author
There was a problem hiding this comment.
[/tdd] No test covers array of object — the PR description mentions it as an example output but there is no corresponding test case.
💡 Suggested addition
it("reports a missing required array-of-objects field with item type 'array of object'", () => {
const schema = s.object({ tags: s.array(s.object({ id: s.string })), name: s.string });
const result = analyzeResponse(JSON.stringify({ name: "x" }), schema, "test", 1);
expect(result.ok).toBe(false);
if (!result.ok) {
expect(result.error.message).toContain("array of object");
}
});The PR body explicitly cites "array of object" as a newly supported description, so a test pinning that output would complete the coverage story.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Samples run
21-ci-log-diagnosis.tscommandsToTry: s.array(s.string). Clean run, no repair needed.22-config-normalizer.tss.unknownfornormalizedfield — appropriate but schema is effectively unvalidated.23-schema-inference.tsp.bash(...)intent ands.unknownforexampleoutput. No repair.24-error-message-improver.tss.optional(s.string)forcontextinput field. Validated correctly.25-migration-guide.tss.optional(s.string)forcontextinput field. Clean run.All five samples ran successfully in a single turn with the stub runner.
What was identified
Samples 21, 22, and 24 all declare array fields in their output schemas (
commandsToTry,fields, etc.) usings.array(s.string)ors.array(s.object(...)). When such a required field is missing from the model response, the harness emits:The
describeSchemaTypehelper returned just"array"for any array schema — it checked"type" in schemabefore"items" in schema, so the items type was never surfaced. This meant repair prompts received a less-specific hint: the model knew it needed an array but not what element type to use, increasing the risk of a second repair turn.Change
describeSchemaTypenow checks"items" in schemabefore the generic"type" in schemabranch, and returns"array of <itemType>"(e.g."array of string","array of object") instead of plain"array". The "missing required field" message in repair prompts becomes:This is a small, non-breaking internal change — the function is not exported and only affects diagnostic strings in
AgentError.messageand repair prompts.Tests
Two tests in
src/rig.test.tswere updated/added to coverarray of stringandarray of numberin the missing-field error message.