Skip to main content

windmill_api/models/
agent_tool.rs

1/*
2 * Windmill API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.881.1
7 * Contact: contact@windmill.dev
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// AgentTool : A tool available to an AI agent. Can be a flow module or an external MCP (Model Context Protocol) tool
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct AgentTool {
17    /// Unique identifier for this tool. Cannot contain spaces - use underscores instead (e.g., 'get_user_data' not 'get user data')
18    #[serde(rename = "id")]
19    pub id: String,
20    /// The name the AI agent calls this tool by, not a human label. On a flowmodule tool it must match ^[a-zA-Z0-9_]+$ - letters, numbers and underscores only (e.g. 'search_documentation', not 'Search documentation') - and always be set; on an mcp, websearch or question tool it is a plain label. Put the human-readable explanation in 'description'.
21    #[serde(rename = "summary", skip_serializing_if = "Option::is_none")]
22    pub summary: Option<String>,
23    /// Free-text description of the tool given to the AI to decide when and how to call it. Overrides the description auto-derived from the underlying script.
24    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
25    pub description: Option<String>,
26    /// Scopes the token of this tool's jobs is restricted to, on top of the agent step's own restriction: a tool can only narrow it.
27    #[serde(rename = "job_token_scopes", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
28    pub job_token_scopes: Option<Option<Vec<String>>>,
29    /// Flowmodule and mcp tools only. Each call waits for a person to approve or reject it from the flow's run page or chat, without the agent holding a worker. Calls in the same turn that do not require approval run right away. A rejected call, or one nobody answers within 30 minutes, is reported to the AI as not run.
30    #[serde(rename = "requires_approval", skip_serializing_if = "Option::is_none")]
31    pub requires_approval: Option<bool>,
32    /// Flowmodule tools only. The agent is answered as soon as the tool's job starts and keeps working; the job's result reaches it in a later message. If the agent finishes its answer first, it stops without holding a worker until the job is done, then continues with the result.
33    #[serde(rename = "background", skip_serializing_if = "Option::is_none")]
34    pub background: Option<bool>,
35    /// Flowmodule tools only, with background unset. The agent waits up to this many seconds for the tool's job and gets its result as usual; a job still running then continues as a background one, its result reaching the agent in a later message.
36    #[serde(rename = "background_after_secs", skip_serializing_if = "Option::is_none")]
37    pub background_after_secs: Option<i32>,
38    #[serde(rename = "value")]
39    pub value: Box<models::ToolValue>,
40}
41
42impl AgentTool {
43    /// A tool available to an AI agent. Can be a flow module or an external MCP (Model Context Protocol) tool
44    pub fn new(id: String, value: models::ToolValue) -> AgentTool {
45        AgentTool {
46            id,
47            summary: None,
48            description: None,
49            job_token_scopes: None,
50            requires_approval: None,
51            background: None,
52            background_after_secs: None,
53            value: Box::new(value),
54        }
55    }
56}
57