@@ -31,7 +31,7 @@ impl Default for RateLimitConfig {
3131 Self {
3232 enabled : true ,
3333 reasoning_rps : 5.0 , // 5 requests per second
34- action_rps : 10.0 , // 10 requests per second
34+ action_rps : 10.0 , // 10 requests per second
3535 reflection_rps : 3.0 , // 3 requests per second
3636 }
3737 }
@@ -82,6 +82,8 @@ pub struct AgentEngineConfig {
8282 pub action_engine : String ,
8383 pub reflection_engine : String ,
8484 pub memory_database : String ,
85+ #[ serde( default = "default_memory_enabled" ) ]
86+ pub memory_enabled : bool ,
8587 pub tools : ToolConfig ,
8688 pub config_path : Option < String > ,
8789 pub max_iterations : Option < u32 > ,
@@ -109,12 +111,16 @@ fn default_web_browsing() -> bool {
109111 true
110112}
111113
114+ fn default_memory_enabled ( ) -> bool {
115+ true
116+ }
117+
112118/// Runtime configuration with loaded engines and credentials
113119#[ derive( Clone ) ]
114120pub struct AgentRuntimeConfig {
115- pub reasoning_engine : Arc < Box < dyn Engine > > ,
116- pub action_engine : Arc < Box < dyn Engine > > ,
117- pub reflection_engine : Arc < Box < dyn Engine > > ,
121+ pub reasoning_engine : Arc < dyn Engine > ,
122+ pub action_engine : Arc < dyn Engine > ,
123+ pub reflection_engine : Arc < dyn Engine > ,
118124 pub config : AgentEngineConfig ,
119125 pub credentials : HashMap < String , String > ,
120126 pub supervisor : Option < AutonomySupervisorConfig > ,
@@ -129,11 +135,7 @@ pub struct AgentRuntimeConfig {
129135impl AgentRuntimeConfig {
130136 /// Get the base engine for enhanced reasoning
131137 pub fn get_base_engine ( & self ) -> Option < Arc < dyn Engine > > {
132- // Return a clone of the reasoning engine for use as base engine
133- // We need to convert from Arc<Box<dyn Engine>> to Arc<dyn Engine>
134- // This is a workaround - we can't directly cast, so we'll return None for now
135- // In a real implementation, we'd need to restructure to avoid this type mismatch
136- None
138+ Some ( self . reasoning_engine . clone ( ) )
137139 }
138140
139141 /// Acquire a rate limit token for reasoning operations
@@ -276,52 +278,42 @@ impl AgentEngineConfig {
276278 } ;
277279
278280 // Create reflection engine (can be the same as reasoning)
279- let reflection_engine = if self . reflection_engine == self . reasoning_engine {
280- // Create a new instance of the same engine
281- self . create_engine (
282- & fluent_config_content,
283- & self . reflection_engine ,
284- & credentials,
285- model_override,
286- )
287- . await ?
288- } else if self . reflection_engine == self . action_engine {
289- // Create a new instance of the same engine
290- self . create_engine (
291- & fluent_config_content,
292- & self . reflection_engine ,
293- & credentials,
294- model_override,
295- )
296- . await ?
297- } else {
298- self . create_engine (
281+ let reflection_engine = self
282+ . create_engine (
299283 & fluent_config_content,
300284 & self . reflection_engine ,
301285 & credentials,
302286 model_override,
303287 )
304- . await ?
305- } ;
288+ . await ?;
306289
307290 // Initialize rate limiters based on config
308- let rate_limit_config = self . rate_limit . clone ( ) . unwrap_or_else ( RateLimitConfig :: from_environment) ;
291+ let rate_limit_config = self
292+ . rate_limit
293+ . clone ( )
294+ . unwrap_or_else ( RateLimitConfig :: from_environment) ;
309295
310296 let ( reasoning_rate_limiter, action_rate_limiter, reflection_rate_limiter) =
311297 if rate_limit_config. enabled {
312298 (
313- Some ( Arc :: new ( fluent_engines:: RateLimiter :: new ( rate_limit_config. reasoning_rps ) ) ) ,
314- Some ( Arc :: new ( fluent_engines:: RateLimiter :: new ( rate_limit_config. action_rps ) ) ) ,
315- Some ( Arc :: new ( fluent_engines:: RateLimiter :: new ( rate_limit_config. reflection_rps ) ) ) ,
299+ Some ( Arc :: new ( fluent_engines:: RateLimiter :: new (
300+ rate_limit_config. reasoning_rps ,
301+ ) ) ) ,
302+ Some ( Arc :: new ( fluent_engines:: RateLimiter :: new (
303+ rate_limit_config. action_rps ,
304+ ) ) ) ,
305+ Some ( Arc :: new ( fluent_engines:: RateLimiter :: new (
306+ rate_limit_config. reflection_rps ,
307+ ) ) ) ,
316308 )
317309 } else {
318310 ( None , None , None )
319311 } ;
320312
321313 Ok ( AgentRuntimeConfig {
322- reasoning_engine : Arc :: new ( reasoning_engine) ,
323- action_engine : Arc :: new ( action_engine) ,
324- reflection_engine : Arc :: new ( reflection_engine) ,
314+ reasoning_engine : Arc :: from ( reasoning_engine) ,
315+ action_engine : Arc :: from ( action_engine) ,
316+ reflection_engine : Arc :: from ( reflection_engine) ,
325317 config : self . clone ( ) ,
326318 credentials,
327319 supervisor : self . supervisor . clone ( ) ,
@@ -334,6 +326,31 @@ impl AgentEngineConfig {
334326 } )
335327 }
336328
329+ /// Resolve the configured SQLite memory database to a filesystem path.
330+ ///
331+ /// Supported forms:
332+ /// - `sqlite://global` (default)
333+ /// - `sqlite://:memory:`
334+ /// - `sqlite:///absolute/path/to/db`
335+ /// - `sqlite://./relative/path/to/db`
336+ pub fn resolve_memory_db_path ( & self ) -> std:: path:: PathBuf {
337+ let url = self . memory_database . trim ( ) ;
338+ let Some ( rest) = url. strip_prefix ( "sqlite://" ) else {
339+ return crate :: paths:: global_agent_memory_db_path ( ) ;
340+ } ;
341+
342+ if rest. is_empty ( ) || rest == "global" {
343+ return crate :: paths:: global_agent_memory_db_path ( ) ;
344+ }
345+ if rest == ":memory:" {
346+ return std:: path:: PathBuf :: from ( ":memory:" ) ;
347+ }
348+
349+ // `sqlite:///abs/path` yields rest like "/abs/path" (keep it absolute)
350+ // `sqlite://./rel/path` yields rest like "./rel/path"
351+ std:: path:: PathBuf :: from ( rest)
352+ }
353+
337354 pub fn supervisor_config ( & self ) -> AutonomySupervisorConfig {
338355 self . supervisor . clone ( ) . unwrap_or_default ( )
339356 }
@@ -531,7 +548,8 @@ impl AgentEngineConfig {
531548 reasoning_engine : "sonnet3.5" . to_string ( ) ,
532549 action_engine : "gpt-4o" . to_string ( ) ,
533550 reflection_engine : "gemini-flash" . to_string ( ) ,
534- memory_database : "sqlite://./agent_memory.db" . to_string ( ) ,
551+ memory_database : "sqlite://global" . to_string ( ) ,
552+ memory_enabled : true ,
535553 tools : ToolConfig {
536554 file_operations : true ,
537555 shell_commands : false , // Disabled by default for security
@@ -627,8 +645,7 @@ pub mod credentials {
627645
628646 // Load CREDENTIAL_ prefixed variables (fluent_cli pattern)
629647 for ( key, value) in env:: vars ( ) {
630- if key. starts_with ( "CREDENTIAL_" ) {
631- let credential_key = & key[ 11 ..] ; // Remove CREDENTIAL_ prefix
648+ if let Some ( credential_key) = key. strip_prefix ( "CREDENTIAL_" ) {
632649 credentials. insert ( credential_key. to_string ( ) , value) ;
633650 }
634651 }
0 commit comments