Repository navigation
fix(tools): give supplied schemas the same description guidance as params - #36
Merged
Merged
Conversation
…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
marked this pull request as ready for review
September 21, 2026 21:52
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.
The gap
Choosing
@tool(schema=...)overparams=silently cost a plugin its model-facing guidance._augment_descriptionran only on theparamspath, so a supplied Hermes schema reached the model with its bare description, and the runtime missing-argument error dropped its example too (exampleswas hardcoded to{}wheneverschemawas supplied).The two paths were mutually exclusive, and nothing said so:
oneOf, …)Required:/Optional:guidanceparams=schema=(before)schema=(after)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
requiredlist and the JSON Schemaexampleskeyword 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 scalarexample. A scalar is deliberately not read, and there's a test pinning that.Two limits keep this from rewriting hand-written text:
Required:clause;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:
oneOf,required, and every other keyword survive;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=andparams=emit byte-identical descriptions for equivalent inputsoneOfandrequiredpreserved, including undervalidate_required=Falseexamplefails 1Scope
Kit-side only; no upstream change needed. README updated per the Release Notes rule.