mini_langchain/agent/types.rs
1use crate::llm::traits::LLM;
2use std::sync::Arc;
3use crate::tools::traits::Tool;
4use std::collections::HashMap;
5use super::error::AgentError;
6use crate::llm::tokens::TokenUsage;
7use serde::{Serialize, Deserialize};
8
9/// High-level agent that holds an LLM and a set of tools, plus simple agent state.
10pub struct Agent {
11 /// A short, human-friendly name for the agent instance.
12 pub name: String,
13
14 /// The LLM implementation used to generate responses/thoughts.
15 pub llm: Arc<dyn LLM>,
16
17 /// Registered tools the agent may call by name.
18 pub tools: HashMap<String, Arc<dyn Tool>>,
19
20 /// Optional system prompt / instructions provided to the LLM describing
21 /// the agent's role and available behaviors.
22 pub system_prompt: Option<String>,
23
24 /// Simple short-term memory / conversation context kept by the agent.
25 /// We store `Message` objects elsewhere in the crate; for a minimal
26 /// implementation we keep user-visible strings here.
27 pub memory: Vec<String>,
28
29 /// Maximum iterations when running a looped decision process.
30 pub max_iterations: usize,
31}
32
33#[derive(Debug, Serialize, Deserialize, Clone, Default)]
34pub struct AgentResult {
35 pub tokens: TokenUsage,
36 pub generation: String,
37}
38
39pub type AgentExecuteResult = Result<AgentResult, AgentError>;
40
41
42