pub struct ToolExecutor { /* private fields */ }Expand description
工具执行器 — 按名称分派 ToolCall 到实际工具函数。
内部持有 ToolCatalog,通过 snapshot() 获取冻结工具快照。
Clone 为 O(1)(Arc 浅拷贝)。
Implementations§
Source§impl ToolExecutor
impl ToolExecutor
Sourcepub fn new(catalog: Arc<dyn ToolCatalog>) -> Self
pub fn new(catalog: Arc<dyn ToolCatalog>) -> Self
绑定工具目录。
Sourcepub fn with_catalog(catalog: Arc<dyn ToolCatalog>) -> Self
pub fn with_catalog(catalog: Arc<dyn ToolCatalog>) -> Self
绑定工具目录,使用默认重试策略。
Sourcepub fn with_retry_policy(
catalog: Arc<dyn ToolCatalog>,
policy: RetryPolicy,
) -> Self
pub fn with_retry_policy( catalog: Arc<dyn ToolCatalog>, policy: RetryPolicy, ) -> Self
构造时绑定全局重试策略。
Sourcepub fn set_retry_policy(&mut self, policy: RetryPolicy)
pub fn set_retry_policy(&mut self, policy: RetryPolicy)
设置/替换重试策略。
Sourcepub fn retry_policy(&self) -> RetryPolicy
pub fn retry_policy(&self) -> RetryPolicy
获取当前重试策略的克隆。
Sourcepub async fn snapshot(&self) -> Arc<ToolSnapshot> ⓘ
pub async fn snapshot(&self) -> Arc<ToolSnapshot> ⓘ
获取冻结工具快照。
每轮迭代调用一次,固定本轮工具集。
Sourcepub async fn execute_with_snapshot(
&self,
call: &ToolCall,
snapshot: &ToolSnapshot,
) -> ToolResult
pub async fn execute_with_snapshot( &self, call: &ToolCall, snapshot: &ToolSnapshot, ) -> ToolResult
执行单个工具调用,自带重试。
使用预解析的快照执行。
Sourcepub async fn execute_with_emission(
&self,
call: &ToolCall,
snapshot: &ToolSnapshot,
tx: &Sender<AgentEvent>,
) -> ToolResult
pub async fn execute_with_emission( &self, call: &ToolCall, snapshot: &ToolSnapshot, tx: &Sender<AgentEvent>, ) -> ToolResult
执行单个工具调用,自带重试 + Retry 事件发射。
Trait Implementations§
Source§impl Clone for ToolExecutor
impl Clone for ToolExecutor
Source§fn clone(&self) -> ToolExecutor
fn clone(&self) -> ToolExecutor
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ToolExecutor
impl !UnwindSafe for ToolExecutor
impl Freeze for ToolExecutor
impl Send for ToolExecutor
impl Sync for ToolExecutor
impl Unpin for ToolExecutor
impl UnsafeUnpin for ToolExecutor
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