Expand description
Agent infrastructure and configuration. Agent Infrastructure
Core infrastructure for building LLM-powered agents.
This module provides:
- AgentCore - Complete working agent infrastructure
- Message types for Frontend-Controller communication
- Input routing between Frontend and controller
- Logging infrastructure
- Configuration management with trait-based customization
§Quick Start (Headless)
ⓘ
use agent_core_runtime::agent::{AgentConfig, AgentCore};
struct MyConfig;
impl AgentConfig for MyConfig {
fn config_path(&self) -> &str { ".myagent/config.yaml" }
fn default_system_prompt(&self) -> &str { "You are helpful." }
fn log_prefix(&self) -> &str { "myagent" }
fn name(&self) -> &str { "MyAgent" }
}
fn main() -> std::io::Result<()> {
let mut core = AgentCore::new(&MyConfig)?;
core.start_background_tasks();
// Get channels for custom frontend integration
let tx = core.to_controller_tx();
let rx = core.take_from_controller_rx();
// Create a session and interact programmatically
let (session_id, model, _) = core.create_initial_session()?;
// ... implement your own event loop
core.shutdown();
Ok(())
}Modules§
- interface
- Engine Interface Abstractions
Structs§
- Agent
Core - AgentCore - Core runtime infrastructure for LLM-powered agents.
- Auto
Approve Policy - Auto-approve all permission requests.
- Channel
Event Sink - Event sink backed by an async channel.
- Channel
Input Source - Input source backed by an async channel.
- Config
File - Root configuration structure from YAML
- Controller
Input Payload - Payload for input to the controller
- Deny
AllPolicy - Deny all permission requests.
- Environment
Context - Environment context information.
- Input
Router - Routes messages from the TUI to the controller.
- Interactive
Policy - Interactive policy - always ask the user.
- LLMController
- The main LLM controller that manages sessions and coordinates communication
- LLMRegistry
- LLM Registry - stores loaded provider configurations
- LLMSession
Config - Configuration for creating an LLM session
- Logger
- Tracing-based logger that writes to daily log files.
- Permission
Registry - Registry for managing permission grants and requests.
- Provider
Config - Provider configuration from YAML
- Provider
Info - Information about a known OpenAI-compatible provider.
- Send
Error - Error when sending an event fails.
- Simple
Config - A simple configuration for quick agent setup.
- Simple
Event Sink - Simple event sink that prints to stdout.
- TurnId
- Identifies a turn in the conversation (e.g., “u1”, “a1”, “u2”, “a2”)
- User
Interaction Registry - Registry for managing pending user interactions.
Enums§
- Agent
Error - Error type for agent operations.
- Config
Error - Configuration errors
- Controller
Event - Event emitted by the controller
- Policy
Decision - Decision from a permission policy.
- Tool
Result Status - Result status from tool execution.
- UiMessage
- Messages sent from the controller to the TUI for display
Constants§
- DEFAULT_
CHANNEL_ SIZE - Default channel buffer size for internal communication. This applies to all async channels: LLM responses, tool results, UI events, etc. Can be overridden via AgentConfig::channel_buffer_size().
Traits§
- Agent
Config - Trait for agent-specific configuration.
- Event
Sink - Receives events from the agent engine and delivers them to a consumer.
- Input
Source - Provides input from a consumer to the agent engine.
- Permission
Policy - Policy for handling permission requests.
Functions§
- convert_
controller_ event_ to_ ui_ message - Converts a ControllerEvent to a UiMessage for the frontend.
- create_
channels - Creates a pair of channels for TUI-Controller communication
- get_
provider_ info - Returns provider info for a known provider name.
- is_
known_ provider - Returns true if this is a known OpenAI-compatible provider.
- list_
providers - Returns a list of all known provider names.
- load_
config - Load config for an agent using its AgentConfig trait implementation.
Type Aliases§
- From
Controller Rx - Receiver for messages from controller to frontend
- From
Controller Tx - Sender for messages from controller to frontend
- ToController
Rx - Receiver for messages from frontend to controller
- ToController
Tx - Sender for messages from frontend to controller