#[non_exhaustive]pub struct AutoFunctionResult {
pub response: InteractionResponse,
pub executions: Vec<FunctionExecutionResult>,
pub reached_max_loops: bool,
}Expand description
Result from create_with_auto_functions() containing the final response
and a history of all function executions.
This type provides visibility into which functions were called during automatic function execution, useful for debugging, logging, and evaluation.
§Memory Considerations
The executions vector accumulates all FunctionExecutionResult records
from each iteration of the auto-function loop. For typical use cases (1-5
iterations with 1-3 functions each), this is negligible.
For edge cases with many function calls or large result payloads, consider:
- Limit iterations: Use
crate::InteractionBuilder::with_max_function_call_loops()to cap the maximum number of iterations (default: 5) - Extract and drop: Extract only the data you need, then drop the result
- Manual control: For fine-grained memory management, implement function
calling manually using
crate::InteractionBuilder::add_functions()andcrate::InteractionBuilder::create()instead of the auto-function helpers
Each FunctionExecutionResult contains the function name, call ID, result
value (as serde_json::Value), and execution duration. Memory usage scales
primarily with the size of function result payloads.
§Example
let result = client
.interaction()
.with_model("gemini-3-flash-preview")
.with_text("What's the weather in London?")
.create_with_auto_functions()
.await?;
// Access the final response
if let Some(text) = result.response.as_text() {
println!("Answer: {}", text);
}
// Access execution history
for exec in &result.executions {
println!("Called {} -> {}", exec.name, exec.result);
}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.response: InteractionResponseThe final response from the model (after all function calls completed)
executions: Vec<FunctionExecutionResult>All functions that were executed during the auto-function loop
reached_max_loops: boolWhether the auto-function loop was terminated due to reaching the maximum
number of iterations (set via with_max_function_call_loops()).
When true, the response contains the last response from the model before
hitting the limit, which likely still contains pending function calls.
The executions vector contains all functions that were successfully executed
before the limit was reached.
This allows debugging why the model is stuck in a loop and preserves partial results that may still be useful.
Implementations§
Source§impl AutoFunctionResult
impl AutoFunctionResult
Sourcepub fn all_executions_succeeded(&self) -> bool
pub fn all_executions_succeeded(&self) -> bool
Returns true if all function executions succeeded (no errors).
This is useful for detecting missing function implementations or function execution failures that would otherwise be silently sent to the model as error results.
§Example
let result = client.interaction()
.with_text("What's the weather?")
.add_functions(vec![get_weather_function()])
.create_with_auto_functions()
.await?;
assert!(result.all_executions_succeeded(),
"Function executions failed: {:?}",
result.failed_executions());Sourcepub fn failed_executions(&self) -> Vec<&FunctionExecutionResult>
pub fn failed_executions(&self) -> Vec<&FunctionExecutionResult>
Returns all executions that failed (had errors).
Trait Implementations§
Source§impl Clone for AutoFunctionResult
impl Clone for AutoFunctionResult
Source§fn clone(&self) -> AutoFunctionResult
fn clone(&self) -> AutoFunctionResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AutoFunctionResult
impl Debug for AutoFunctionResult
Source§impl<'de> Deserialize<'de> for AutoFunctionResult
impl<'de> Deserialize<'de> for AutoFunctionResult
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>,
Auto Trait Implementations§
impl Freeze for AutoFunctionResult
impl RefUnwindSafe for AutoFunctionResult
impl Send for AutoFunctionResult
impl Sync for AutoFunctionResult
impl Unpin for AutoFunctionResult
impl UnwindSafe for AutoFunctionResult
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> 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>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);