Three integration paths. Pick the one that fits.
# Install (pick one)
uv tool install soma-ai # recommended
# pip install soma-ai # if pip is on PATH
# pipx install soma-ai # equivalent
soma installSOMA monitors all tool calls automatically via pre/post hooks. No code changes needed.
What you get: real-time guidance injected into Claude Code's context whenever behavioral pressure rises. The agent sees SOMA's advice as part of the tool response.
import anthropic
import soma
client = soma.wrap(anthropic.Anthropic())
response = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}]
)Every LLM call is intercepted. SOMA tracks vitals and injects guidance messages when pressure rises. Raises SomaBlocked if pressure exceeds the block threshold, SomaBudgetExhausted if a budget dimension is spent.
import soma
engine = soma.quickstart()
agent_id = engine.register_agent("my-agent")
# Record actions manually
result = engine.record_action(
agent_id,
soma.Action(tool_name="Bash", output_text="...", token_count=100)
)
print(result.vitals.pressure) # 0.0 - 1.0
print(result.mode) # OBSERVE / GUIDE / WARN / BLOCKFull control over what gets monitored and when.
| Command | What it does |
|---|---|
soma status |
Current pressure, vitals, and budget |
soma install |
Install Claude Code hooks |
soma config show |
Display active configuration |
soma doctor |
Diagnose configuration and hook health |
soma analytics |
Session analytics and trends |
soma replay |
Replay a recorded session |
soma dashboard |
Launch web dashboard (ROI page) |
SOMA reads from soma.toml in your project root. Everything has sensible defaults.
[budget]
tokens = 100000
cost_usd = 5.0
[thresholds]
guide = 0.4 # pressure above this → suggest corrections
warn = 0.7 # pressure above this → alert + flag destructive ops
block = 0.9 # pressure above this → restrict destructive operationsaction ──> vitals ──> pressure ──> guidance ──> injection
- Actions enter the engine (tool calls, API requests)
- Vitals computed: uncertainty, drift, error rate, token usage, cost
- Pressure derived from vitals using EMA baselines and z-score sigmoid
- Guidance fires when pressure crosses thresholds: OBSERVE → GUIDE → WARN → BLOCK
- Contextual patterns (retry loops, tool entropy, panic edits) trigger specific prescriptions
The closed loop: actions → vitals → pressure → guidance → behavior change.