Skip to main content

Example: Network Automation Agent

This example shows how to use AgenticGuard with an AI agent that manages network infrastructure — a high-risk scenario where every action must be audited and destructive operations must be blocked.

Scenario

An LLM-powered network agent that can:

  • Query device status (read-only, safe)
  • Update firewall rules (write, needs audit)
  • Restart services (destructive, needs approval)

Policy

version: "1"
rules:
# Block all destructive actions
- tool: network
action: restart
decision: deny
message: "Service restarts require manual approval"

- tool: network
action: shutdown
decision: deny

# Require reasoning for any write
- tool: network
action: update
require_reasoning: true
message: "Firewall rule updates require agent reasoning"

- tool: network
action: create
require_reasoning: true

# Allow reads freely
- tool: network
action: get
decision: allow

- tool: network
action: list
decision: allow

Agent code

from agentic_guard import AgenticGuard, PolicyViolationError

gate = AgenticGuard(
api_key="ag_xxxxxxxxxxxx",
base_url="https://api.agentic-guard.com",
mode="enforce",
)

def query_device_status(device_id: str) -> dict:
return gate.call(
tool="network",
action="get",
tool_url=f"https://network-api.internal/devices/{device_id}",
method="GET",
task_id="status_check",
)

def update_firewall_rule(rule_id: str, new_config: dict, reasoning: str) -> dict:
return gate.call(
tool="network",
action="update",
tool_url=f"https://network-api.internal/firewall/{rule_id}",
method="PUT",
body=new_config,
reasoning=reasoning,
task_id="firewall_update",
)

def restart_service(service_name: str) -> dict:
try:
return gate.call(
tool="network",
action="restart",
tool_url=f"https://network-api.internal/services/{service_name}/restart",
method="POST",
)
except PolicyViolationError as e:
# Signal the LLM to request manual approval
return {
"error": "requires_approval",
"message": e.message,
"action": "restart",
"target": service_name,
}

What the audit log shows

timestamp tool action decision reasoning
2026-07-16 10:01 network get allowed —
2026-07-16 10:02 network update allowed "Blocking port 8080 per security scan #42"
2026-07-16 10:03 network restart denied — ← blocked, manual review triggered

Key takeaways

  • Read operations are allowed freely (low risk)
  • Write operations require reasoning (creates an audit trail)
  • Destructive operations are blocked entirely — the agent returns a structured signal for human approval