pub fn constrain_tool_calls(body: &mut Value, ctx: &ModelContext) -> boolExpand description
Originate a decode-time grammar for a demanded dialect tool call.
Engages only when all of the following hold, and is a no-op otherwise:
GGLIB_DISABLE_GRAMMARis not set to a truthy value;- the model resolved from the catalog with a dialect spec whose codec list includes JSON (see module docs for why the native path is excluded — and a grammar can only originate JSON-shaped bodies);
- the request carries a non-empty
toolsarray whose function names are expressible in a GBNF literal; - the client sent none of
grammar/json_schema/response_format— a client that constrains its own decode is always respected; tool_choicedemands a call:"required", or a named function.
Returns true when a grammar was installed.