Expand description
High-level umbrella crate for building LLM-driven agents with tools, memory, and tokenization.
This crate re-exports the main llmy-* crates behind a single top-level API so downstream
users can build an agent without having to depend on each sub-crate individually.
§Building An Agent
The smallest useful agent needs three pieces:
- A system prompt.
- A
agent::tool::ToolBoxcontaining zero or more tools. - A
harness::Agentto hold conversation state and orchestrate tool calls.
use llmy::agent::tool::ToolBox;
use llmy::agent::tools::files::ReadFileTool;
use llmy::harness::Agent;
let mut tools = ToolBox::new();
tools.add_tool(ReadFileTool::new(std::env::current_dir().unwrap()));
let agent = Agent::new(
"You are a helpful assistant.".to_string(),
tools,
"docs-example".to_string(),
);
let _ = agent;Once the agent exists, you typically:
- Create an
client::client::LLMfrom CLI-style configuration inclapor directly fromclientprimitives. - Push user input with
harness::Agent::step_with_user. - Continue stepping while the agent is still issuing tool calls.
§Memory-Enabled Agents
If you want the agent to search and update structured memory, construct an
agent::tools::memory::AgentMemoryContext and then build the agent with
harness::Agent::with_memory.
use llmy::agent::tool::ToolBox;
use llmy::agent::tools::memory::{
AgentMemory,
AgentMemoryContext,
embed::{SimilarityModel, SimilarityModelConfig},
};
use llmy::harness::{Agent, memory::AgentMemorySystemPromptCriteria};
async fn build_agent() -> Result<Agent, llmy::LLMYError> {
let memory = AgentMemoryContext::new(
AgentMemory::default(),
SimilarityModel::new(SimilarityModelConfig::default()).await?,
);
Ok(Agent::with_memory(
"You are a helpful assistant.".to_string(),
ToolBox::new(),
"docs-memory-example".to_string(),
&memory,
&AgentMemorySystemPromptCriteria::default(),
)
.await)
}§Module Guide
clapcontains CLI-oriented configuration helpers that can build an LLM client from flags and environment variables.clientcontains the lower-level LLM client, billing, settings, debug, and model modules.agentcontains the core tool traits and the aggregated tool modules used by agents.ebmedre-exports the embedding helpers used by memory search and similarity matching.harnesscontains the concrete in-memory agent implementation.tokenizercontains model metadata and token counting helpers.openaire-exportsasync-openaifor callers that need direct access to request and response types.
Modules§
- agent
- Core agent traits plus the bundled tool modules used by
llmyagents. - clap
- Command-line and environment-driven LLM configuration helpers.
- client
- Lower-level client, model, billing, debug, and settings modules used to talk to LLM backends.
- ebmed
- Embedding and similarity helpers used by memory search, token counting, and input truncation.
- harness
- Concrete in-memory agent harness with context management, compaction, and optional memory.
- openai
- Raw
async-openaire-export for callers that need direct protocol-level types. - tokenizer
- Tokenizer helpers and model metadata for approximate token counting and context sizing.
Enums§
- LLMY
Error - Common llmy error type shared across agent, tool, and client layers.