use crate::model::ToolChoice;
use serde::{Deserialize, Serialize};
const DEFAULT_MAX_ITERATIONS: usize = 16;
const DEFAULT_COMPACT_THRESHOLD: usize = 100_000;
const DEFAULT_COMPACT_TOOL_MAX_LEN: usize = 1024;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentConfig {
#[serde(skip)]
pub name: String,
#[serde(default)]
pub description: String,
#[serde(skip)]
pub system_prompt: String,
#[serde(default)]
pub model: Option<String>,
#[serde(default = "default_max_iterations")]
pub max_iterations: usize,
#[serde(default)]
pub tool_choice: ToolChoice,
#[serde(default)]
pub thinking: bool,
#[serde(default)]
pub members: Vec<String>,
#[serde(default)]
pub skills: Vec<String>,
#[serde(default)]
pub mcps: Vec<String>,
#[serde(skip)]
pub tools: Vec<String>,
#[serde(default = "default_compact_threshold")]
pub compact_threshold: Option<usize>,
#[serde(default = "default_compact_tool_max_len")]
pub compact_tool_max_len: usize,
}
fn default_max_iterations() -> usize {
DEFAULT_MAX_ITERATIONS
}
fn default_compact_threshold() -> Option<usize> {
Some(DEFAULT_COMPACT_THRESHOLD)
}
fn default_compact_tool_max_len() -> usize {
DEFAULT_COMPACT_TOOL_MAX_LEN
}
impl Default for AgentConfig {
fn default() -> Self {
Self {
name: String::new(),
description: String::new(),
system_prompt: String::new(),
model: None,
max_iterations: DEFAULT_MAX_ITERATIONS,
tool_choice: ToolChoice::Auto,
thinking: false,
members: Vec::new(),
skills: Vec::new(),
mcps: Vec::new(),
tools: Vec::new(),
compact_threshold: default_compact_threshold(),
compact_tool_max_len: DEFAULT_COMPACT_TOOL_MAX_LEN,
}
}
}
impl AgentConfig {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
..Default::default()
}
}
pub fn system_prompt(mut self, prompt: impl Into<String>) -> Self {
self.system_prompt = prompt.into();
self
}
pub fn description(mut self, desc: impl Into<String>) -> Self {
self.description = desc.into();
self
}
pub fn model(mut self, name: impl Into<String>) -> Self {
self.model = Some(name.into());
self
}
pub fn thinking(mut self, enabled: bool) -> Self {
self.thinking = enabled;
self
}
}