Struct ToolOutput
pub struct ToolOutput {Show 14 fields
pub content: String,
pub is_error: bool,
pub artifacts: Vec<Artifact>,
pub answer: Option<String>,
pub ends_turn: bool,
pub sandbox: SandboxUsage,
pub repeat_key: Option<Box<String>>,
pub plan: Option<Box<Plan>>,
pub kept: Option<Box<KeptOutput>>,
pub reported: Vec<RunId>,
pub pinned: bool,
pub images: Vec<ImageRef>,
pub loaded: Vec<Loaded>,
pub kept_images: Box<[KeptImage]>,
}Expand description
What a successful tool call returns.
Journaled, hence serializable.
Fields§
§content: StringText handed back to the model as the tool result.
is_error: boolWhether the tool reports failure. The model still sees content (the
run does not fail); the tool message is marked is_error.
artifacts: Vec<Artifact>Outputs of the run, emitted as [RunEvent::Artifact] (durable, see
RunView::artifacts).
answer: Option<String>Words the tool announces as the run’s answer: when the run finishes, they are its
output’s text (the A2A completed status message), not the closing words of the model.
See announcing. Never read from an error result.
Journaled with the result, so a replay announces the same words; absent from a journal
written before it existed, and not written while it is None.
ends_turn: boolThe announced answer is also the end of the turn: once the calls the
model asked for in this turn are answered, the run finishes with it and the model is not
called again. See final_answer. Ignored without an answer, and never
read from an error result.
Absent from a journal written before it existed, and not written while it is false.
sandbox: SandboxUsageThe time the call’s commands ran in a sandbox, as the call reported it
(ToolCtx::report_sandbox); the agent loop fills it in from what the call reported. Journaled
with the result, so the run counts it once, and a replay counts the same.
Absent from a journal written before it existed, and not written while empty.
repeat_key: Option<Box<String>>What the tool says makes two results of the same call the same result for the
repeated-call rule (doom_loop): two answers of one call (same tool, same arguments) that
carry the same key count as equal, whatever their text says. A command that fails the same way
twice prints a different duration or path each time, so its text never repeats to the byte; the
key (exit:2) does (boxed, so that a Result<_, ToolOutput> stays small). See with_repeat_key.
Journaled with the result, so a replay decides the same; absent from a journal written before
it existed, and not written while it is None.
plan: Option<Box<Plan>>The conversation’s plan as it is after this call (Plan): the whole plan, not a change.
The loop makes it the run’s plan when the result is not an error, in the same commit as the
result; a replay takes it from the journal. Read the plan a call starts from with
ToolCtx::plan. Never read from an error result.
Absent from a journal written before it existed, and not written while it is None.
kept: Option<Box<KeptOutput>>A long text the tool wants the run to keep in its own state, for
read_output to page through (keep_long makes it,
and only when the agent has no KeptStore). The loop moves it into
Conversation::kept_outputs; it is journaled with the
result, so a replay keeps the same text.
Absent from a journal written before it existed, and not written while None.
reported: Vec<RunId>The rounds of child sessions whose reports this result gives the model (ADR 0045), as run
ids. A result that gives one is the moment the loop counts the tokens of the rounds this
run started that have ended, in the run’s totals, once each
(Conversation::rounds_started); only whether the list
is empty is read, because a run id differs between a run and a copy of its journal. Set by
the session tools only. Never read from an error result.
Absent from a journal written before it existed, and not written while empty.
Honoured only from a tool that runs alone. The loop reads the rounds in a journaled step of its own right after the call; beside other calls (ADR 0049) that step has no place between them, so a call of a segment of several that reports rounds is answered with an error that tells the model to call the tool alone.
pinned: boolThe result is pinned: a compaction that drops it from the history copies it into the marker that stands in for what was dropped (up to 32 KiB, and 64 KiB for all the results that were pinned), so what the model must keep knowing (a workspace’s path and branch, the instructions of a repository) outlives the summary. Set it only for a small result that is the tool’s own and whose loss would leave the model not knowing where it is: it is copied as text into a user message. Never read from an error result.
Absent from a journal written before it existed, and not written while it is false.
images: Vec<ImageRef>Images the result returns, by reference: keep_image admits and keeps
them, with_image adds one. The history holds them on the tool’s message,
and a model that sees is sent them after the run of tool messages; the references hold no
byte. Never read from an error result.
Absent from a journal written before it existed, and not written while empty.
loaded: Vec<Loaded>The groups and tools the run has loaded, as this result says: the whole list the call saw,
with the one it loaded, in the order they were loaded. The loop applies it to the run’s
state (Conversation::loaded) when the result is not an
error, in the same commit as the result, and records the turn of the next request in
Conversation::tools_appended; a replay takes the
list from the journal. A load appends its tools to the tools array, never inserts them (ADR
0044, decision 1). Only a group loader (load__group__…) sets it. Never read from
an error result.
Absent from a journal written before it existed, and not written while empty.
kept_images: Box<[KeptImage]>The bytes of images, for the run to keep in its own state: only when
the agent has no ImageStore (keep_image says
which). Journaled with the result, like kept, so a replay keeps the same
images.
Absent from a journal written before it existed, and not written while empty.
Implementations§
§impl ToolOutput
impl ToolOutput
pub fn text(content: impl Into<String>) -> ToolOutput
pub fn text(content: impl Into<String>) -> ToolOutput
A successful result with no artifacts.
pub fn error(content: impl Into<String>) -> ToolOutput
pub fn error(content: impl Into<String>) -> ToolOutput
A failed result the model should see and react to (for example invalid arguments). It does not fail the run.
pub fn with_image(self, outcome: ImageOutcome) -> ToolOutput
pub fn with_image(self, outcome: ImageOutcome) -> ToolOutput
Add the image outcome admitted (keep_image) to the result. An image
that was not admitted adds nothing: its line is ImageOutcome::stand_in, for the text.
pub fn with_loaded(self, loaded: impl IntoIterator<Item = Loaded>) -> ToolOutput
pub fn with_loaded(self, loaded: impl IntoIterator<Item = Loaded>) -> ToolOutput
Say what the run has loaded (loaded): the whole list this call saw, with
its own entry added, in the order they were loaded. The next model call is the first whose
tools array has the loaded groups’ tools appended.
pub fn announcing(self, text: impl Into<String>) -> ToolOutput
pub fn announcing(self, text: impl Into<String>) -> ToolOutput
Announce text as the run’s answer: once the run finishes, text is what it answered, and
what the model says in its last turn is not. A later call that announces replaces it (the
last announcement wins), and one that fails announces nothing: an error result’s answer
is ignored. The announcement lasts until a new message reaches the run.
For a tool that hands the final answer over by another route (the thread tool
turn_output of adam-ui does), so that a client that reads only the run’s output reads the
same answer the person was shown.
pub fn final_answer(self, text: impl Into<String>) -> ToolOutput
pub fn final_answer(self, text: impl Into<String>) -> ToolOutput
Announce text as the run’s answer and end the turn with it: like
announcing, and once the calls of this model turn are answered the run
finishes with text as its output, with no further model call, so the model has no closing
line to write after an answer the person has already read. A message that reached the run
meanwhile is read first: the model is called again with it, and the announcement ends there
as a new turn’s would. A call that fails ends nothing.
For a tool whose call is the model’s answer (turn_output of adam-ui).
pub fn with_repeat_key(self, key: impl Into<String>) -> ToolOutput
pub fn with_repeat_key(self, key: impl Into<String>) -> ToolOutput
Say what makes this result the same as another of the same call for the repeated-call rule:
three calls in a row with the same tool and arguments are refused when the two before carried
the same key (or gave equal results, or both were errors). Set it only for a failure whose
text varies and whose cause does not (exit:2), never on a success: a poll that succeeds with
a changing text must keep running.
pub fn pinned(self) -> ToolOutput
pub fn pinned(self) -> ToolOutput
Pin the result: see pinned.
pub fn with_plan(self, plan: Plan) -> ToolOutput
pub fn with_plan(self, plan: Plan) -> ToolOutput
Make plan the conversation’s plan, when this result is not an error: see
plan.
pub fn with_artifact(self, artifact: Artifact) -> ToolOutput
pub fn with_artifact(self, artifact: Artifact) -> ToolOutput
Add an artifact.
Trait Implementations§
§impl Clone for ToolOutput
impl Clone for ToolOutput
§fn clone(&self) -> ToolOutput
fn clone(&self) -> ToolOutput
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for ToolOutput
impl Debug for ToolOutput
§impl Default for ToolOutput
impl Default for ToolOutput
§fn default() -> ToolOutput
fn default() -> ToolOutput
§impl<'de> Deserialize<'de> for ToolOutput
impl<'de> Deserialize<'de> for ToolOutput
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolOutput, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolOutput, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl IntoToolOutput for ToolOutput
impl IntoToolOutput for ToolOutput
§fn into_tool_output(self) -> ToolOutput
fn into_tool_output(self) -> ToolOutput
§impl PartialEq for ToolOutput
impl PartialEq for ToolOutput
§impl Serialize for ToolOutput
impl Serialize for ToolOutput
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for ToolOutput
Auto Trait Implementations§
impl Freeze for ToolOutput
impl RefUnwindSafe for ToolOutput
impl Send for ToolOutput
impl Sync for ToolOutput
impl Unpin for ToolOutput
impl UnsafeUnpin for ToolOutput
impl UnwindSafe for ToolOutput
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>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> IntoToolResult for Twhere
T: IntoToolOutput,
impl<T> IntoToolResult for Twhere
T: IntoToolOutput,
§fn into_tool_result(self) -> Result<ToolOutput, ToolError>
fn into_tool_result(self) -> Result<ToolOutput, ToolError>
§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].