AgentConfig

Struct AgentConfig 

Source
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

Source

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 operations
  • timeout - 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
Hide additional 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}
Source

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

Source§

fn clone(&self) -> AgentConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for AgentConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,