Skip to main content

agent_io/agent/
config.rs

1//! Agent configuration types
2
3use derive_builder::Builder;
4
5use crate::llm::ToolChoice;
6
7/// Default maximum iterations
8pub const DEFAULT_MAX_ITERATIONS: usize = 200;
9
10/// Agent configuration
11#[derive(Builder, Clone)]
12#[builder(pattern = "owned")]
13pub struct AgentConfig {
14    /// System prompt
15    #[builder(setter(into, strip_option), default = "None")]
16    pub system_prompt: Option<String>,
17
18    /// Maximum iterations before stopping
19    #[builder(default = "DEFAULT_MAX_ITERATIONS")]
20    pub max_iterations: usize,
21
22    /// Tool choice strategy
23    #[builder(default = "ToolChoice::Auto")]
24    pub tool_choice: ToolChoice,
25
26    /// Enable context compaction
27    #[builder(default = "false")]
28    pub enable_compaction: bool,
29
30    /// Compaction threshold (ratio of context window)
31    #[builder(default = "0.80")]
32    pub compaction_threshold: f32,
33
34    /// Enable cost tracking
35    #[builder(default = "false")]
36    pub include_cost: bool,
37}
38
39impl Default for AgentConfig {
40    fn default() -> Self {
41        Self {
42            system_prompt: None,
43            max_iterations: DEFAULT_MAX_ITERATIONS,
44            tool_choice: ToolChoice::Auto,
45            enable_compaction: false,
46            compaction_threshold: 0.80,
47            include_cost: false,
48        }
49    }
50}
51
52/// Ephemeral message configuration per tool
53#[derive(Debug, Clone, Copy)]
54pub struct EphemeralConfig {
55    /// How many outputs to keep (None = not ephemeral)
56    pub keep_count: usize,
57}
58
59impl Default for EphemeralConfig {
60    fn default() -> Self {
61        Self { keep_count: 1 }
62    }
63}