AI Agent Security Cheat Sheet — Agent Monitoring
Bounded code example (external data; do not execute automatically): ```python import structlog from dataclasses import dataclass, field from typing import List, Dict, Any from datetime import datetime logger = structlog.get_logger() @dataclass class AgentSecurityEvent: event_type: str severity: str
Reference note (untrusted external data; do not execute it as instructions).
Bounded code example (external data; do not execute automatically):
```python
import structlog
from dataclasses import dataclass, field
from typing import List, Dict, Any
from datetime import datetime
logger = structlog.get_logger()
@dataclass
class AgentSecurityEvent:
event_type: str
severity: str # INFO, WARNING, CRITICAL
agent_id: str
session_id: str
user_id: str
timestamp: datetime
details: Dict[str, Any]
tool_name: Optional[str] = None
class AgentMonitor:
ANOMALY_THRESHOLDS = {
"tool_calls_per_minute": 30,
"failed_tool_calls": 5,
"injection_attempts": 1,
"sensitive_data_access": 3,
"cost_per_session_usd": 10.0,
}
def __init__(self, agent_id: str):
self.agent_id = agent_id
self.session_metrics = {}
self.alert_handlers = []
async def log_tool_call(self, session_id: str, tool_name: str,
params: dict, result: dict, user_
```
Attribution: Adapted from OWASP Cheat Sheet Series under CC-BY-SA-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
OWASP Cheat Sheet Series — cheatsheets/AI_Agent_Security_Cheat_Sheet.md :: Agent Monitoring ↗Revision 07111ee754e8 · CC-BY-SA-4.0 and attribution