pub struct OutputSpec {
pub format: Option<String>,
pub instructions: Option<String>,
pub example: Option<String>,
pub schema: Option<Value>,
pub validator: Option<String>,
}Expand description
What shape an agent should return.
Declared by a blueprint ([agent.output]), narrowed by a stage
([stages.<name>.output]), and overridable by whoever starts the run. See
resolve_output_spec for how the three combine.
Every field is optional, and an entirely empty spec is meaningful: it asks for a final output without constraining its shape.
Fields§
§format: Option<String>An opaque label for the shape, carried to the model and recorded beside
the result. "markdown", "json", "a2ui", and
"application/vnd.acme.report+xml" are all equally valid and equally
uninterpreted. Consumers that render differently per format (a browser
UI, say) match on this string; the engine never does.
instructions: Option<String>Free-form guidance folded into the submit_output tool description and
the output stage’s system prompt. This is where a format that the model
has never seen gets explained.
example: Option<String>A literal sample shown to the model verbatim. The most effective lever for an unusual format, and the reason one needs no code support.
schema: Option<Value>A JSON Schema describing the answer’s shape. When present, a submission is parsed as JSON and validated against it, and a failure is refused back to the model so it can correct itself.
Separate from format because they answer different questions.
format = "json" asks “does this parse as JSON”; a schema asks “does the
parsed document have the fields I need”. A format check comes free for
the handful of formats the engine can parse; shape is only ever checked
when someone writes a schema down.
validator: Option<String>A .rhai script that decides whether an answer is valid, as a path
relative to the blueprint directory.
For a format the engine cannot parse and a shape a JSON Schema cannot
describe. The script defines fn validate(content) and returns () when
the answer is fine or a string saying what is wrong; the string goes back
to the agent as the same refusal a schema failure produces.
Written for the format it accompanies, so a caller who overrides the format retires it along with the schema.
Implementations§
Trait Implementations§
Source§impl Clone for OutputSpec
impl Clone for OutputSpec
Source§fn clone(&self) -> OutputSpec
fn clone(&self) -> OutputSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OutputSpec
impl Debug for OutputSpec
Source§impl Default for OutputSpec
impl Default for OutputSpec
Source§fn default() -> OutputSpec
fn default() -> OutputSpec
Source§impl<'de> Deserialize<'de> for OutputSpec
impl<'de> Deserialize<'de> for OutputSpec
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for OutputSpec
Source§impl PartialEq for OutputSpec
impl PartialEq for OutputSpec
Source§impl Serialize for OutputSpec
impl Serialize for OutputSpec
impl StructuralPartialEq for OutputSpec
Auto Trait Implementations§
impl Freeze for OutputSpec
impl RefUnwindSafe for OutputSpec
impl Send for OutputSpec
impl Sync for OutputSpec
impl Unpin for OutputSpec
impl UnsafeUnpin for OutputSpec
impl UnwindSafe for OutputSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.