Skip to content

fix(tools): give supplied schemas the same description guidance as params - #36

Merged
offendingcommit merged 1 commit into
mainfrom
fix/schema-description-augmentation
Sep 21, 2026
Merged

offendingcommit merged 1 commit into
mainfrom
fix/schema-description-augmentation

Conversation

@offendingcommit

Copy link
Copy Markdown
Owner

The gap

Choosing @tool(schema=...) over params= silently cost a plugin its model-facing guidance. _augment_description ran only on the params path, so a supplied Hermes schema reached the model with its bare description, and the runtime missing-argument error dropped its example too (examples was hardcoded to {} whenever schema was supplied).

The two paths were mutually exclusive, and nothing said so:

path expressive keywords (oneOf, …) Required: / Optional: guidance
params= dropped yes
schema= (before) preserved no
schema= (after) preserved yes

Found by a peer probing the running kit rather than reading it — the tell that this was undocumented rather than intended.

What changed

Both clauses are now built from the consumer's own schema: its required list and the JSON Schema examples keyword on each property. Nothing is invented.

examples (the list) is the spelling the host understands — Hermes' schema sanitizer names it a preserved metadata keyword and a non-schema sibling ("list of example values") and does not recognize a scalar example. A scalar is deliberately not read, and there's a test pinning that.

Two limits keep this from rewriting hand-written text:

  • a clause is skipped when the description already carries that label, so prose that spells out its own requirements doesn't gain a second, differently-worded Required: clause;
  • a schema with no required properties and no examples comes out byte-identical.

Design tension, stated plainly

PR #15 offered this path so plugins could "adopt decorators without changing their public schemas." The emitted description does change here. Three things argue it's still right:

  1. the schema itself is untouched — oneOf, required, and every other keyword survive;
  2. the added text is derived wholly from the consumer's own schema;
  3. the path already replaced the description with the resolved doc (copied["description"] = description), so description fidelity was never absolute.

The conservative alternative, if you'd rather not change existing consumers' descriptions, is an opt-in flag instead of symmetry. Left as a draft for that call.

This also serves the standing AGENTS.md rule that validation errors stay instructive "including the missing argument name and example when available" — on the schema path the example was available and thrown away.

Verification

  • schema= and params= emit byte-identical descriptions for equivalent inputs
  • oneOf and required preserved, including under validate_required=False
  • Mutation-tested all three guards: dropping the augmentation fails 4 tests; dropping the double-augmentation guard fails 1; reading a scalar example fails 1
  • Full suite: 265 tests, OK

Scope

Kit-side only; no upstream change needed. README updated per the Release Notes rule.

…rams

Choosing @tool(schema=...) silently cost a plugin its model-facing
guidance. _augment_description ran only on the params path, so a
supplied Hermes schema reached the model with its bare description --
no "Required: `x` (e.g. ...)", no "Optional:" -- and the runtime
missing-argument error dropped its example too, because the examples
dict was hardcoded to {} whenever schema was supplied.

That made the two paths mutually exclusive with nothing saying so: use
params and lose expressive keywords like oneOf, or use schema and lose
the guidance. A peer found it by probing the running kit rather than
by reading, which is the tell that it was undocumented rather than
intended.

Both clauses are now built from the consumer's own schema -- its
required list and the JSON Schema examples keyword on each property --
so this surfaces their data rather than inventing any. examples is the
spelling Hermes understands: its schema sanitizer names it a preserved
metadata keyword and a non-schema sibling, and does not recognize a
scalar example, so a scalar is deliberately not read.

Two limits keep this from rewriting descriptions people wrote by hand.
A clause is skipped when the description already carries that label,
so prose spelling out its own requirements is not contradicted by a
second, differently-worded Required: clause. And a schema with no
required properties and no examples is left byte-identical.

This also serves the standing rule that validation errors stay
instructive "including the missing argument name and example when
available" -- on the schema path the example was available and thrown
away.

Note the tension with PR #15, which offered this path so plugins could
"adopt decorators without changing their public schemas": the emitted
description does change. The schema itself does not, the added text is
derived wholly from the schema, and the path already replaced the
description with the resolved doc rather than passing it through, so
description fidelity was never absolute here.

Verified: schema= and params= now emit byte-identical descriptions for
equivalent inputs, with oneOf and required preserved. Mutation-tested
all three guards -- dropping the augmentation fails 4 tests, dropping
the double-augmentation guard fails 1, reading a scalar example fails
1. Full suite 265 tests OK.
@offendingcommit
offendingcommit marked this pull request as ready for review September 21, 2026 21:52
@offendingcommit
offendingcommit merged commit da4ba9f into main Sep 21, 2026
6 checks passed
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.

1 participant