DEV Community

Anton Illarionov
Anton Illarionov

Posted on

Constitutional AI Safety for Agents: 7-Layer Validation

Constitutional AI Safety for Agents

Add production guardrails to any AI agent.

Quick Start

import requests

def check_action(action):
    r = requests.post(
        'https://api.odei.ai/api/v2/guardrail/check',
        json={'action': action, 'severity': 'medium'}
    ).json()
    return r.get('verdict') == 'APPROVED'

if check_action('send email to all users'):
    send_email()
Enter fullscreen mode Exit fullscreen mode

MCP (Claude Desktop)

{"mcpServers": {"odei": {"command": "npx", "args": ["@odei/mcp-server"]}}}
Enter fullscreen mode Exit fullscreen mode

7 Constitutional Layers

  1. Immutability
  2. Temporal context
  3. Referential integrity (catches hallucinated references)
  4. Authority
  5. Deduplication (prevents double-actions)
  6. Provenance
  7. Constitutional alignment

Returns: APPROVED / REJECTED / ESCALATE

Production Stats (ODEI Jan-Feb 2026)

  • 65% APPROVED
  • 15% REJECTED
  • 20% ESCALATE

LangChain

from langchain.tools import tool
import requests

@tool
def guardrail_check(action: str) -> str:
    r = requests.post('https://api.odei.ai/api/v2/guardrail/check',
                      json={'action': action}).json()
    return f"{r['verdict']}: {r.get('reasoning','')[:200]}"
Enter fullscreen mode Exit fullscreen mode

Links

Top comments (0)