Choose your integration path. All paths share the same core kernel.
Best for: any CLI, any language, any framework.
pip install agentassert-typec-proxyWrite a contract:
cat > contract.yaml << 'EOF'
dsl_version: "0.4"
contractspec: "1.0"
kind: agent
name: safety-minimal
description: "Block destructive tool calls only."
version: "0.1"
invariants:
process:
- tool_blocklist:
tools: ["rm -rf /*", "curl|bash"]
scope: session
recovery:
on_hard_violation: raise
on_soft_violation: log_and_continue
EOFStart the proxy:
agentassert-proxy proxy start --contract contract.yaml --port 9000Point your agent at it. The proxy acts as a drop-in replacement by intercepting provider HTTP requests. Configure your favorite tool as follows:
Point Claude Code to the proxy by setting the base URL in your terminal before launching:
export ANTHROPIC_BASE_URL=http://localhost:9000/anthropic
claudeNote: Every model call and tool execution made by Claude Code will now pass through the contract evaluation engine.
Antigravity IDE targets both Gemini and DeepSeek (via OpenAI endpoint). Intercept both by exporting:
# Point OpenAI-compatible requests (like DeepSeek Pro) to proxy
export OPENAI_BASE_URL=http://localhost:9000/openai
# Point Gemini requests to proxy
export GEMINI_BASE_URL=http://localhost:9000/geminiEnsure your terminal session or workspace runtime inherits these environment variables before starting the agent.
To govern CommandCode (cmd-mimo, cmd-ds), configure the environment variables globally:
export ANTHROPIC_BASE_URL=http://localhost:9000/anthropic
export OPENAI_BASE_URL=http://localhost:9000/openai
export GEMINI_BASE_URL=http://localhost:9000/gemini
export OPENROUTER_BASE_URL=http://localhost:9000/openrouterAdding this to your shell profile (~/.zshrc or ~/.bash_profile) guarantees that CommandCode's local models and downstream APIs are intercepted.
To intercept Hermes CLI agent requests, update ~/.hermes/config.yaml to specify proxy upstream URLs:
# ~/.hermes/config.yaml
providers:
openai:
base_url: "http://127.0.0.1:9000/openai/v1"
anthropic:
base_url: "http://127.0.0.1:9000/anthropic/v1"
gemini:
base_url: "http://127.0.0.1:9000/gemini/v1"
openrouter:
base_url: "http://127.0.0.1:9000/openrouter/v1"Or start the hermes command with env variables configured (export ANTHROPIC_BASE_URL=...).
To route Cursor's AI queries through AgentAssert:
- Terminal Launch: Set base URLs in terminal and start Cursor from there:
export ANTHROPIC_BASE_URL=http://localhost:9000/anthropic export OPENAI_BASE_URL=http://localhost:9000/openai cursor .
- UI Configuration: Alternatively, go to Settings -> Models -> Custom API Keys / Base URLs and supply:
- OpenAI:
http://localhost:9000/openai/v1 - Anthropic:
http://localhost:9000/anthropic/v1
- OpenAI:
Cascade agent in Windsurf respects proxy configuration:
- Terminal Launch:
export ANTHROPIC_BASE_URL=http://localhost:9000/anthropic export OPENAI_BASE_URL=http://localhost:9000/openai windsurf .
- UI Settings: Go to Windsurf Settings -> AI Configurations -> Custom Endpoints:
- OpenAI Compatible Base URL:
http://localhost:9000/openai/v1 - Anthropic Compatible Base URL:
http://localhost:9000/anthropic/v1
- OpenAI Compatible Base URL:
Edit your local openclaw_config.json to route through the proxy:
{
"anthropic_base_url": "http://localhost:9000/anthropic/v1",
"openai_base_url": "http://localhost:9000/openai/v1"
}Or run the OpenClaw service inside a shell where the base URLs are exported.
In the Cline panel:
- Click the Settings icon.
- Under API Provider, select OpenAI Compatible or Anthropic.
- Configure the Base URL:
- OpenAI compatible:
http://localhost:9000/openai/v1 - Anthropic compatible:
http://localhost:9000/anthropic/v1
- OpenAI compatible:
- Enter any placeholder text for API Key (the proxy forwards the real ones automatically).
All provider API calls now flow through the contract layer. No code changes needed.
Best for: Python developers using Anthropic or OpenAI SDKs directly.
pip install agentassert-typec-sdkfrom anthropic import Anthropic
from agentassert_typec_sdk import wrap
client = wrap(Anthropic(), "contract.yaml")
# Every call is now contract-enforced
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}]
)Supported clients: anthropic.Anthropic, anthropic.AsyncAnthropic, openai.OpenAI, openai.AsyncOpenAI.
Best for: Claude Code CLI power users.
pip install agentassert-typec-claude-codeInstall the hook:
agentassert-claude-code install --contract safety-minimal.yamlCheck status:
agentassert-claude-code statusRemove the hook:
agentassert-claude-code uninstallThree contract templates ship with the package: safety-minimal, partner-mode, full-governance.
npx agentassert-typec proxy start --contract contract.yaml --port 9000Same as the HTTP proxy, zero-install via npm. Downloads the pre-built binary.
brew install agentassert-typec
agentassert-proxy proxy start --contract contract.yamlHere's a production-ready contract with all 7 operators:
dsl_version: "0.4"
contractspec: "1.0"
kind: agent
name: full-governance
description: "Full behavioral contract with all process operators."
version: "0.1"
invariants:
process:
# 1. Require challenge before recommendation
- must_precede:
before: "challenge"
after: "recommendation"
scope: turn
# 2. State cost before paid API calls
- must_state:
field: "cost"
before_tool_pattern: "tap_*|paid_api_*"
rationale: "Per cost-control policy"
# 3. Block destructive tools
- tool_blocklist:
tools:
- "rm -rf /*"
- "curl|bash"
- "*--no-verify"
scope: session
# 4. Restrict tools for specific skills
- tool_allowlist:
tools: ["Read", "Write", "Edit", "Grep", "Glob"]
scope: "skill:seo-content-optimizer"
# 5. Cap token usage per turn
- context_budget:
max_tokens_per_turn: 60000
action_on_breach: warn
# 6. Detect behavioral drift
- process_drift:
window_size: 10
jsd_threshold: 0.30
action: log
# 7. LLM-as-judge for qualitative rules
- judge_predicate:
rubric: "Response shows L99 conviction (no 'depends', no 'either works')"
sample_rate: 0.20
model: ds-flash-free
action_on_fail: theta_penalty
cost_ceiling_usd_per_session: 0.10
recovery:
on_hard_violation: raise
on_soft_violation: log_and_continue
satisfaction:
p: 0.95
delta: 0.10
k: 3After starting the proxy, test that blocked tools actually get blocked:
# This call should return a ContractBreachError
curl -X POST http://localhost:9000/anthropic/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Run: rm -rf /"}]
}'The proxy returns a 400 with the violation details instead of forwarding to Anthropic.
- Contract DSL Reference — all 7 operators in detail
- Case Study — compressing CLAUDE.md by 48%
- Mathematics — JSD drift, Θ scorer, (p,δ,k)
- FAQ