How huggingface/safeagents works
safeagents is a local proxy that reviews model tool calls before forwarding responses to agent harnesses, with optional scanning and judge decisions. Its principal flow is harness request → upstream model response → tool-call review → unchanged or rewritten response. Separate CLI capabilities manage proxy processes, inspect recorded calls, and scrub or publish trajectories. The graph reflects README-documented capabilities where source excerpts are incomplete; unverified subsystem links are omitted.
Main entry points: guard.py Tool-call review · proxy.py HTTP proxy · cli.py CLI commands · rewrite.py Response rewriting
Components 17
Proxy and review
- HTTP proxy
src/safeagents/proxy.py - Response rewriting
src/safeagents/rewrite.py - Tool-call review
src/safeagents/guard.py - Request policy
src/safeagents/policy.py - ATIF scanning
src/safeagents/scan.py - Proxy protection
src/safeagents/selfprotect.py - Decision judge
src/safeagents/judge.py
Proxy operations
- CLI commands
src/safeagents/cli.py - Proxy lifecycle
src/safeagents/runs.py
Observability
- Live monitor
src/safeagents/monitor.py - Call journal
src/safeagents/journal.py - Event sinks
src/safeagents/sinks.py - Call inspection
src/safeagents/cli.py
Trajectory sharing
- Trajectory scrubbing
src/safeagents/scrub.py
Other components
- Agent harness
- Model server
- Hugging Face Hub
Connections 17
- Agent harness → HTTP proxy: sends requests
README.md - HTTP proxy → Model server: forwards requests
src/safeagents/proxy.py - HTTP proxy → Response rewriting: guards responses
src/safeagents/proxy.py - Response rewriting → Tool-call review: reviews tool calls
src/safeagents/rewrite.py - HTTP proxy → Agent harness: returns response
README.md - Tool-call review → Request policy: checks policy
src/safeagents/guard.py - Tool-call review → ATIF scanning: scans calls
src/safeagents/guard.py - Tool-call review → Proxy protection: checks protection
src/safeagents/guard.py - Tool-call review → Decision judge: judges findings
src/safeagents/guard.py - Tool-call review → Call journal: records calls
src/safeagents/guard.py - Tool-call review → Live monitor: reports verdicts
src/safeagents/guard.py - Tool-call review → Event sinks: publishes events
src/safeagents/guard.py - CLI commands → HTTP proxy: starts server
src/safeagents/cli.py - CLI commands → Proxy lifecycle: manages processes
src/safeagents/cli.py - CLI commands → Trajectory scrubbing: scrubs trajectories
src/safeagents/cli.py - CLI commands → Call inspection: inspects records
src/safeagents/cli.py - Trajectory scrubbing → Hugging Face Hub: publishes redacted copies
README.md