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 exceededmax-turns:MaxTurnsPolicy— stops the loop after a configured number of turnsdeny-list:ToolDenyListPolicy— rejects tool calls by namesandbox:SandboxPolicy— restricts file paths to an allowed root directoryloop-detection:LoopDetectionPolicy— detects repeated tool call patternscheckpoint:CheckpointPolicy— persists agent state after each turn
§Application policies
prompt-guard:PromptInjectionGuard— blocks prompt injection in user messages and tool resultspii:PiiRedactor— redacts personally identifiable information from assistant responsescontent-filter:ContentFilter— keyword/regex blocklist for assistant outputaudit:AuditLogger— records every turn to a pluggable sinkmemory-nudge:MemoryNudgePolicy— heuristic detection of save-worthy content in agent turns
Structs§
- Audit
Cost - Subset of cost relevant for audit records.
- Audit
Logger PostTurnPolicythat builds anAuditRecordfor every turn and writes it to the configuredAuditSink.- Audit
Record - Summary of a single turn, suitable for serialization to an audit log.
- Audit
Usage - Subset of token usage relevant for audit records.
- Budget
Policy - Stops the agent loop when accumulated cost or tokens exceed configured limits.
- Checkpoint
Policy - Persists agent state after each turn via a
CheckpointStore. - Content
Filter - Keyword/regex blocklist for assistant output.
- Filter
Rule - A single filter rule consisting of a compiled regex and metadata.
- Jsonl
Audit Sink - Appends one JSON line per audit record to a file on disk.
- Loop
Detection Policy - Detects when the model is stuck in a cycle, calling the same tools with identical arguments repeatedly.
- MaxTurns
Policy - Stops the agent loop after a configured number of turns.
- Memory
Nudge - A structured payload emitted when save-worthy content is detected in a turn.
- Memory
Nudge Policy - A
PostTurnPolicythat 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.
- Prompt
Injection Guard - Sandbox
Policy - Rejects tool calls that reference file paths outside an allowed root directory.
- Tool
Deny List Policy - Rejects tool calls whose names appear in the deny list.
Enums§
- Content
Filter Error - Errors returned when constructing a
ContentFilter. - Loop
Detection Action - What to do when a repeated tool call pattern is detected.
- Memory
Nudge Category - The category of save-worthy content detected by
MemoryNudgePolicy. - Nudge
Sensitivity - Controls how aggressively
MemoryNudgePolicyflags borderline content. - PiiMode
- Behaviour when PII is detected.
Traits§
- Audit
Sink - Pluggable destination for audit records.