Skip to content

feat: add json-nonempty scorer - #54

Merged
royalpinto007 merged 1 commit into
AgentPostmortem:mainfrom
sharadvc:feat/json-nonempty-scorer
Sep 17, 2026
Merged

royalpinto007 merged 1 commit into
AgentPostmortem:mainfrom
sharadvc:feat/json-nonempty-scorer

Conversation

@sharadvc

Copy link
Copy Markdown
Contributor

Fixes #37

Models game structured-output evals with vacuous {} / {"answer": ""} / all-null payloads that still validate against the schema. The existing json-schema scorer passes them.

Change

  • New src/scorers/json-nonempty.ts exporting a Scorer (sibling to json-schema.ts).
  • Registers the new json-nonempty type in registry.ts builtinScorers.
  • Wraps schema validation with emptiness checks: minKeys (default 1), rejectBlankStrings (default true), rejectNulls (default true). Counts non-empty leaf values recursively; fails outputs with zero non-empty leaves.
  • Documented in README scorer table + CHANGELOG [Unreleased].

Acceptance

  • ctx('{}') with minKeys: 1 fails before the change.
  • ctx('{"answer": "Paris"}') passes after.

Tests cover the empty object, blank strings, all-null payloads, minKeys, non-JSON input, and schema-rejection precedence.

Full suite: 113/113 pass (npm test); tsc --noEmit and eslint clean.

This contribution was made with AI assistance (Claude).

Fails schema-valid-but-empty outputs ({}, {answer: ""}, all-null)
that still game structured-output evals. Wraps schema validation
with non-empty-leaf checks (minKeys, rejectBlankStrings, rejectNulls)
and registers the new json-nonempty type.

Closes AgentPostmortem#37
@royalpinto007
royalpinto007 merged commit 5e28f0a into AgentPostmortem:main Sep 17, 2026
9 checks passed
@github-actions

Copy link
Copy Markdown

And it's in. Thanks @sharadvc.

Good, focused change. Exactly the kind of thing Evalgate needs.

If Evalgate is useful to you, a star goes a long way.

Happy to see more from you whenever you have the time.

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.

New scorer json-nonempty: fail schema-valid-but-empty outputs

2 participants