pub struct ToolConfig {
pub max_usage_count: Option<u32>,
pub result_as_answer: bool,
/* private fields */
}Expand description
Configuration that wraps a Tool to add usage limits and short-circuit behaviour.
Fields§
§max_usage_count: Option<u32>If Some(n), the tool is disabled after n successful calls.
result_as_answer: boolIf true, the tool’s output is used directly as the final answer, bypassing further LLM reasoning in the agent loop.
Implementations§
Source§impl ToolConfig
impl ToolConfig
Sourcepub fn new(tool: Arc<dyn Tool>) -> Self
pub fn new(tool: Arc<dyn Tool>) -> Self
Wrap a tool with default configuration (no usage limit, no result-as-answer).
Sourcepub fn with_max_usage(self, n: u32) -> Self
pub fn with_max_usage(self, n: u32) -> Self
Set the maximum number of times this tool may be called before it is disabled.
Sourcepub fn with_result_as_answer(self) -> Self
pub fn with_result_as_answer(self) -> Self
Mark this tool so that its output is treated as the final agent answer.
Sourcepub fn is_exhausted(&self) -> bool
pub fn is_exhausted(&self) -> bool
Returns true when the tool has hit its usage cap.
Trait Implementations§
Source§impl Tool for ToolConfig
impl Tool for ToolConfig
fn name(&self) -> &str
fn description(&self) -> &str
fn parameters(&self) -> Value
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: Value,
ctx: &'life1 ToolContext<'life2>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Auto Trait Implementations§
impl !Freeze for ToolConfig
impl !RefUnwindSafe for ToolConfig
impl !UnwindSafe for ToolConfig
impl Send for ToolConfig
impl Sync for ToolConfig
impl Unpin for ToolConfig
impl UnsafeUnpin for ToolConfig
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