Skip to main content

traitclaw_core/
config.rs

1//! Agent configuration.
2
3/// Configuration for an Agent instance.
4///
5/// This struct is `#[non_exhaustive]` — new fields may be added in future
6/// releases (e.g., `retry_policy`, `timeout_secs`) without breaking changes.
7#[derive(Debug, Clone)]
8#[non_exhaustive]
9pub struct AgentConfig {
10    /// System prompt for the agent.
11    pub system_prompt: Option<String>,
12
13    /// Maximum number of tokens for LLM responses.
14    pub max_tokens: Option<u32>,
15
16    /// Temperature for LLM sampling (0.0 - 2.0).
17    pub temperature: Option<f32>,
18
19    /// Maximum number of tool call iterations before stopping.
20    pub max_iterations: u32,
21
22    /// Maximum token budget for the entire agent run.
23    pub token_budget: Option<usize>,
24}
25
26impl Default for AgentConfig {
27    fn default() -> Self {
28        Self {
29            system_prompt: None,
30            max_tokens: Some(4096),
31            temperature: Some(0.7),
32            max_iterations: 20,
33            token_budget: None,
34        }
35    }
36}
37
38#[cfg(test)]
39mod tests {
40    use super::*;
41
42    #[test]
43    fn test_default_config() {
44        let config = AgentConfig::default();
45        assert!(config.system_prompt.is_none());
46        assert_eq!(config.max_iterations, 20);
47        assert_eq!(config.max_tokens, Some(4096));
48        assert!(config.token_budget.is_none());
49        assert!((config.temperature.unwrap() - 0.7).abs() < f32::EPSILON);
50    }
51}