Skip to main content

Crate swink_agent_policies

Crate swink_agent_policies 

Source
Expand description

Policy implementations for swink_agent.

This crate provides all policy implementations built against swink-agent’s public policy trait API. Each policy is feature-gated independently:

§Core policies

  • budget: BudgetPolicy — stops the loop when cost or token limits are exceeded
  • max-turns: MaxTurnsPolicy — stops the loop after a configured number of turns
  • deny-list: ToolDenyListPolicy — rejects tool calls by name
  • sandbox: SandboxPolicy — restricts file paths to an allowed root directory
  • loop-detection: LoopDetectionPolicy — detects repeated tool call patterns
  • checkpoint: CheckpointPolicy — persists agent state after each turn

§Application policies

  • prompt-guard: PromptInjectionGuard — blocks prompt injection in user messages and tool results
  • pii: PiiRedactor — redacts personally identifiable information from assistant responses
  • content-filter: ContentFilter — keyword/regex blocklist for assistant output
  • audit: AuditLogger — records every turn to a pluggable sink
  • memory-nudge: MemoryNudgePolicy — heuristic detection of save-worthy content in agent turns

Structs§

AuditCost
Subset of cost relevant for audit records.
AuditLogger
PostTurnPolicy that builds an AuditRecord for every turn and writes it to the configured AuditSink.
AuditRecord
Summary of a single turn, suitable for serialization to an audit log.
AuditUsage
Subset of token usage relevant for audit records.
BudgetPolicy
Stops the agent loop when accumulated cost or tokens exceed configured limits.
CheckpointPolicy
Persists agent state after each turn via a CheckpointStore.
ContentFilter
Keyword/regex blocklist for assistant output.
FilterRule
A single filter rule consisting of a compiled regex and metadata.
JsonlAuditSink
Appends one JSON line per audit record to a file on disk.
LoopDetectionPolicy
Detects when the model is stuck in a cycle, calling the same tools with identical arguments repeatedly.
MaxTurnsPolicy
Stops the agent loop after a configured number of turns.
MemoryNudge
A structured payload emitted when save-worthy content is detected in a turn.
MemoryNudgePolicy
A PostTurnPolicy that detects save-worthy content via heuristic pattern matching.
PiiPattern
A named regex pattern used for PII detection.
PiiRedactor
Detects and optionally redacts PII in assistant output.
PromptInjectionGuard
SandboxPolicy
Rejects tool calls that reference file paths outside an allowed root directory.
ToolDenyListPolicy
Rejects tool calls whose names appear in the deny list.

Enums§

ContentFilterError
Errors returned when constructing a ContentFilter.
LoopDetectionAction
What to do when a repeated tool call pattern is detected.
MemoryNudgeCategory
The category of save-worthy content detected by MemoryNudgePolicy.
NudgeSensitivity
Controls how aggressively MemoryNudgePolicy flags borderline content.
PiiMode
Behaviour when PII is detected.

Traits§

AuditSink
Pluggable destination for audit records.