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)]
18pub struct AgentConfig {
19 pub name: CompactString,
21 pub description: CompactString,
23 pub system_prompt: String,
25 pub model: Option<CompactString>,
27 pub max_iterations: usize,
29 pub tool_choice: ToolChoice,
31}
32
33impl Default for AgentConfig {
34 fn default() -> Self {
35 Self {
36 name: CompactString::default(),
37 description: CompactString::default(),
38 system_prompt: String::new(),
39 model: None,
40 max_iterations: DEFAULT_MAX_ITERATIONS,
41 tool_choice: ToolChoice::Auto,
42 }
43 }
44}
45
46impl AgentConfig {
47 pub fn new(name: impl Into<CompactString>) -> Self {
49 Self {
50 name: name.into(),
51 ..Default::default()
52 }
53 }
54
55 pub fn system_prompt(mut self, prompt: impl Into<String>) -> Self {
57 self.system_prompt = prompt.into();
58 self
59 }
60
61 pub fn description(mut self, desc: impl Into<CompactString>) -> Self {
63 self.description = desc.into();
64 self
65 }
66
67 pub fn model(mut self, name: impl Into<CompactString>) -> Self {
69 self.model = Some(name.into());
70 self
71 }
72}