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 tasks_stale_after_turns: usize,
74
75 pub request_parameters: Parameters,
77}
78
79impl Default for AgentConfig {
80 fn default() -> Self {
81 Self {
82 max_iterations: 10_000,
83 context: ContextStrategy::default(),
84 system_prompt: None,
85 persona_prompt: None,
86 agent_kind: AgentKind::default(),
87 transcript_path: None,
88 context_assembler: ContextAssemblerConfig::default(),
89 tasks_stale_after_turns: 4,
90 request_parameters: Parameters::default(),
91 }
92 }
93}
94
95impl AgentConfig {
96 #[must_use]
98 pub fn new() -> Self {
99 Self::default()
100 }
101
102 #[must_use]
104 pub const fn with_max_iterations(mut self, limit: usize) -> Self {
105 self.max_iterations = limit;
106 self
107 }
108
109 #[must_use]
111 pub const fn with_context(mut self, strategy: ContextStrategy) -> Self {
112 self.context = strategy;
113 self
114 }
115
116 #[must_use]
118 pub fn with_system_prompt(mut self, prompt: impl Into<String>) -> Self {
119 self.system_prompt = Some(prompt.into());
120 self
121 }
122
123 #[must_use]
125 pub fn with_persona_prompt(mut self, prompt: impl Into<String>) -> Self {
126 self.persona_prompt = Some(prompt.into());
127 self
128 }
129
130 #[must_use]
132 pub const fn with_agent_kind(mut self, kind: AgentKind) -> Self {
133 self.agent_kind = kind;
134 self
135 }
136
137 #[must_use]
139 pub fn with_transcript_path(mut self, path: impl Into<String>) -> Self {
140 self.transcript_path = Some(path.into());
141 self
142 }
143
144 #[must_use]
146 pub const fn with_idle_reassemble_after(mut self, idle_reassemble_after: Duration) -> Self {
147 self.context_assembler.idle_reassemble_after = idle_reassemble_after;
148 self
149 }
150
151 #[must_use]
153 pub fn with_request_parameters(mut self, parameters: Parameters) -> Self {
154 self.request_parameters = parameters;
155 self
156 }
157}