7. Validate input with constraints
You want the schema to enforce shape โ a pattern on an ID, a length range on a reason, a numeric bound โ so the LLM gets it right the first time and bad inpu...
Problem. You want the schema to enforce shape โ a pattern on an ID, a length range on a reason, a numeric bound โ so the LLM gets it right the first time and bad input never reaches call.
Solution. Stack constraint tags after the type. They're type-aware: @min/@max become minLength, minimum, or minItems depending on the field's type.
#: (
#: applicant_id: String @pattern(^app-\d+$) @desc(Use fetch_latest_applicant to get this ID),
#: workflow_id: String @min(1) @max(50),
#: email: String @format(email),
#: priority: Integer @min(1) @max(5),
#: ?reason: String? @min(10) @max(500),
#: ?tags: Array[String] @max(10) @unique()
#: ) -> Hash[Symbol, untyped]Result. Each tag maps to its JSON Schema keyword: pattern, minLength/maxLength, format, minimum/maximum, maxItems, uniqueItems. @desc(...) becomes the field description โ and doubles as a tool-chaining hint to the LLM ("call X first to get this value").
Full tag table lives in the README. The common ones: @min @max @exclusive_min @exclusive_max @multiple_of @pattern @format @unique @desc @title @example @deprecated.
Collected from COOKBOOK.md in the repository. Edit it there, not here.