Core primitives, traits, and abstractions for agent-oriented programming in Rust.
agentropic-core is the foundational crate of the Agentropic ecosystem, providing the building blocks for creating autonomous, intelligent agents. It defines agent identity, lifecycle management, core traits, and fundamental abstractions that all other Agentropic crates build upon.
This crate establishes:
- Agent Identity: Unique identification and addressing for agents
- Agent Traits: Core behavioral interfaces that all agents implement
- Lifecycle Management: Agent creation, initialization, execution, and termination
- Core Abstractions: Fundamental types and patterns for agent-oriented systems
Every agent has a unique identity that enables:
- Addressability in multi-agent systems
- Message routing and communication
- Access control and permissions
- Tracking and observability
use agentropic_core::{AgentId, AgentIdentity};
let agent_id = AgentId::new();
let identity = AgentIdentity::new(agent_id, "trading-agent");The Agent trait is the fundamental interface all agents must implement:
use agentropic_core::{Agent, AgentContext, AgentResult};
#[async_trait]
pub trait Agent: Send + Sync {
/// Unique identifier for this agent
fn id(&self) -> &AgentId;
/// Initialize the agent
async fn initialize(&mut self, ctx: &AgentContext) -> AgentResult<()>;
/// Execute the agent's main behavior
async fn execute(&mut self, ctx: &AgentContext) -> AgentResult<()>;
/// Gracefully shutdown the agent
async fn shutdown(&mut self, ctx: &AgentContext) -> AgentResult<()>;
}Agents follow a well-defined lifecycle:
- Creation → Agent instance is constructed
- Initialize → Resources allocated, connections established
- Execute → Main agent behavior runs
- Shutdown → Cleanup and graceful termination
The lifecycle is managed by the runtime (see agentropic-runtime).
AgentContext provides agents with access to:
- Configuration
- Logging and telemetry
- Shared resources
- Communication channels
AgentId- Unique agent identifier (UUID-based)AgentIdentity- Full identity with ID and human-readable nameAgentMetadata- Descriptive metadata about an agentAgentState- Lifecycle state tracking
Agent- Core agent behaviorAgentFactory- Agent construction and dependency injectionPerceivable- Agents that can perceive their environmentActionable- Agents that can take actions
AgentResult<T>- Standard result type for agent operationsAgentError- Comprehensive error types for agent failures
- Agent lifecycle state machines
- Identity generation and validation
- Context management helpers
Add to your Cargo.toml:
[dependencies]
agentropic-core = "0.1.0"use agentropic_core::{Agent, AgentId, AgentContext, AgentResult};
use async_trait::async_trait;
pub struct SimpleAgent {
id: AgentId,
counter: u64,
}
impl SimpleAgent {
pub fn new() -> Self {
Self {
id: AgentId::new(),
counter: 0,
}
}
}
#[async_trait]
impl Agent for SimpleAgent {
fn id(&self) -> &AgentId {
&self.id
}
async fn initialize(&mut self, ctx: &AgentContext) -> AgentResult<()> {
ctx.log_info("SimpleAgent initializing");
Ok(())
}
async fn execute(&mut self, ctx: &AgentContext) -> AgentResult<()> {
self.counter += 1;
ctx.log_info(&format!("Execution count: {}", self.counter));
Ok(())
}
async fn shutdown(&mut self, ctx: &AgentContext) -> AgentResult<()> {
ctx.log_info("SimpleAgent shutting down");
Ok(())
}
}agentropic-core is designed to be:
- Minimal: Only fundamental abstractions, no opinions on implementation
- Extensible: Traits allow for diverse agent types
- Safe: Leverages Rust's type system for correctness
- Async-first: Built for concurrent, non-blocking agent execution
- agentropic-messaging - Agent communication protocols
- agentropic-cognition - Reasoning and decision-making
- agentropic-runtime - Agent execution engine
- agentropic - Batteries-included facade
Full API documentation is available on docs.rs.
For guides and tutorials, see agentropic-docs.
Contributions are welcome! Please see the contributing guidelines.
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.
Active Development - This crate is under active development. APIs may change before 1.0 release.
Part of the Agentropic ecosystem for agent-oriented programming in Rust.