Skip to main content

synaptic_tools/
return_direct.rs

1use std::sync::Arc;
2
3use async_trait::async_trait;
4use serde_json::Value;
5use synaptic_core::{SynapticError, Tool};
6
7/// A tool wrapper that signals the agent should return the tool's output directly
8/// to the user without further LLM processing.
9pub struct ReturnDirectTool {
10    inner: Arc<dyn Tool>,
11}
12
13impl ReturnDirectTool {
14    /// Wrap an existing tool so its output is returned directly to the user.
15    pub fn new(inner: Arc<dyn Tool>) -> Self {
16        Self { inner }
17    }
18
19    /// Returns `true`, indicating this tool's output should be returned directly.
20    pub fn is_return_direct(&self) -> bool {
21        true
22    }
23}
24
25#[async_trait]
26impl Tool for ReturnDirectTool {
27    fn name(&self) -> &'static str {
28        self.inner.name()
29    }
30
31    fn description(&self) -> &'static str {
32        self.inner.description()
33    }
34
35    async fn call(&self, args: Value) -> Result<Value, SynapticError> {
36        self.inner.call(args).await
37    }
38}