Crate agents_sdk

Crate agents_sdk 

Source
Expand description

§Rust Deep Agents SDK

High-performance Rust framework for composing reusable “deep” AI agents with custom tools, sub-agents, and prompts.

§Quick Start

[dependencies]
agents-sdk = "0.0.1"  # Includes toolkit by default
use agents_sdk::{ConfigurableAgentBuilder, OpenAiConfig, OpenAiChatModel};
use agents_core::persistence::InMemoryCheckpointer;
use std::sync::Arc;

    let config = OpenAiConfig::new(
        std::env::var("OPENAI_API_KEY")?,
        "gpt-4o-mini"
    );

    // Create the model
    let model = Arc::new(OpenAiChatModel::new(config)?);

    // Build an agent
    let agent = ConfigurableAgentBuilder::new("You are a helpful assistant.")
        .with_model(model)
        .with_checkpointer(Arc::new(InMemoryCheckpointer::new()))
        .build()?;

    // Use the agent
    use agents_sdk::state::AgentStateSnapshot;
    use std::sync::Arc;

    let response = agent.handle_message(
        "Please greet Alice using the greet tool",
        Arc::new(AgentStateSnapshot::default())
    ).await?;
    println!("{:?}", response);

§Features

  • toolkit (default): Includes agents-toolkit with built-in tools
  • aws: Includes AWS integrations
  • redis: Redis-backed state persistence
  • postgres: PostgreSQL-backed state persistence
  • dynamodb: DynamoDB-backed state persistence (AWS)
  • persistence: Grouped feature for Redis + PostgreSQL
  • aws-full: Grouped feature for AWS + DynamoDB
  • full: Includes all features

§Installation Options

# Default installation with toolkit
agents-sdk = "0.0.1"

# Core only (minimal installation)
agents-sdk = { version = "0.0.1", default-features = false }

# With specific persistence backend
agents-sdk = { version = "0.0.1", features = ["redis"] }
agents-sdk = { version = "0.0.1", features = ["postgres"] }
agents-sdk = { version = "0.0.1", features = ["dynamodb"] }

# With AWS integrations
agents-sdk = { version = "0.0.1", features = ["aws-full"] }

# Everything included
agents-sdk = { version = "0.0.1", features = ["full"] }

§Persistence Examples

§Redis Checkpointer

use agents_sdk::{RedisCheckpointer, ConfigurableAgentBuilder};
use std::sync::Arc;

let checkpointer = Arc::new(
    RedisCheckpointer::new("redis://127.0.0.1:6379").await?
);

let agent = ConfigurableAgentBuilder::new("You are a helpful assistant")
    .with_checkpointer(checkpointer)
    .build()?;

§PostgreSQL Checkpointer

use agents_sdk::{PostgresCheckpointer, ConfigurableAgentBuilder};
use std::sync::Arc;

let checkpointer = Arc::new(
    PostgresCheckpointer::new("postgresql://user:pass@localhost/agents").await?
);

let agent = ConfigurableAgentBuilder::new("You are a helpful assistant")
    .with_checkpointer(checkpointer)
    .build()?;

§DynamoDB Checkpointer

use agents_sdk::{DynamoDbCheckpointer, ConfigurableAgentBuilder};
use std::sync::Arc;

let checkpointer = Arc::new(
    DynamoDbCheckpointer::new("agent-checkpoints").await?
);

let agent = ConfigurableAgentBuilder::new("You are a helpful assistant")
    .with_checkpointer(checkpointer)
    .build()?;

Modules§

agent
buildertoolkit
Tool builder utilities for creating tools from functions
builtintoolkit
Built-in tools for common agent operations
dynamodb_checkpointeraws
DynamoDB-backed checkpointer implementation for AWS deployments.
events
Event system for agent lifecycle tracking and progress broadcasting
hitl
Human-in-the-Loop (HITL) types for agent execution interrupts.
llm
messaging
persistence
Persistence traits for checkpointing agent state between runs.
prelude
Prelude module for common imports
security
Security utilities for PII protection and data sanitization
state
tools
Core tool system for AI agents

Structs§

AnthropicConfig
AnthropicMessagesModel
ConfigurableAgentBuilder
Builder API to assemble a DeepAgent in a single fluent flow, mirroring the Python create_configurable_agent experience. Prefer this for ergonomic construction.
DeepAgent
Core Deep Agent runtime implementation
DynamoDbCheckpointeraws
DynamoDB-backed checkpointer for serverless AWS deployments.
DynamoDbCheckpointerBuilderaws
Builder for configuring a DynamoDB checkpointer.
EditFileTooltoolkit
Edit file tool - performs string replacement in a file
GeminiChatModel
GeminiConfig
HitlPolicy
LsTooltoolkit
List files tool - shows all files in the agent’s filesystem
OpenAiChatModel
OpenAiConfig
PostgresCheckpointerpostgres
PostgreSQL-backed checkpointer with connection pooling.
ReadFileTooltoolkit
Read file tool - reads the contents of a file
ReadTodosTooltoolkit
Read todos tool - retrieves the current todo list
RedisCheckpointerredis
Redis-backed checkpointer with connection pooling and TTL support.
SubAgentConfig
Configuration for creating and registering a subagent using a simple, Python-like shape.
SummarizationConfig
Configuration for summarization middleware
TokenCosts
Token cost configuration for different providers
TokenTrackingConfig
Configuration for token tracking middleware
TokenTrackingMiddleware
Token tracking middleware that wraps an LLM to monitor usage
TokenUsage
TokenUsageSummary
Summary of token usage across all requests
ToolBuildertoolkit
Builder for creating tools from async functions
ToolContext
Context provided to tool implementations for accessing agent state and utilities
ToolParameterSchema
JSON Schema definition for tool parameters
ToolRegistry
Tool registry for managing and discovering available tools
ToolSchema
Complete schema definition for a tool
UnimplementedSecretsProvideraws
Stub Secrets Manager provider; real implementation will sit behind the secrets feature.
WriteFileTooltoolkit
Write file tool - creates or overwrites a file
WriteTodosTooltoolkit
Write todos tool - updates the agent’s todo list

Enums§

StreamChunk
A chunk of streaming response from the LLM
ToolResult
Result of a tool invocation

Traits§

AgentHandle
Abstraction for hosting a fully configured agent (planner + tools + prompts).
Checkpointeraws
Trait for persisting and retrieving agent state between conversation runs. This mirrors the LangGraph Checkpointer interface used in the Python implementation.
SecretsProvideraws
Placeholder trait for loading configuration secrets.
Tool
Core trait for tool implementations

Functions§

create_async_deep_agent
Async constructor alias to mirror the Python API surface.
create_deep_agent
Create a deep agent - matches Python create_deep_agent() API exactly
create_filesystem_toolstoolkit
Create all filesystem tools and return them as a vec
create_todos_tooltoolkit
Create the todos tool (write only)
create_todos_toolstoolkit
Create both read and write todos tools
get_default_model
Returns the default language model configured Uses OpenAI GPT-4o-mini for cost-effective operation. This model provides excellent performance at a fraction of the cost compared to larger models.
tooltoolkit
Quick helper to create a simple async tool
tool_synctoolkit
Quick helper to create a simple sync tool

Type Aliases§

AgentStream
Type alias for a stream of agent response chunks
ChunkStream
Type alias for a pinned boxed stream of chunks
ThreadIdaws
Unique identifier for a conversation thread/session.
ToolBox
Type alias for boxed tool instances

Attribute Macros§

tooltoolkit
Converts a Rust function into an AI agent tool with automatic schema generation.