Skip to content

feat: add s.nonEmptyObject schema helper and p.writeOutput prompt helper#73

Merged
pelikhan merged 3 commits into
mainfrom
copilot/rig-tasks-daily-evaluation-2026-07-23-05bbf768-0444-46af-9ac5-158180a6904e
Jul 23, 2026
Merged

feat: add s.nonEmptyObject schema helper and p.writeOutput prompt helper#73
pelikhan merged 3 commits into
mainfrom
copilot/rig-tasks-daily-evaluation-2026-07-23-05bbf768-0444-46af-9ac5-158180a6904e

Conversation

Copilot AI commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

From the daily rig evaluation, two gaps were identified: no way to reject empty {} map outputs at validation time, and no clean way to wire an LLM-generated output field to a file path (the existing p.write takes a static string, creating ambiguity about who provides the content).

s.nonEmptyObject(valueSchema, description?)

Constrained RecordSchema with minProperties: 1 — mirrors s.nonEmptyArray for maps.

output: s.object({
  labels: s.nonEmptyObject(s.string, "at least one label required"),
})
// serializes to { type: "object", additionalProperties: { type: "string" }, minProperties: 1 }
// validation rejects {}
  • RecordSchema type gains an optional minProperties field
  • serializeSchema emits minProperties in JSON Schema output
  • validateSchema enforces the constraint at runtime

p.writeOutput(field, path, options?)

New prompt intent (mode: "prompt.writeOutput") that tells the harness to write the value of a named output field to a file after the agent generates its response — solving the p.write content-source ambiguity.

const tracker = agent({
  instructions: p`Scan for TODO comments. ${p.writeOutput("report", "todo-report.md")}`,
  output: s.object({ report: s.string }),
});
// renders: "After generating the response, write the value of output field "report" to the file at path "todo-report.md""

Use p.writeOutput when the content is LLM-generated; use p.write for static content.

Docs

  • SKILL.md and README.md updated with both helpers, usage examples, and a p.write vs p.writeOutput guidance note
  • rig.ts file-header comment updated

- Add s.nonEmptyObject(valueSchema, description?) as a constrained
  RecordSchema with minProperties:1; validates that the record has at
  least one key at runtime
- Add p.writeOutput(field, path, options?) prompt intent that instructs
  the harness to write the value of a named output field to a file after
  generation, solving the p.write ambiguity for LLM-generated content
- Update RecordSchema type to include optional minProperties field
- Update serializeSchema to emit minProperties in JSON Schema output
- Update validateSchema to enforce minProperties on record schemas
- Add 9 new tests covering both features
- Update SKILL.md and README.md with new helpers and clarifications
- Update file-header comment in rig.ts

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue in daily rig evaluation tasks feat: add s.nonEmptyObject schema helper and p.writeOutput prompt helper Jul 23, 2026
Copilot AI requested a review from pelikhan July 23, 2026 20:48
@pelikhan
pelikhan marked this pull request as ready for review July 23, 2026 20:50
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts on this branch.

…ly-evaluation-2026-07-23-05bbf768-0444-46af-9ac5-158180a6904e

# Conflicts:
#	skills/rig/rig.ts

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts on this branch.

Resolved. The two conflicts were both in the rig.ts file header comment:

  • T:PromptIntent kind list: merged writeOutput (this PR) + env (main)
  • p.write doc line: kept main's clarifying note and added p.writeOutput entry from this PR

All 189 tests pass (bd37a90).

@pelikhan
pelikhan merged commit 6124144 into main Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[rig-tasks] Daily rig evaluation — 2026-07-23 — 5/5 passed

2 participants