Skip to main content

Crate aither_agent

Crate aither_agent 

Source
Expand description

Aither Agent Framework

An ergonomic, minimal-core agent framework for building autonomous AI agents. The agent handles the tool-use loop internally with a simple API.

§Quick Start

ⓘ
use aither_agent::Agent;

// Simple one-shot query
let agent = Agent::new(llm);
let response = agent.query("What is 2+2?").await?;

// With tools and hooks
let agent = Agent::builder(llm)
    .tool(FileSystemTool::read_only("."))
    .hooks(ReadOnly)
    .build();

let response = agent.query("List all Rust files").await?;

§Features

  • Ergonomic API: Simple query() for one-shot tasks, run() to handle each event as it happens
  • Internal Loop: Tool execution handled automatically
  • Trait-based Hooks: Intercept operations at compile time
  • Context Management: One policy, a cache-aware window, async compaction
  • Generic over LLM: Works with any LanguageModel implementation

The crate carries no product policy: no default system prompt, no terminal tool and no built-in subagent types. The embedder supplies its own instructions, tools and policies.

Re-exports§

pub use context::AnyContextSource;
pub use context::AnyFileReferences;
pub use context::AnyLiveSource;
pub use context::AttachmentCatalogEntry;
pub use context::AttachmentRef;
pub use context::Block;
pub use context::CompactionError;
pub use context::CompletedCompaction;
pub use context::Context;
pub use context::ContextBlock;
pub use context::ContextBudget;
pub use context::ContextCheckpoint;
pub use context::ContextFile;
pub use context::ContextItem;
pub use context::ContextPolicy;
pub use context::ContextSource;
pub use context::ExternalContent;
pub use context::ExternalSlot;
pub use context::FileReferences;
pub use context::Handoff;
pub use context::HandoffDocument;
pub use context::HandoffPrompt;
pub use context::HandoffSchema;
pub use context::InstructionSlot;
pub use context::InvalidHandoff;
pub use context::KeptAttachment;
pub use context::LineRange;
pub use context::LiveChange;
pub use context::LiveContent;
pub use context::LiveSource;
pub use context::LiveUpdate;
pub use context::Moment;
pub use context::Placement;
pub use context::PrefixBlock;
pub use context::PrefixChain;
pub use context::PrefixRewrites;
pub use context::PromptCache;
pub use context::PromptPrefix;
pub use context::ReassemblyReport;
pub use context::Restoration;
pub use context::SkillCatalogEntry;
pub use context::SourceId;
pub use context::Sourced;
pub use context::SourcedSlot;
pub use context::SystemLayout;

Modules§

context
Context management: one window, one policy, one budget.

Structs§

Agent
An autonomous agent that runs a conversation with a language model, executing the tool calls it makes.
AgentBuilder
Builder for constructing agents with custom configuration.
AgentCheckpoint
Checkpoint payload exported by the agent runtime.
AgentConfig
Configuration for agent behavior.
AgentPath
Where an agent stands in the tree of agents a run started: empty for the main agent, the subagent’s name beneath its parent’s path otherwise.
AgentTools
Tools registry used by the agent.
AnyClock
A type-erased Clock, what the agent stores.
BlockId
Identifies one block of a response within its request.
BudgetedModel
A model with budget tracking.
CacheEntry
A cache entry for an uploaded file.
CacheStats
Aggregate prompt-caching statistics collected across one agent session.
CacheWarmth
A shared view of one agent’s prompt-cache entry.
CancelHandle
Cancels a Run from outside, such as from another task while the run is being driven. Cloneable and cheap.
Checkpoints
The newest checkpoint of a run in progress, readable while the run is being driven.
ChildEvents
Where a child’s events go: the parent’s stream.
CompactResult
Result of a compaction operation.
ContextWindowMetrics
Metrics describing the currently assembled context window.
ContextWindowSnapshot
Fully assembled LLM request window plus lifecycle metadata.
FileCache
File cache for tracking uploaded files across providers.
ForkSnapshot
The parent agent’s request, as a fork subagent starts from it.
ForkSource
The latest request of a parent agent, shared with whatever forks it.
Instant
A point on a Clock’s timeline.
ManualClock
A clock that only moves when told to.
ModelGroup
A group of models with the same tier, ordered by preference.
PauseId
Identifies one pause, unique within an agent.
RequestCx
What the loop knows as it assembles a request.
RequestId
Identifies one request sent to the model, unique within an agent. A request sent again after its response stream broke has a new id.
Run
One run of an Agent, from Agent::run or Agent::resume.
RunId
Identifies one run of an agent: from Agent::run or Agent::resume to its RunEnded.
StopCx
The model ended its turn with no tool call.
SubagentRun
One registered child.
SubagentRunInfo
Snapshot of one child in flight.
SubagentRuns
The registry of children in flight.
SystemClock
The operating system’s monotonic clock that keeps counting while the machine sleeps; the default.
TimedEvent
An AgentEvent with the UTC time it was emitted and the agent that emitted it.
ToolInvocation
A tool call the model made, before it runs.
ToolOutcome
A tool call after it ran.
ToolPanic
A tool’s future panicked while handling a call.
TurnBoundaryContext
A turn that called tools has ended.

Enums§

AfterTool
What Hooks::after_tool decides for a finished tool call.
AgentError
Errors that can occur during agent execution.
AgentEvent
Events emitted during agent execution.
Budget
Budget limit for a model.
CacheState
The state of a prompt-cache entry at one moment.
CheckpointReason
Why a checkpoint was emitted.
CompactionOutcome
How a compaction announced by AgentEvent::CompactionStarted ended.
CompactionTrigger
Why a compaction started.
ContextWindowPhase
Lifecycle phase of the assembled context window.
InjectionKind
What an injection into the conversation was.
ModelGroupError
Error type for model group operations.
OutputKind
What a streamed block of the model’s response is.
RequestOutcome
How a request ended.
RunOutcome
How a run ended.
RunPause
Why a run stopped short of an answer without failing.
StopDecision
What Hooks::on_stop decides when the model ends its turn.
ToolDecision
What Hooks::before_tool decides for a tool call.
ToolOrigin
Where a tool call runs.
ToolVerdict
What the agent settled on for a tool call before running it.
TurnBoundaryAction
What Hooks::on_turn_boundary decides at a turn’s end.

Traits§

ChildAgent
An agent that can run as a child of another.
Clock
A source of monotonic time.
Hooks
The embedder’s decisions at the loop’s control points.
Tool
Tools that can be called by language models.