Content moderation, PII detection, compliance, policies, actions, and audit logging
Sentinel is Teleon’s safety and compliance system for AI agents. It validates inputs before execution and validates outputs after execution.
For the full API surface (including GuardrailResult fields and detailed violation structures), see Sentinel API in API Reference.
Sentinel API
Safety & compliance
- Enabling Sentinel on an agent
- Content moderation configuration (
moderation_threshold)
- PII detection and redaction
- Prompt injection detection (
injection_threshold)
- Compliance standards configuration
- Policy DSL (YAML/JSON)
- Tool guardrails (allowlist/blocklist + policy rules)
- Violation actions (
block, flag, redact, escalate)
- Audit logging and platform persistence
- Webhooks and Dashboard monitoring
from teleon import TeleonClient
client = TeleonClient(api_key="tlk_live_xxx")
@client.agent(
name="support",
sentinel={
"content_filtering": True,
"pii_detection": True,
"prompt_injection_detection": True,
"action_on_violation": "block",
},
)
async def support_agent(query: str):
return "ok"
Sentinel’s content moderator detects toxic content across multiple categories and languages.
@client.agent(
name="chat",
sentinel={
"content_filtering": True,
"language": "en",
"additional_languages": ["es", "fr"],
"moderation_threshold": 0.8,
},
)
async def chat_agent(message: str):
return "ok"
Direct usage:
from teleon.sentinel.content_moderator import ContentModerator
moderator = ContentModerator(threshold=0.8)
results = moderator.check_all(text)
Sentinel detects and optionally redacts PII. Supported types include emails, phones (US/UK/EU/intl), SSNs, credit cards, IBANs, EU VAT numbers, passports, addresses, and names.
@client.agent(
name="support",
sentinel={
"pii_detection": True,
"action_on_violation": "redact",
},
)
async def support_agent(query: str):
return "ok"
Direct usage:
from teleon.sentinel.pii_detector import PIIDetector
detector = PIIDetector()
detected = detector.detect(text)
redacted_text = detector.redact(text)
Note: PII field names in the detect() return dict are singular: email, phone, ssn, credit_card, ip_address, iban, vat, passport, dob, address, name.
Sentinel detects attempts to manipulate agent behavior through prompt injection, jailbreaking, and encoding evasion.
@client.agent(
name="chat",
sentinel={
"prompt_injection_detection": True,
"injection_threshold": 0.8,
"action_on_violation": "block",
},
)
async def chat_agent(message: str):
return "ok"
Supported standards include GDPR, HIPAA, PCI_DSS, SOC2, and CCPA.
from teleon.sentinel import ComplianceStandard
@client.agent(
name="healthcare",
sentinel={
"compliance": [
ComplianceStandard.HIPAA,
ComplianceStandard.GDPR,
]
},
)
async def healthcare_agent(query: str):
return "ok"
Define rules declaratively in YAML or JSON. This replaces legacy custom policies for new code.
version: "1.0"
policies:
- name: restrict-tools
severity: critical
action: block
targets: [tool_call]
rules:
- type: tool_allowlist
allowed_tools: [web_search, calculator]
- type: tool_argument
tool: web_search
argument: query
operator: not_contains_any
values: [hack, exploit, vulnerability]
match: all
@client.agent(
name="agent",
tools=[web_search, calculator],
sentinel={
"policy_file": "policies.yaml",
},
)
async def agent(query: str):
return "ok"
Tool guardrails validate tool calls before execution. Prefer allowlists for production agents.
@client.agent(
name="agent",
tools=[web_search, calculator, shell_exec],
sentinel={
"tool_guardrails": True,
"allowed_tools": ["web_search", "calculator"],
},
)
async def agent(query: str):
return "ok"
The PolicyEngine class is retained for backward compatibility. New code should use the Policy DSL instead.
from teleon.sentinel.policy_engine import PolicyEngine
engine = PolicyEngine()
engine.add_policy("no_competitors", {
"type": "regex",
"pattern": r"\b(competitor1|competitor2|rival)\b",
"message": "Competitor mention detected",
"severity": "medium",
})
engine.add_policy("max_length", {
"type": "condition",
"condition": "len(text) > 10000",
"message": "Content exceeds maximum length",
"severity": "low",
})
Available actions are block, flag, redact, and escalate.
- Block: stops execution and raises
AgentValidationError
- Flag: logs violation and allows execution to continue
- Redact: masks sensitive content and continues
- Escalate: flags for human review
from teleon.sentinel import GuardrailAction
@client.agent(
name="agent",
sentinel={
"action_on_violation": GuardrailAction.REDACT,
},
)
async def agent(query: str):
return "ok"
Enable structured logging and an audit trail.
@client.agent(
name="agent",
sentinel={
"log_violations": True,
"audit_enabled": True,
},
)
async def agent(query: str):
return "ok"
Accessing audit logs:
audit_logger = engine.get_audit_logger()
violations = audit_logger.get_violations(agent_id="my-agent", limit=100)
stats = audit_logger.get_violation_stats(agent_id="my-agent")
Violations can be persisted to the Teleon platform database:
from teleon.sentinel.persistence import SentinelViolationPersistence
persistence = SentinelViolationPersistence(
agent_id="my-agent",
agent_name="My Agent",
batch_size=10,
flush_interval=5.0,
max_queue_size=1000,
)
await persistence.submit_violation(
violation_type="pii_detection",
action_taken="redact",
details={"pii_type": "email"},
validation_type="input",
)
await persistence.flush()
await persistence.close()
Webhooks send real-time HTTP notifications when violations occur. Configure them via the Dashboard or the platform API.
Use the Teleon Dashboard to browse violations, view statistics, manage policies, and configure webhooks.