Skip to main content

Module agent

Module agent 

Source
Expand description

Agent - The core agent loop that orchestrates LLM interactions and tool execution

The Agent is the heart of the system. It manages:

  • Conversation history (via Session)
  • LLM interactions (via Provider)
  • Tool execution (via ToolRegistry)
  • Event publishing (via EventBus)

§Architecture

User Input
    │
    ▼
┌─────────┐
│  Agent  │◄──── Provider (LLM)
└─────────┘
    │  ▲
    │  │ Tool Results
    ▼  │
┌─────────┐
│  Tools  │
└─────────┘

§Example

ⓘ
use codive_core::{Agent, AgentConfig};
use codive_providers::AnthropicProvider;

let provider = AnthropicProvider::new("sk-...")?;
let agent = Agent::new(provider, AgentConfig::default());

// Run a single turn
let response = agent.run("Hello!").await?;
println!("{}", response);

Structs§

Agent
The Agent orchestrates conversations between users, LLMs, and tools
CancellationToken
A token which can be used to signal a cancellation request to one or more tasks.
TurnResult
Result of an agent turn

Enums§

AgentRunError
Errors that can occur during agent execution