pub struct ToolCtx {
pub progress: ToolProgress,
/* private fields */
}Expand description
调用工具时注入的运行时上下文。
大多数工具用不到它(用 ToolRegistry::register 注册的 handler 拿不到);
需要上报工具进度时用 ToolRegistry::register_with_ctx 注册,并通过
ToolCtx::progress 发出增量输出。这样实时 UI 与 check(id) 看到的内容保持一致。
Fields§
§progress: ToolProgress当前工具调用的进度通道。
Implementations§
Source§impl ToolCtx
impl ToolCtx
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
当前会话 id。工具需要打标签或组织输出时可读取;进度输出请走 ToolCtx::progress。
Sourcepub fn cancellation_token(&self) -> CancellationToken
pub fn cancellation_token(&self) -> CancellationToken
当前这轮 run 的取消令牌。派生子 agent 的工具应用它(或 child_token())替代
CancellationToken::new(),以便取消能向下传播。
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ToolCtx
impl RefUnwindSafe for ToolCtx
impl Send for ToolCtx
impl Sync for ToolCtx
impl Unpin for ToolCtx
impl UnsafeUnpin for ToolCtx
impl UnwindSafe for ToolCtx
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