pub struct OutputSpec {
pub name: String,
pub description: String,
pub schema: Value,
pub keeps_tools: bool,
}Expand description
The shape a turn must answer in.
The three fields describing that shape are all load-bearing, so they arrive
together through one constructor: a spec missing any of them would describe
a tool the model cannot use. with_tools is a builder
because what it says is not part of the shape — it is what the turn wearing
that shape is allowed to do on its way to filling it in.
Fields§
§name: StringWhat the answering tool is called, as the model sees it — report or
submit_findings rather than an internal identifier. mentra derives the
tool’s actual name from this and makes it unique per call, so a run’s
stream will not show this string verbatim.
description: StringWhat the tool is for, in the imperative. The model reads this to decide what a complete answer looks like, so “one entry per problem you saw on the last turn” is worth more than “returns findings”.
Whether it may also ask for work is with_tools.
By default the turn holds no tool but this one, so a description asking
the model to go and read something describes work it cannot do —
describe the answer, not a task. A turn that kept its tools has the
opposite exposure, since nothing makes it stop working and answer, and
this is where the condition for stopping belongs: “call this once you
have read every changed file and have nothing further to check”.
schema: ValueJSON Schema for the answer. The field descriptions in it are read by the model, not just validated against.
keeps_tools: boolWhether the turn keeps its ordinary tools while it answers. False unless
with_tools says otherwise.
Implementations§
Source§impl OutputSpec
impl OutputSpec
pub fn new( name: impl Into<String>, description: impl Into<String>, schema: Value, ) -> Self
Sourcepub fn with_tools(self) -> Self
pub fn with_tools(self) -> Self
Lets the turn work before it answers, instead of only shaping what the conversation already holds.
A shaping turn asked for something it has not been told answers from nothing it looked at: well-formed, empty, and reported as a success. The way around that has been to spend two turns on every read-then-answer job, one to gather and one to shape. This spends one — the run keeps the whole toolset beside the terminal tool, works as many rounds as it needs, and ends the turn by calling it.
The cost is that nothing forces the ending. A model that works and then
answers in prose, or that runs out of budget mid-gather, produces no
value at all; PreparedRun::output says
what comes back instead. Two turns also remain the better shape when the
reading should not share a context with the answering — one reader per
reviewer, as in examples/review_workflow.rs.
Sourcepub fn reserve(self) -> OutputReservation
pub fn reserve(self) -> OutputReservation
Reserve the exact generated output tool for one future validated run.
Reservation has no runtime side effect. The generated name is exposed so a host can identify protocol events before the run starts.