swiftide_agents/tools/
control.rs1use anyhow::Result;
3use async_trait::async_trait;
4use std::borrow::Cow;
5use swiftide_core::{
6 AgentContext,
7 chat_completion::{Tool, ToolOutput, ToolSpec, errors::ToolError},
8};
9
10#[derive(Clone, Debug, Default)]
12pub struct Stop {}
13
14#[async_trait]
15impl Tool for Stop {
16 async fn invoke(
17 &self,
18 _agent_context: &dyn AgentContext,
19 _raw_args: Option<&str>,
20 ) -> Result<ToolOutput, ToolError> {
21 Ok(ToolOutput::Stop)
22 }
23
24 fn name(&self) -> Cow<'_, str> {
25 "stop".into()
26 }
27
28 fn tool_spec(&self) -> ToolSpec {
29 ToolSpec::builder()
30 .name("stop")
31 .description("When you have completed, or cannot complete, your task, call this")
32 .build()
33 .unwrap()
34 }
35}
36
37impl From<Stop> for Box<dyn Tool> {
38 fn from(val: Stop) -> Self {
39 Box::new(val)
40 }
41}