Skip to content

Steering

Steering is TraitClaw’s safety and guidance system. It consists of three complementary traits that work together to keep agents safe, guided, and observable.

ComponentPurposeWhen it runs
GuardPrevent dangerous actionsBefore tool execution
HintInject guidance into contextBefore LLM generation
TrackerCollect metrics and adaptAfter each step
use traitclaw_steering::Steering;
let agent = Agent::builder()
.provider(provider)
.steering(Steering::auto()) // All guards + hints + tracking
.build()?;
GuardProtection
ShellDenyGuardBlocks shell command execution
LoopDetectionGuardDetects infinite reasoning loops
RateLimitGuardLimits requests per time window
ToolBudgetGuardLimits total tool calls per session
ContentFilterGuardFilters harmful content patterns
PromptInjectionGuardDetects prompt injection attempts
WorkspaceBoundaryGuardRestricts file access to workspace
HintGuidance
BudgetHintInjects remaining token budget awareness
SystemPromptReminderRe-injects system prompt periodically
TruncationHintWarns when context is being truncated
TeamProgressHintReports multi-agent team progress
use traitclaw_core::Guard;
struct MaxCostGuard {
max_dollars: f64,
spent: AtomicF64,
}
#[async_trait]
impl Guard for MaxCostGuard {
async fn check(&self, action: &AgentAction) -> GuardResult {
if self.spent.load() > self.max_dollars {
GuardResult::Deny("Cost budget exceeded".into())
} else {
GuardResult::Allow
}
}
}