pub struct AgentConfig { /* private fields */ }Expand description
Configuration for an AI Agent.
Controls various aspects of agent behavior including retry logic, timeouts, and goal analysis capabilities.
§Examples
use ceylon_next::agent::AgentConfig;
// Create default configuration
let config = AgentConfig::default();
// Create custom configuration
let mut config = AgentConfig::new(5, 120);
config.with_goal_analysis(false);Implementations§
Source§impl AgentConfig
impl AgentConfig
Sourcepub fn new(max_retries: u64, timeout: u64) -> Self
pub fn new(max_retries: u64, timeout: u64) -> Self
Creates a new AgentConfig with specified retry and timeout settings.
§Arguments
max_retries- Maximum number of retries for failed operationstimeout- Timeout in seconds for agent operations
§Examples
use ceylon_next::agent::AgentConfig;
let config = AgentConfig::new(5, 120);Examples found in repository?
examples/01_basic_agent.rs (lines 20-23)
12async fn main() {
13 println!("🤖 Ceylon Agent - Basic Example\n");
14
15 // Step 1: Create a new agent with a name and model
16 // The model should be one supported by the LLM library (openai, anthropic, ollama, etc.)
17 let mut agent = Agent::new("Assistant", "ollama::gemma3:latest");
18
19 // Step 2: (Optional) Configure the agent with custom settings
20 let config = AgentConfig::new(
21 3, // max_retries
22 60, // timeout in seconds
23 );
24 agent.with_config(config);
25
26 // Step 3: (Optional) Customize the system prompt
27 agent.with_system_prompt(
28 "You are a helpful assistant that answers questions accurately and concisely. \
29 Always provide well-structured responses."
30 );
31
32 // Step 4: Create a task request
33 let mut task = TaskRequest::new("What is the capital of France?");
34 task.with_name("Geography Question")
35 .with_description("A simple geography question")
36 .with_priority(5);
37
38 // Step 5: Run the agent with the task
39 println!("📋 Task: {}\n", "What is the capital of France?");
40 let response = agent.run(task).await;
41
42 // Step 6: Handle the response
43 match response.result() {
44 OutputData::Text(answer) => {
45 println!("📝 Agent Response:\n{}\n", answer);
46 }
47 _ => {
48 println!("❌ Unexpected response type");
49 }
50 }
51
52 println!("✅ Example completed successfully!");
53}More examples
examples/04_advanced_agent.rs (lines 120-123)
113async fn main() {
114 println!("🤖 Ceylon Agent - Advanced Example\n");
115
116 // Step 1: Create an agent with custom configuration
117 let mut agent = Agent::new("AdvancedAssistant", "ollama::gemma3:latest");
118
119 // Configure with custom settings
120 let config = AgentConfig::new(
121 5, // Allow more retries for complex tasks
122 120, // Longer timeout
123 );
124 agent.with_config(config);
125
126 // Custom system prompt for the advanced agent
127 agent.with_system_prompt(
128 "You are an advanced AI assistant with access to specialized tools. \
129 You can fetch weather data and analyze text. \
130 Always explain your reasoning and use tools appropriately. \
131 Provide detailed and accurate responses.",
132 );
133
134 // Step 2: Register multiple tools
135 println!("🔧 Registering tools...");
136 agent.add_tool(WeatherTool);
137 agent.add_tool(TextAnalyzerTool);
138 println!("✓ Tools registered: get_weather, analyze_text\n");
139
140 // Step 3: Create and run multiple tasks with different priorities
141 let tasks_data = vec![
142 (
143 "What's the weather in Paris and London? Compare them.",
144 "Weather Comparison",
145 "Compare weather in two cities",
146 9, // High priority
147 ),
148 (
149 "Analyze this text for readability: 'The quick brown fox jumps over the lazy dog. \
150 This sentence demonstrates all letters of the English alphabet.'",
151 "Text Analysis",
152 "Analyze readability",
153 5, // Medium priority
154 ),
155 ];
156
157 for (prompt, name, description, priority) in tasks_data {
158 println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
159 println!("📋 Task: {}", name);
160 println!("⭐ Priority: {}/10", priority);
161 println!("📝 Description: {}", description);
162 println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
163
164 let mut task = TaskRequest::new(prompt);
165 task.with_name(name)
166 .with_description(description)
167 .with_priority(priority);
168
169 // Run the agent
170 println!("⏳ Running agent...\n");
171 let response = agent.run(task).await;
172
173 // Handle response
174 match response.result() {
175 OutputData::Text(answer) => {
176 println!("✅ Task completed\n");
177 }
178 _ => {
179 println!("⚠️ Unexpected response type\n");
180 }
181 }
182 }
183
184 // Step 4: Demonstrate memory capabilities
185 println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
186 println!("📚 Agent Status Summary:");
187 println!("• System Prompt: Custom advanced prompt");
188 println!("• Tools Available: 2 (weather, text analyzer)");
189 println!("• Memory Enabled: Yes");
190 println!("• Max Retries: 5");
191 println!("• Timeout: 120 seconds");
192 println!("• Tasks Completed: 2\n");
193
194 println!("✅ Advanced example completed successfully!");
195}Sourcepub fn with_goal_analysis(&mut self, enabled: bool) -> &mut Self
pub fn with_goal_analysis(&mut self, enabled: bool) -> &mut Self
Enables or disables automatic goal analysis for tasks.
When enabled, the agent will automatically analyze incoming tasks and break them down into structured goals with sub-goals and success criteria.
§Arguments
enabled- Whether to enable goal analysis
§Examples
use ceylon_next::agent::AgentConfig;
let mut config = AgentConfig::default();
config.with_goal_analysis(false);Trait Implementations§
Source§impl Clone for AgentConfig
impl Clone for AgentConfig
Source§fn clone(&self) -> AgentConfig
fn clone(&self) -> AgentConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AgentConfig
impl RefUnwindSafe for AgentConfig
impl Send for AgentConfig
impl Sync for AgentConfig
impl Unpin for AgentConfig
impl UnwindSafe for AgentConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more