walrus_core/agent/
config.rs1use crate::model::ToolChoice;
7use compact_str::CompactString;
8use serde::{Deserialize, Serialize};
9use smallvec::SmallVec;
10
11const DEFAULT_MAX_ITERATIONS: usize = 16;
13
14#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct AgentConfig {
21 pub name: CompactString,
23 pub description: CompactString,
25 pub system_prompt: String,
27 pub model: Option<CompactString>,
29 pub max_iterations: usize,
31 pub tool_choice: ToolChoice,
33 pub tools: SmallVec<[CompactString; 8]>,
35 pub skill_tags: SmallVec<[CompactString; 4]>,
37}
38
39impl Default for AgentConfig {
40 fn default() -> Self {
41 Self {
42 name: CompactString::default(),
43 description: CompactString::default(),
44 system_prompt: String::new(),
45 model: None,
46 max_iterations: DEFAULT_MAX_ITERATIONS,
47 tool_choice: ToolChoice::Auto,
48 tools: SmallVec::new(),
49 skill_tags: SmallVec::new(),
50 }
51 }
52}
53
54impl AgentConfig {
55 pub fn new(name: impl Into<CompactString>) -> Self {
57 Self {
58 name: name.into(),
59 ..Default::default()
60 }
61 }
62
63 pub fn system_prompt(mut self, prompt: impl Into<String>) -> Self {
65 self.system_prompt = prompt.into();
66 self
67 }
68
69 pub fn description(mut self, desc: impl Into<CompactString>) -> Self {
71 self.description = desc.into();
72 self
73 }
74
75 pub fn tool(mut self, name: impl Into<CompactString>) -> Self {
77 self.tools.push(name.into());
78 self
79 }
80
81 pub fn skill_tag(mut self, tag: impl Into<CompactString>) -> Self {
83 self.skill_tags.push(tag.into());
84 self
85 }
86
87 pub fn model(mut self, name: impl Into<CompactString>) -> Self {
89 self.model = Some(name.into());
90 self
91 }
92}