Expand description
§TraitClaw
A Rust AI Agent Framework — Simple by default, powerful when needed.
This is the main entry point for the TraitClaw framework. It re-exports
everything from traitclaw-core and traitclaw-macros, so you only need
one dependency in your Cargo.toml:
[dependencies]
traitclaw = "1.0"§Feature Flags
| Feature | Crate | Default |
|---|---|---|
openai-compat | traitclaw-openai-compat | ✅ |
macros | traitclaw-macros | ✅ |
steering | traitclaw-steering | ❌ |
sqlite | traitclaw-memory-sqlite | ❌ |
mcp | traitclaw-mcp | ❌ |
rag | traitclaw-rag | ❌ |
team | traitclaw-team | ❌ |
eval | traitclaw-eval | ❌ |
strategies | traitclaw-strategies | ❌ |
full | all of the above | ❌ |
Re-exports§
pub use traitclaw_openai_compat as openai_compat;pub use traitclaw_steering as steering;pub use traitclaw_memory_sqlite as memory_sqlite;pub use traitclaw_mcp as mcp;pub use traitclaw_rag as rag;pub use traitclaw_team as team;pub use traitclaw_eval as eval;pub use traitclaw_strategies as strategies;
Modules§
- agent
- Agent — the main entry point for running AI agents.
- agent_
builder - Agent builder for fluent configuration.
- config
- Agent configuration.
- context_
managers - Built-in
ContextManagerimplementations for common compression strategies. - default_
strategy - Default strategy — preserves v0.1.0 agent loop behavior.
- error
- Error types for
TraitClawCore. - factory
- Agent factory for shared-provider multi-agent creation.
- memory
- Memory implementations.
- pool
- Agent pool for managing and executing groups of agents.
- prelude
- Prelude module for convenient imports.
- registries
- Built-in
ToolRegistryimplementations. - retry
- Retry wrapper for LLM providers with exponential backoff.
- token_
counter - Accurate tiktoken-based token counting.
- token_
counting - Token counting utilities for context management.
- traits
- Core trait definitions for
TraitClaw. - transformers
- Built-in
OutputTransformerimplementations for common use cases. - types
- Shared types for
TraitClaw.
Structs§
- Adaptive
Registry - A tool registry that automatically limits the number of visible tools based on the configured model tier.
- Adaptive
Strategy - Adaptive strategy that queries
Tracker::recommended_concurrency()to decide whether to run sequentially or in parallel. - Agent
- The main agent struct.
- Agent
Builder - Builder for constructing an
Agentwith a fluent API. - Agent
Factory - A factory for creating multiple agents from a shared provider.
- Agent
Output - Output from an agent run.
- Agent
Pool - A collection of agents for group execution.
- Agent
Runtime - Runtime context provided to strategies.
- Agent
Session - A session-scoped agent wrapper.
- Agent
State - Snapshot of the agent’s runtime state.
- Budget
Aware Truncator - Truncates output to a maximum character count, respecting context utilization.
- Char
Approx Counter - Approximate token counter using the 4-characters ≈ 1-token heuristic.
- Completion
Request - A completion request to send to an LLM provider.
- Completion
Response - A completion response from the LLM provider.
- Compressed
Memory - A memory decorator that compresses older messages into summaries.
- Default
Strategy - The default agent strategy preserving v0.1.0 behavior.
- Dynamic
Registry - A mutable tool registry supporting runtime add/remove/toggle.
- Full
Output Retriever - Virtual tool that retrieves the full output cached by
ProgressiveTransformer. - Grouped
Registry - A tool registry that organizes tools into named groups with group-level activation and deactivation.
- Hint
Message - A hint message to be injected into the conversation.
- InMemory
Memory - In-memory implementation of the
Memorytrait. - Json
Extractor - Extracts JSON from tool output, discarding surrounding text.
- LlmCompressor
- Summarizes old messages using an LLM provider.
- Logging
Hook - A hook that logs all lifecycle events using
tracing. - Message
- A single message in a conversation.
- Model
Info - Information about the LLM model being used by a provider.
- Parallel
Strategy - Execute tool calls concurrently with bounded concurrency.
- Pending
Tool Call - A pending tool call to be executed by a strategy.
- Progressive
Transformer - A two-phase output transformer that returns an LLM-generated summary first,
with the full output cached and available on demand via the
__get_full_outputvirtual tool. - Retry
Config - Configuration for retry behavior.
- Retry
Provider - A provider decorator that retries transient errors with exponential backoff.
- Rule
Based Compressor - Scores messages by importance and removes lowest-scored first.
- RunUsage
- Usage statistics from an agent run.
- Sequential
Strategy - Execute tool calls one at a time in order.
- Simple
Registry - A simple, immutable tool registry that wraps
Vec<Arc<dyn ErasedTool>>. - Tier
Limits - Per-tier tool limits.
- Tiered
Compressor - Chains compression tiers: keep recent → rule-compress mid → LLM-summarize old.
- TikToken
Counter - Exact token counter using OpenAI-compatible BPE tokenization via tiktoken-rs.
- Tool
Call - A tool call requested by the LLM.
- Tool
Result - The result of executing a single tool call.
- Tool
Schema - JSON Schema representation for a tool’s parameters.
- Transformer
Chain - Pipes output through multiple transformers in order.
- Usage
- Token usage statistics for a completion.
Enums§
- Action
- An action that the agent wants to perform.
- Agent
Output Content - The content type of an agent output.
- Error
- Errors that can occur during agent operation.
- Guard
Result - Result of a guard check.
- Hint
Priority - Priority level for hint injection.
- Hook
Action - The result of a hook’s interception decision.
- Injection
Point - Where in the conversation to inject the hint message.
- Message
Role - Role of a message in a conversation.
- Model
Tier - Model capability tier used by the steering system to auto-configure Guard, Hint, and Tracker behavior.
- Stream
Event - Events emitted during streaming.
Traits§
- Agent
Hook - Async lifecycle hooks for agent observability and interception.
- Agent
Strategy - Pluggable agent execution strategy.
- Context
Manager - Async trait for pluggable context window management.
- Erased
Tool - Type-erased tool wrapper for dynamic dispatch.
- Execution
Strategy - Trait for pluggable tool execution strategies.
- Guard
- Hard boundary check for agent actions.
- Hint
- Contextual guidance injection for model steering.
- Memory
- Trait for the 3-layer memory system.
- Output
Transformer - Async trait for context-aware tool output transformation.
- Provider
- Trait for LLM providers.
- Token
Counter - Trait for pluggable token counting backends.
- Tool
- Trait for defining agent tools with typed inputs and outputs.
- Tool
Registry - Trait for pluggable tool management.
- Tracker
- Runtime state monitor for the steering system.
Type Aliases§
- Completion
Stream - A stream of completion events.
- Result
- Convenience type alias for
Result<T, Error>.
Derive Macros§
- Tool
- Derive the
ErasedToolimplementation boilerplate for a struct.