#[non_exhaustive]pub struct ToolResult {
pub code: i32,
pub stdout: String,
pub stderr: String,
pub data: Option<Value>,
pub output: Option<OutputData>,
pub did_spill: bool,
pub original_code: Option<i64>,
pub content_type: Option<String>,
pub baggage: BTreeMap<String, String>,
}Expand description
Result from tool execution via backend.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.code: i32Exit code (0 = success).
stdout: StringStandard output.
stderr: StringStandard error.
data: Option<Value>Structured data (if any).
output: Option<OutputData>Structured output data for rendering (preserved from ExecResult).
did_spill: boolTrue if the output limiter capped this result (propagated from
ExecResult). See ExecResult.did_spill for the full semantics (disk
spill vs. in-memory truncation, exit code remap to 3).
original_code: Option<i64>The command’s original exit code before spill logic overwrote it
(propagated from ExecResult). Present only when did_spill is true
and code was changed. See ExecResult.original_code.
content_type: Option<String>MIME content type hint (propagated from ExecResult).
baggage: BTreeMap<String, String>Opaque key-value context (propagated from ExecResult).
Implementations§
Source§impl ToolResult
impl ToolResult
Sourcepub fn success(stdout: impl Into<String>) -> ToolResult
pub fn success(stdout: impl Into<String>) -> ToolResult
Create a successful result.
Sourcepub fn with_data(stdout: impl Into<String>, data: Value) -> ToolResult
pub fn with_data(stdout: impl Into<String>, data: Value) -> ToolResult
Create a result with structured data.
Sourcepub fn with_output(self, output: Option<OutputData>) -> ToolResult
pub fn with_output(self, output: Option<OutputData>) -> ToolResult
Set the structured output-data payload, returning self for chaining.
Sourcepub fn with_content_type(self, ct: impl Into<String>) -> ToolResult
pub fn with_content_type(self, ct: impl Into<String>) -> ToolResult
Set the content-type hint, returning self for chaining.
Sourcepub fn with_baggage(self, baggage: BTreeMap<String, String>) -> ToolResult
pub fn with_baggage(self, baggage: BTreeMap<String, String>) -> ToolResult
Replace the baggage map, returning self for chaining.
Sourcepub fn with_did_spill(self, did_spill: bool) -> ToolResult
pub fn with_did_spill(self, did_spill: bool) -> ToolResult
Set the spill flag, returning self for chaining.
Sourcepub fn with_original_code(self, original_code: Option<i64>) -> ToolResult
pub fn with_original_code(self, original_code: Option<i64>) -> ToolResult
Set the pre-spill original exit code, returning self for chaining.
Trait Implementations§
Source§impl Clone for ToolResult
impl Clone for ToolResult
Source§fn clone(&self) -> ToolResult
fn clone(&self) -> ToolResult
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 ToolResult
impl Debug for ToolResult
Source§impl From<ExecResult> for ToolResult
impl From<ExecResult> for ToolResult
Source§fn from(exec: ExecResult) -> ToolResult
fn from(exec: ExecResult) -> ToolResult
Source§impl From<ToolResult> for ExecResult
impl From<ToolResult> for ExecResult
Source§fn from(result: ToolResult) -> ExecResult
fn from(result: ToolResult) -> ExecResult
The symmetric peer of From<ExecResult> for ToolResult above — every
field that direction preserves, this direction must preserve too, or a
backend-registered tool’s structured data/content_type/baggage
silently vanishes crossing back into the kernel (the embedder seam:
x=$(embedder_tool) and for r in $(embedder_tool) need .data to
see typed results, not just stdout text).
data uses json_to_value_no_envelope rather than the internal
round-trip conversion: a backend tool’s JSON is external input, so an
object shaped like the byte envelope must stay a plain record, never
silently auto-decode to Value::Bytes.
Auto Trait Implementations§
impl Freeze for ToolResult
impl RefUnwindSafe for ToolResult
impl Send for ToolResult
impl Sync for ToolResult
impl Unpin for ToolResult
impl UnsafeUnpin for ToolResult
impl UnwindSafe for ToolResult
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,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> OrderedSeq<'_, T> for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
Source§impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
Source§fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
WrappingSpan::make_wrapped to wrap an AST node in a span.