[rig-sampler] Add type: "string" to all-string enum schemas#30
Merged
Conversation
When all enum values are strings, include "type": "string" alongside the "enum" array in the serialized JSON Schema. This gives LLMs a stronger type constraint and follows JSON Schema best-practice (RFC 3986 §6.1.2). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pelikhan
marked this pull request as ready for review
July 23, 2026 10:49
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 — changes are well-tested and the implementation is correct.
📋 Highlights
Positive Highlights
- ✅ New test covers all four meaningful cases: all-string, all-number, mixed, and empty enum
- ✅ Empty-enum edge case correctly skips
type: "string"(viaenumValues.length > 0guard) - ✅ Existing test updated to match new expected output — no silent drift
- ✅ Minimal, surgical change; unrelated code is untouched
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 14.4 AIC · ⌖ 3.94 AIC · ⊞ 6.3K
Comment /matt to run again
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.
Sample run:
10-triage-pr.tsSample executed:
src/samples/10-triage-pr.ts— classifies a GitHub issue and suggests labels usings.enumfor bothkindandpriorityfields.Run result: ✅ Succeeded in 1 turn (no repair loops). The stub produced valid output matching the schema.
Observation from the run output:
The generated
<output_schema>block emitted by the harness fors.enum("bug", "feature", "question", "chore")was:{"enum": ["bug", "feature", "question", "chore"]}This is valid JSON Schema, but omits the type constraint. JSON Schema best-practice (and many LLM prompt guides) recommend including
"type": "string"alongsideenumwhen all values are strings — it gives the model a clearer, redundant signal to produce a string and helps schema validators surface type mismatches before value mismatches.Change
In
serializeSchema, when anEnumSchema's values are all strings, the serialized output now includes"type": "string":{"type": "string", "enum": ["bug", "feature", "question", "chore"]}Mixed-type or non-string enums (e.g.
s.enum(1, 2, 3)) continue to emit only{"enum": [...]}.Tests
"converts enum schemas"test to expect the newtype: "string"field."adds type:string to all-string enums but not mixed enums"test covering string-only, number-only, mixed, and empty enum cases.All 129 tests pass.