Skip to content

Conversation

harish0101-ops
Copy link
Contributor

@harish0101-ops harish0101-ops commented Sep 5, 2025

lazy initialization tools_impl in SwarmsAgentBuilder

pub struct SwarmsAgentBuilder<M>
where
    M: llm::Model + Send + Sync,
    M::RawCompletionResponse: Send + Sync,
{
    /// The LLM model instance used for generating responses
    model: M,
    /// Agent configuration including execution parameters
    config: AgentConfig,
    /// Optional system prompt to guide agent behavior
    system_prompt: Option<String>,
    /// List of tool definitions available to the agent
    tools: Vec<ToolDefinition>,
    /// Implementation instances of tools, keyed by tool name
    tools_impl: OnceLock<DashMap<String, Arc<dyn ToolDyn>>>,
}

plus short_memory and tools_impl in SwarmsAgent

#[derive(Clone, Serialize)]
pub struct SwarmsAgent<M>
where
    M: llm::Model + Clone + Send + Sync,
    M::RawCompletionResponse: Clone + Send + Sync,
{
    /// The LLM model used for generating responses
    model: M,
    /// Agent configuration including execution parameters
    config: AgentConfig,
    /// Optional system prompt that guides agent behavior
    system_prompt: Option<String>,
    /// Short-term memory for maintaining conversation history
    #[serde(skip)]
    short_memory: OnceLock<AgentShortMemory>,
    /// List of available tool definitions
    tools: Vec<ToolDefinition>,
    /// Tool implementation instances (not serialized)
    #[serde(skip)]
    tools_impl: OnceLock<DashMap<String, Arc<dyn ToolDyn>>>,
}

other files changes because of cargo fmt changes

Fixes #50

@kyegomez
Copy link
Contributor

kyegomez commented Sep 6, 2025

@harish0101-ops hey there are some merge conflicts we need to fix here!

@harish0101-ops
Copy link
Contributor Author

@harish0101-ops hey there are some merge conflicts we need to fix here!

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[IMPROVEMENT] Implement lazy initialization for agent components
2 participants