Skip to main content

llm_stack/tool/
output.rs

1//! Tool output types.
2
3/// Output returned by a tool handler.
4///
5/// Contains the content string that will be sent back to the LLM.
6/// For application-level metadata (metrics, request IDs, etc.), use
7/// the context parameter to write to shared state instead.
8///
9/// # Example
10///
11/// ```rust
12/// use llm_stack::tool::ToolOutput;
13///
14/// let output = ToolOutput::new("Result: 42");
15/// ```
16#[derive(Debug, Clone, Default)]
17pub struct ToolOutput {
18    /// The content to return to the LLM.
19    pub content: String,
20}
21
22impl ToolOutput {
23    /// Creates a new tool output with the given content.
24    pub fn new(content: impl Into<String>) -> Self {
25        Self {
26            content: content.into(),
27        }
28    }
29}
30
31impl From<String> for ToolOutput {
32    fn from(s: String) -> Self {
33        Self::new(s)
34    }
35}
36
37impl From<&str> for ToolOutput {
38    fn from(s: &str) -> Self {
39        Self::new(s)
40    }
41}