adk_studio/schema/
agent.rs

1use serde::{Deserialize, Serialize};
2
3/// Agent definition schema
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct AgentSchema {
6    #[serde(rename = "type")]
7    pub agent_type: AgentType,
8    #[serde(default)]
9    pub model: Option<String>,
10    #[serde(default)]
11    pub instruction: String,
12    #[serde(default)]
13    pub tools: Vec<String>,
14    #[serde(default)]
15    pub sub_agents: Vec<String>,
16    #[serde(default)]
17    pub position: Position,
18    #[serde(default)]
19    pub max_iterations: Option<u32>,
20    /// For router agents: condition -> target agent mapping
21    #[serde(default)]
22    pub routes: Vec<Route>,
23}
24
25/// A conditional route
26#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct Route {
28    pub condition: String,
29    pub target: String,
30}
31
32impl AgentSchema {
33    pub fn llm(model: impl Into<String>) -> Self {
34        Self {
35            agent_type: AgentType::Llm,
36            model: Some(model.into()),
37            instruction: String::new(),
38            tools: Vec::new(),
39            sub_agents: Vec::new(),
40            position: Position::default(),
41            max_iterations: None,
42            routes: Vec::new(),
43        }
44    }
45
46    pub fn with_instruction(mut self, instruction: impl Into<String>) -> Self {
47        self.instruction = instruction.into();
48        self
49    }
50
51    pub fn with_tools(mut self, tools: Vec<String>) -> Self {
52        self.tools = tools;
53        self
54    }
55
56    pub fn with_position(mut self, x: f64, y: f64) -> Self {
57        self.position = Position { x, y };
58        self
59    }
60}
61
62/// Agent type
63#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
64#[serde(rename_all = "snake_case")]
65pub enum AgentType {
66    Llm,
67    Tool,
68    Sequential,
69    Parallel,
70    Loop,
71    Router,
72    Graph,
73    Custom,
74}
75
76/// Canvas position
77#[derive(Debug, Clone, Serialize, Deserialize, Default)]
78pub struct Position {
79    pub x: f64,
80    pub y: f64,
81}