1use std::time::Duration;
4
5use aither_core::llm::model::Parameters;
6
7use crate::compression::ContextStrategy;
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
11pub enum AgentKind {
12 #[default]
14 Coding,
15 Chatbot,
17}
18
19#[derive(Debug, Clone)]
21pub struct ContextAssemblerConfig {
22 pub static_budget_fraction: f32,
24 pub handoff_threshold: f32,
26 pub idle_reassemble_after: Duration,
28 pub handoff_instruction: String,
30}
31
32impl Default for ContextAssemblerConfig {
33 fn default() -> Self {
34 Self {
35 static_budget_fraction: 0.2,
36 handoff_threshold: 0.9,
37 idle_reassemble_after: Duration::from_secs(300),
38 handoff_instruction: "Your context window is nearly exhausted. Generate a concise handoff summary now, preserving current goals, constraints, file paths, pending tasks, and immediate next actions.".to_string(),
39 }
40 }
41}
42
43#[derive(Debug, Clone)]
45pub struct AgentConfig {
46 pub max_iterations: usize,
48
49 pub context: ContextStrategy,
51
52 pub system_prompt: Option<String>,
54
55 pub persona_prompt: Option<String>,
57
58 pub agent_kind: AgentKind,
60
61 pub transcript_path: Option<String>,
63
64 pub context_assembler: ContextAssemblerConfig,
66
67 pub request_parameters: Parameters,
69}
70
71impl Default for AgentConfig {
72 fn default() -> Self {
73 Self {
74 max_iterations: 10_000,
75 context: ContextStrategy::default(),
76 system_prompt: None,
77 persona_prompt: None,
78 agent_kind: AgentKind::default(),
79 transcript_path: None,
80 context_assembler: ContextAssemblerConfig::default(),
81 request_parameters: Parameters::default(),
82 }
83 }
84}
85
86impl AgentConfig {
87 #[must_use]
89 pub fn new() -> Self {
90 Self::default()
91 }
92
93 #[must_use]
95 pub const fn with_max_iterations(mut self, limit: usize) -> Self {
96 self.max_iterations = limit;
97 self
98 }
99
100 #[must_use]
102 pub const fn with_context(mut self, strategy: ContextStrategy) -> Self {
103 self.context = strategy;
104 self
105 }
106
107 #[must_use]
109 pub fn with_system_prompt(mut self, prompt: impl Into<String>) -> Self {
110 self.system_prompt = Some(prompt.into());
111 self
112 }
113
114 #[must_use]
116 pub fn with_persona_prompt(mut self, prompt: impl Into<String>) -> Self {
117 self.persona_prompt = Some(prompt.into());
118 self
119 }
120
121 #[must_use]
123 pub const fn with_agent_kind(mut self, kind: AgentKind) -> Self {
124 self.agent_kind = kind;
125 self
126 }
127
128 #[must_use]
130 pub fn with_transcript_path(mut self, path: impl Into<String>) -> Self {
131 self.transcript_path = Some(path.into());
132 self
133 }
134
135 #[must_use]
137 pub const fn with_idle_reassemble_after(mut self, idle_reassemble_after: Duration) -> Self {
138 self.context_assembler.idle_reassemble_after = idle_reassemble_after;
139 self
140 }
141
142 #[must_use]
144 pub fn with_request_parameters(mut self, parameters: Parameters) -> Self {
145 self.request_parameters = parameters;
146 self
147 }
148}