Skip to main content

Crate traitclaw

Crate traitclaw 

Source
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

FeatureCrateDefault
openai-compattraitclaw-openai-compat
macrostraitclaw-macros
steeringtraitclaw-steering
sqlitetraitclaw-memory-sqlite
mcptraitclaw-mcp
ragtraitclaw-rag
teamtraitclaw-team
evaltraitclaw-eval
strategiestraitclaw-strategies
fullall 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 ContextManager implementations for common compression strategies.
default_strategy
Default strategy — preserves v0.1.0 agent loop behavior.
error
Error types for TraitClaw Core.
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 ToolRegistry implementations.
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 OutputTransformer implementations for common use cases.
types
Shared types for TraitClaw.

Structs§

AdaptiveRegistry
A tool registry that automatically limits the number of visible tools based on the configured model tier.
AdaptiveStrategy
Adaptive strategy that queries Tracker::recommended_concurrency() to decide whether to run sequentially or in parallel.
Agent
The main agent struct.
AgentBuilder
Builder for constructing an Agent with a fluent API.
AgentFactory
A factory for creating multiple agents from a shared provider.
AgentOutput
Output from an agent run.
AgentPool
A collection of agents for group execution.
AgentRuntime
Runtime context provided to strategies.
AgentSession
A session-scoped agent wrapper.
AgentState
Snapshot of the agent’s runtime state.
BudgetAwareTruncator
Truncates output to a maximum character count, respecting context utilization.
CharApproxCounter
Approximate token counter using the 4-characters ≈ 1-token heuristic.
CompletionRequest
A completion request to send to an LLM provider.
CompletionResponse
A completion response from the LLM provider.
CompressedMemory
A memory decorator that compresses older messages into summaries.
DefaultStrategy
The default agent strategy preserving v0.1.0 behavior.
DynamicRegistry
A mutable tool registry supporting runtime add/remove/toggle.
FullOutputRetriever
Virtual tool that retrieves the full output cached by ProgressiveTransformer.
GroupedRegistry
A tool registry that organizes tools into named groups with group-level activation and deactivation.
HintMessage
A hint message to be injected into the conversation.
InMemoryMemory
In-memory implementation of the Memory trait.
JsonExtractor
Extracts JSON from tool output, discarding surrounding text.
LlmCompressor
Summarizes old messages using an LLM provider.
LoggingHook
A hook that logs all lifecycle events using tracing.
Message
A single message in a conversation.
ModelInfo
Information about the LLM model being used by a provider.
ParallelStrategy
Execute tool calls concurrently with bounded concurrency.
PendingToolCall
A pending tool call to be executed by a strategy.
ProgressiveTransformer
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_output virtual tool.
RetryConfig
Configuration for retry behavior.
RetryProvider
A provider decorator that retries transient errors with exponential backoff.
RuleBasedCompressor
Scores messages by importance and removes lowest-scored first.
RunUsage
Usage statistics from an agent run.
SequentialStrategy
Execute tool calls one at a time in order.
SimpleRegistry
A simple, immutable tool registry that wraps Vec<Arc<dyn ErasedTool>>.
TierLimits
Per-tier tool limits.
TieredCompressor
Chains compression tiers: keep recent → rule-compress mid → LLM-summarize old.
TikTokenCounter
Exact token counter using OpenAI-compatible BPE tokenization via tiktoken-rs.
ToolCall
A tool call requested by the LLM.
ToolResult
The result of executing a single tool call.
ToolSchema
JSON Schema representation for a tool’s parameters.
TransformerChain
Pipes output through multiple transformers in order.
Usage
Token usage statistics for a completion.

Enums§

Action
An action that the agent wants to perform.
AgentOutputContent
The content type of an agent output.
Error
Errors that can occur during agent operation.
GuardResult
Result of a guard check.
HintPriority
Priority level for hint injection.
HookAction
The result of a hook’s interception decision.
InjectionPoint
Where in the conversation to inject the hint message.
MessageRole
Role of a message in a conversation.
ModelTier
Model capability tier used by the steering system to auto-configure Guard, Hint, and Tracker behavior.
StreamEvent
Events emitted during streaming.

Traits§

AgentHook
Async lifecycle hooks for agent observability and interception.
AgentStrategy
Pluggable agent execution strategy.
ContextManager
Async trait for pluggable context window management.
ErasedTool
Type-erased tool wrapper for dynamic dispatch.
ExecutionStrategy
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.
OutputTransformer
Async trait for context-aware tool output transformation.
Provider
Trait for LLM providers.
TokenCounter
Trait for pluggable token counting backends.
Tool
Trait for defining agent tools with typed inputs and outputs.
ToolRegistry
Trait for pluggable tool management.
Tracker
Runtime state monitor for the steering system.

Type Aliases§

CompletionStream
A stream of completion events.
Result
Convenience type alias for Result<T, Error>.

Derive Macros§

Tool
Derive the ErasedTool implementation boilerplate for a struct.