Skip to main content

Module agent

Module agent 

Source
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§

AgentCore
AgentCore - Core runtime infrastructure for LLM-powered agents.
AutoApprovePolicy
Auto-approve all permission requests.
ChannelEventSink
Event sink backed by an async channel.
ChannelInputSource
Input source backed by an async channel.
ConfigFile
Root configuration structure from YAML
ControllerInputPayload
Payload for input to the controller
DenyAllPolicy
Deny all permission requests.
EnvironmentContext
Environment context information.
InputRouter
Routes messages from the TUI to the controller.
InteractivePolicy
Interactive policy - always ask the user.
LLMController
The main LLM controller that manages sessions and coordinates communication
LLMRegistry
LLM Registry - stores loaded provider configurations
LLMSessionConfig
Configuration for creating an LLM session
Logger
Tracing-based logger that writes to daily log files.
PermissionRegistry
Registry for managing permission grants and requests.
ProviderConfig
Provider configuration from YAML
ProviderInfo
Information about a known OpenAI-compatible provider.
SendError
Error when sending an event fails.
SimpleConfig
A simple configuration for quick agent setup.
SimpleEventSink
Simple event sink that prints to stdout.
TurnId
Identifies a turn in the conversation (e.g., “u1”, “a1”, “u2”, “a2”)
UserInteractionRegistry
Registry for managing pending user interactions.

Enums§

AgentError
Error type for agent operations.
ConfigError
Configuration errors
ControllerEvent
Event emitted by the controller
PolicyDecision
Decision from a permission policy.
ToolResultStatus
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§

AgentConfig
Trait for agent-specific configuration.
EventSink
Receives events from the agent engine and delivers them to a consumer.
InputSource
Provides input from a consumer to the agent engine.
PermissionPolicy
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§

FromControllerRx
Receiver for messages from controller to frontend
FromControllerTx
Sender for messages from controller to frontend
ToControllerRx
Receiver for messages from frontend to controller
ToControllerTx
Sender for messages from frontend to controller