Behavioral monitoring and directive control for AI agents
Project description
SOMA
The nervous system for AI agents. Monitors behavior, predicts problems, and intervenes before things go wrong.
uv tool install soma-ai
soma setup-claude
That's it. Your Claude Code now has a nervous system.
Quick start
# Install (pick one)
uv tool install soma-ai # recommended (uv)
pipx install soma-ai # alternative (pipx)
pip install soma-ai # if you manage PATH yourself
# Connect to Claude Code (installs hooks, status line, slash commands)
soma setup-claude
# Check it's working
soma status
After setup, SOMA runs automatically. Every tool call is monitored. You'll see a status line at the bottom of Claude Code:
SOMA + healthy 2% · #42 · quality A
Slash commands
Use these inside Claude Code:
| Command | What it does |
|---|---|
/soma:status |
Live status — pressure, quality, vitals, budget, tips |
/soma:config |
Settings — modes, thresholds, budget, toggles |
/soma:config mode strict |
Strict mode — low thresholds, verbose |
/soma:config mode relaxed |
Relaxed (default) — balanced monitoring |
/soma:config mode autonomous |
Minimal monitoring for trusted runs |
/soma:control quarantine |
Force agent to quarantine (blocks tools) |
/soma:control release |
Release from quarantine |
/soma:control reset |
Reset behavioral baseline |
/soma:help |
Full command reference |
Terminal commands
soma # live TUI dashboard
soma status # quick text summary
soma mode # show/switch operating mode
soma agents # list monitored agents
soma setup-claude # install hooks into Claude Code
soma config show # print soma.toml
soma export # export session to JSON
Operating modes
Switch with soma mode <name> or /soma:config mode <name>:
| Mode | Autonomy | Quarantine at | Verbosity |
|---|---|---|---|
| strict | human-in-the-loop | 60% | verbose |
| relaxed (default) | human-on-the-loop | 80% | normal |
| autonomous | fully autonomous | 95% | minimal |
What it monitors
5 behavioral signals per action:
- Uncertainty — retries, output chaos, tool diversity
- Drift — deviation from established patterns
- Error rate — syntax errors, failed commands
- Cost — token/dollar burn rate
- Quality — A-F grade (syntax, lint, bash success)
Predicts problems ~5 actions before they happen.
Restricts progressively as pressure rises:
HEALTHY (0-24%) → CAUTION (25%) → DEGRADE (50%) → QUARANTINE (75%) → RESTART (90%)
all allowed warn on writes bash blocked read-only full stop
Explains in plain English:
- "stuck in Edit→Bash loop on config.py (4 cycles)"
- "3 consecutive Bash failures (error_rate=40%)"
- "scope expanded to tests/, config/"
How it works
Tool call → PreToolUse (can block) → Tool executes → PostToolUse (record + validate)
│
Compute vitals → Pressure → Level
│
UserPromptSubmit ← Prediction + RCA + Quality + Tips
4 hooks, all configurable:
- PreToolUse — blocks dangerous actions under pressure
- PostToolUse — records action, validates code, computes vitals
- UserPromptSubmit — injects actionable feedback into agent context
- Stop — saves state, updates fingerprint, shows session summary
Everything is deterministic. No LLM calls. No network requests. Pure math.
Configuration
soma.toml controls everything:
[hooks]
verbosity = "normal" # minimal, normal, verbose
validate_python = true # syntax check after Write
lint_python = true # ruff check after Write
predict = true # anomaly prediction
quality = true # A-F quality grading
[thresholds]
caution = 0.40
degrade = 0.60
quarantine = 0.80
[weights]
uncertainty = 1.2
drift = 1.5
error_rate = 2.5
Claude Code plugin
SOMA is also available as a Claude Code plugin:
/install tr00x/soma-core
This auto-registers hooks and adds /soma:* slash commands.
Requirements
- Python >= 3.11
- Claude Code (for hook integration)
- Optional:
rufffor lint validation,nodefor JS validation
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file soma_ai-0.3.2.tar.gz.
File metadata
- Download URL: soma_ai-0.3.2.tar.gz
- Upload date:
- Size: 150.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
797c2edf762237b576b3a06a7ecae9e1af3199139077b0420cb1e60db346c13a
|
|
| MD5 |
cb7595c418b53dcee4bbfb0f38ff5ee6
|
|
| BLAKE2b-256 |
cbdc23c725031cc60914aefecab3e5a9b95a7d391c49910f12ed232ca3e85695
|
File details
Details for the file soma_ai-0.3.2-py3-none-any.whl.
File metadata
- Download URL: soma_ai-0.3.2-py3-none-any.whl
- Upload date:
- Size: 97.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad70208f8ad5b98b718b3c88ae42a6feeaac1f5c4bc3db4968156d265a5dc659
|
|
| MD5 |
bb0d44b5a4aedf283da56c8ff5e063f9
|
|
| BLAKE2b-256 |
3468c22ae9fa4ad1f9ecb11ededdfdca7667bc41b82a7aa494a377318a2aa053
|