How krishhcodes/agentguard works
AgentGuard runs tool-using RAG scenarios through a LangGraph agent, optionally protecting retrieved content with the Content Firewall and proposed actions with the Action Guard. The guarded path derives user-request scope, tracks untrusted/confidential data, and can pause for human approval; tools operate in an in-memory sandbox. Runs produce audit outcomes, while the evaluation harness measures attack and task results. The README documents the demo UI, alerts, and session monitoring; sampled excerpts do not expose every runtime connection, so those links are limited to documented or indexed relationships.
Main entry points: nodes.py Agent nodes · runner.py Scenario runner · pipeline.py Content firewall · harness.py Evaluation harness
Components 25
Agent workflow
- Scenario runner
agentguard/runner.py - Agent graph
agentguard/agent/graph.py - Agent nodes
agentguard/agent/nodes.py - Run state
agentguard/agent/state.py - RAG retrieval
agentguard/rag/retriever.py
Security layers
- Request scope
agentguard/scope/extractor.py - Content firewall
agentguard/firewall/pipeline.py - Injection heuristics
agentguard/firewall/heuristics.py - LLM classifier
agentguard/firewall/classifier.py - Text views
agentguard/text/views.py - Action rules
agentguard/guard/rules.py - Taint ledger
agentguard/guard/taint.py - Session monitor
agentguard/monitor/session.py
Runtime and evidence
- Tool sandbox
agentguard/sandbox/env.py - Tool registry
agentguard/sandbox/tools.py - LLM gateway
agentguard/llm.py - Audit events
agentguard/audit/events.py - Run alerts
agentguard/alerts.py - Security policy
agentguard/policy.py
Evaluation
- Evaluation harness
agentguard/eval/harness.py - Scenario suites
agentguard/eval/suites.py - Evaluation metrics
agentguard/eval/metrics.py
Other components
- User
Connections 31
- User → CLI: starts runs
README.md - User → Demo UI: uses demo
README.md - CLI → Scenario runner: runs scenario
agentguard/cli.py - Demo UI → Scenario runner: runs scenario
ui/app.py - Scenario runner → Agent graph: invokes graph
agentguard/runner.py - Agent graph → Agent nodes: dispatches nodes
agentguard/agent/graph.py - Agent nodes → Run state: updates state
agentguard/agent/nodes.py - Agent nodes → RAG retrieval: retrieves context
agentguard/agent/nodes.py - Agent nodes → Content firewall: scans content
agentguard/agent/nodes.py - Content firewall → Injection heuristics: scores text
agentguard/firewall/pipeline.py - Content firewall → LLM classifier: classifies ambiguity
agentguard/firewall/pipeline.py - Content firewall → Text views: uses text views
agentguard/firewall/pipeline.py - Agent nodes → LLM gateway: requests completion
agentguard/agent/nodes.py - Agent nodes → Request scope: extracts scope
README.md - Agent nodes → Action rules: checks tool calls
agentguard/agent/nodes.py - Agent nodes → Taint ledger: records provenance
agentguard/agent/nodes.py - Action rules → Taint ledger: checks data flow
agentguard/guard/rules.py - Agent nodes → Tool registry: dispatches tools
- Tool registry → Tool sandbox: operates on
agentguard/sandbox/tools.py - Agent nodes → Audit events: emits decisions
agentguard/agent/nodes.py - Scenario runner → Tool sandbox: creates sandbox
README.md - Scenario runner → Session monitor: supports sessions
README.md - Session monitor → Action rules: uses guard rules
agentguard/monitor/session.py - Scenario runner → Run alerts: produces alerts
README.md - Action rules → Security policy: applies policy
agentguard/guard/rules.py - Content firewall → Security policy: uses thresholds
agentguard/firewall/pipeline.py - CLI → Evaluation harness: starts evaluation
agentguard/cli.py - Evaluation harness → Scenario suites: loads scenarios
agentguard/eval/harness.py - Evaluation harness → Scenario runner: runs scenarios
agentguard/eval/harness.py - Evaluation harness → Evaluation metrics: computes metrics
agentguard/eval/harness.py - Scenario runner → Audit events: records lifecycle
agentguard/runner.py