walrus_core/agent/
config.rs1use crate::model::ToolChoice;
7use compact_str::CompactString;
8use serde::{Deserialize, Serialize};
9
10const DEFAULT_MAX_ITERATIONS: usize = 16;
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
19pub struct AgentConfig {
20 #[serde(skip)]
22 pub name: CompactString,
23 #[serde(default)]
25 pub description: CompactString,
26 #[serde(skip)]
28 pub system_prompt: String,
29 #[serde(default)]
31 pub model: Option<CompactString>,
32 #[serde(default = "default_max_iterations")]
34 pub max_iterations: usize,
35 #[serde(skip)]
37 pub tool_choice: ToolChoice,
38 #[serde(default)]
40 pub thinking: bool,
41 #[serde(default)]
43 pub heartbeat: HeartbeatConfig,
44 #[serde(default)]
46 pub members: Vec<String>,
47 #[serde(default)]
49 pub skills: Vec<String>,
50 #[serde(default)]
52 pub mcps: Vec<String>,
53 #[serde(skip)]
55 pub tools: Vec<CompactString>,
56}
57
58fn default_max_iterations() -> usize {
59 DEFAULT_MAX_ITERATIONS
60}
61
62impl Default for AgentConfig {
63 fn default() -> Self {
64 Self {
65 name: CompactString::default(),
66 description: CompactString::default(),
67 system_prompt: String::new(),
68 model: None,
69 max_iterations: DEFAULT_MAX_ITERATIONS,
70 tool_choice: ToolChoice::Auto,
71 thinking: false,
72 heartbeat: HeartbeatConfig::default(),
73 members: Vec::new(),
74 skills: Vec::new(),
75 mcps: Vec::new(),
76 tools: Vec::new(),
77 }
78 }
79}
80
81impl AgentConfig {
82 pub fn new(name: impl Into<CompactString>) -> Self {
84 Self {
85 name: name.into(),
86 ..Default::default()
87 }
88 }
89
90 pub fn system_prompt(mut self, prompt: impl Into<String>) -> Self {
92 self.system_prompt = prompt.into();
93 self
94 }
95
96 pub fn description(mut self, desc: impl Into<CompactString>) -> Self {
98 self.description = desc.into();
99 self
100 }
101
102 pub fn model(mut self, name: impl Into<CompactString>) -> Self {
104 self.model = Some(name.into());
105 self
106 }
107
108 pub fn thinking(mut self, enabled: bool) -> Self {
110 self.thinking = enabled;
111 self
112 }
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize, Default)]
117pub struct HeartbeatConfig {
118 #[serde(default)]
120 pub interval: u64,
121 #[serde(default)]
123 pub prompt: String,
124}