Skip to main content

Module structured_output

Module structured_output 

Source
Expand description

Model-facing structured-output policy shared by the agent runtimes: the synthetic output tool’s name and description, the instructions and reprompts the model sees, and the required-field check on an answer.

use rig_core::structured_output::{output_tool_augmentation, output_tool_name};
let name = output_tool_name(|taken| taken == "final_result");
assert_eq!(name, "final_result_1");
assert!(output_tool_augmentation(&name).contains("`final_result_1`"));

Constants§

AUGMENTATION_SEPARATOR
The separator between the preamble and an augmentation.
OUTPUT_TOOL_DESCRIPTION
The output tool’s default description.
OUTPUT_TOOL_NAME
The output tool’s default name.

Functions§

missing_required_fields
The top-level required fields of an object schema that arguments lacks, in the schema’s order. A non-object argument lacks every one.
output_tool_augmentation
Appended to the preamble when the answer is asked for through the output tool named name.
output_tool_callable
Whether the tool choice permits calling the output tool named name. No choice, Auto, Required, and a Specific set naming it permit it.
output_tool_name
The output tool’s name for a run: the default, numbered from 1 while is_taken reports a collision (final_result, final_result_1, …).
prompted_augmentation
Appended to the preamble when the answer is asked for as prompted JSON; schema is the schema’s canonical rendering.
reprompt_missing_fields
The reprompt when the output tool named name was called without the missing required fields.
reprompt_text_answer
The reprompt when the model answered as text instead of calling the output tool named name.
text_satisfies_schema
Whether text parses as JSON with every top-level required field of schema. Without a schema any JSON passes. Field types and other schema constraints are not checked.