#[non_exhaustive]pub enum StopReason {
RequestedByTool(ToolCall),
ToolCallsOverLimit(ToolCall),
FeedbackRequired {
tool_call: ToolCall,
payload: Option<Value>,
},
Error,
NoNewMessages,
Other(String),
}
Expand description
The reason the agent stopped
StopReason::Other
has some convenience methods to convert from any AsRef<str>
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
RequestedByTool(ToolCall)
A tool called stop
ToolCallsOverLimit(ToolCall)
A tool repeatedly failed
FeedbackRequired
A tool requires feedback before it will continue
Error
There was an error
NoNewMessages
No new messages; stopping completions
Other(String)
Implementations§
Source§impl StopReason
impl StopReason
Sourcepub const fn is_requested_by_tool(&self) -> bool
pub const fn is_requested_by_tool(&self) -> bool
Returns true if the enum is StopReason::RequestedByTool otherwise false
Sourcepub const fn is_tool_calls_over_limit(&self) -> bool
pub const fn is_tool_calls_over_limit(&self) -> bool
Returns true if the enum is StopReason::ToolCallsOverLimit otherwise false
Sourcepub const fn is_feedback_required(&self) -> bool
pub const fn is_feedback_required(&self) -> bool
Returns true if the enum is StopReason::FeedbackRequired otherwise false
Sourcepub const fn is_error(&self) -> bool
pub const fn is_error(&self) -> bool
Returns true if the enum is StopReason::Error otherwise false
Sourcepub const fn is_no_new_messages(&self) -> bool
pub const fn is_no_new_messages(&self) -> bool
Returns true if the enum is StopReason::NoNewMessages otherwise false
Source§impl StopReason
impl StopReason
pub fn as_requested_by_tool(&self) -> Option<&ToolCall>
pub fn as_tool_calls_over_limit(&self) -> Option<&ToolCall>
pub fn as_feedback_required(&self) -> Option<(&ToolCall, Option<&Value>)>
pub fn as_error(&self) -> Option<()>
pub fn as_no_new_messages(&self) -> Option<()>
pub fn as_other(&self) -> Option<&str>
Trait Implementations§
Source§impl Clone for StopReason
impl Clone for StopReason
Source§fn clone(&self) -> StopReason
fn clone(&self) -> StopReason
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for StopReason
impl Debug for StopReason
Source§impl Default for StopReason
impl Default for StopReason
Auto Trait Implementations§
impl Freeze for StopReason
impl RefUnwindSafe for StopReason
impl Send for StopReason
impl Sync for StopReason
impl Unpin for StopReason
impl UnwindSafe for StopReason
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
Mutably borrows from an owned value. Read more
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> 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>
Converts
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>
Converts
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