Watches your LLM agent in real time and intercepts meltdowns before they spiral.
Project description
Sotis
Sotis watches your LLM agent and catches it before it spirals.
Live run: a real LLM agent spirals on a buggy codebase. Sotis detects three meltdowns in real time, intercepts each one, and degrades gracefully (GDS 1.0 → 0.4) instead of letting the agent burn.
📄 Full raw terminal transcript of this run: run_groq_llama70b_meltdown_20260601.txt
pip install sotis
Long-running agents fail in predictable ways — they loop on the same tool calls, flood their context with error traces, and spiral until the task collapses. Sotis detects these failure patterns in real time and transparently resets execution before they take hold.
Based on "Beyond pass@1: A Reliability Science Framework for Long-Horizon LLM Agents" (arXiv:2603.29231, April 2026)
Architecture
An agent goal is decomposed into a DAG of subtasks and executed through the Sotis ReAct runtime or the LangGraph guard. Every step is fed to the core layer — the Shannon entropy monitor, the Jaccard/fingerprint loop detector, and the workspace density guard. When any of them flags a meltdown, the Checkpoint Manager rolls the workspace back to its last stable state, the Context Resetter distills a compact resumption prompt, and execution continues. Step telemetry streams to a JSON-L logger that the Streamlit dashboard renders.
Full architecture diagram, module descriptions, and design decisions: ARCHITECTURE.md
The Problem
Current AI agents fail predictably under long-horizon execution. As tasks grow longer, agents accumulate error and drift into terminal failure modes:
- Infinite Loops — repeating the same tool calls with identical arguments
- Semantic Spirals — rephrasing failed queries hoping for different outcomes
- Context Poisoning — flooding history with massive error traces and linter warnings
- Edit Storms — making rapid, uncoordinated file edits without shifting outputs
Frontier models do not fail because they are simple. They fail because long-horizon execution decays their reliability envelope until strategy collapse occurs. Sotis acts as an active runtime stabilizer — monitoring execution, detecting behavioral meltdowns, and transparently resetting context to restore forward progress.
Usage
from sotis import SotisGuard
guard = SotisGuard()
for step in range(max_steps):
action = agent.decide()
result = tools.execute(action)
meltdown = guard.watch(action.name, action.args, result.summary)
if meltdown:
guard.reset() # rolls back files, distills context, resumes cleanly
What it looks like in practice
[Step 22] write_file -> {"path": "src/main.py", "content": "import math"} | SUCCESS
[Step 23] run_tests -> {"cmd": "pytest"} | FAIL (ImportError)
[Step 24] write_file -> {"path": "src/main.py", "content": "import math"} | SUCCESS
[Step 25] run_tests -> {"cmd": "pytest"} | FAIL (ImportError)
[WARNING] Anomaly detected: Workspace edit storm and exact argument loops
[INTERCEPT] Sotis Meltdown Interception Triggered!
[RECOVER] Restored workspace files to stable baseline (step 22 diff)
[RECOVER] Distilled session context history (86% token savings)
[RESUME] Injecting resumption briefing into agent context...
[Step 26] grep_search -> {"query": "math"} | Execution resumed cleanly
CLI
sotis dashboard # Launch the Streamlit observability dashboard
sotis benchmark # Run the empirical benchmark suite
sotis demo # Run the built-in meltdown/recovery demo
The dashboard reads session telemetry from logs/. Point it elsewhere with
sotis dashboard --logs <path> or the SOTIS_LOG_DIR environment variable —
set the same value when running your agent so both write and read the same
directory regardless of where each is launched.
Full command reference and the LangGraph integration guide: USAGE.md
Tuning
The default entropy threshold (1.5 bits) is calibrated for agents that use 1-2 tools in tight loops. If your agent legitimately uses 3+ different tools in a short window, the default will fire false positives — log2(3) = 1.585 > 1.5.
Raise the threshold for multi-tool agents:
from sotis import SotisGuard
from sotis.core.entropy import EntropyConfig
guard = SotisGuard(entropy_config=EntropyConfig(hard_threshold=2.7))
| Threshold | Behavior |
|---|---|
1.5 (default) |
Catches tight loops fast. Will false-positive on diverse tool usage. |
2.0 |
Good balance for agents using 3-4 tools regularly. |
2.7 |
Permissive — only fires on genuine chaotic switching across 6+ tools. |
This was validated in the detection gauntlet: default threshold fired a false positive on healthy diverse work (Scenario E), raising to 2.7 eliminated it while preserving 100% true positive detection.
Active Stabilization, Not Passive Tracing
Tools like LangSmith, Langfuse, and Helicone log what happened after your agent already spent $20 looping in production.
Sotis intervenes during execution. It intercepts spiraling tool calls, rolls back uncommitted file edits, distills conversation history, and redirects the model's reasoning loop — before the damage accumulates.
Capabilities
| Capability | Description |
|---|---|
| Meltdown Detection | Sliding-window Shannon entropy (w=5, H=1.5) + exact loop detection |
| Workspace Density Guard | Detects infinite same-file edit cycles |
| Transparent Reset | Git-diff checkpointing + distilled context rebuild (≥60% token savings) |
| Graceful Degradation | GDS scoring preserves partial progress across resets |
| LangGraph Integration | Native guard node — intercepts state, rolls back files |
| Document Processing | PDF, XLSX, Word, CSV support + Jaccard semantic loop detection |
| LLM Support | OpenAI, Anthropic, DeepSeek, Google Gemini |
| Observability | Streamlit dashboard + structured JSON session logs |
The Science
Sotis operationalizes the formal reliability framework from "Beyond pass@1: A Reliability Science Framework for Long-Horizon LLM Agents" (arXiv:2603.29231, April 2026).
Four key findings from the paper that Sotis directly addresses:
Meltdown Onset Point (MOP) — the paper quantifies the transition from coherent planning to chaotic looping via sliding-window Shannon entropy. Sotis implements this as a live runtime monitor with a calibrated threshold of H=1.5 bits over a 5-step window.
Super-linear reliability decay — agent success rates decay faster than mathematically expected because errors are positively correlated across steps. A confused agent stays confused. Sotis acts as a circuit breaker that resets the error correlation coefficient by starting fresh from a verified checkpoint.
Episodic memory failures — the paper demonstrates that naive memory scaffolds universally degrade long-horizon performance by accumulating context overhead. Sotis uses controlled checkpointed resets instead of continuous memory accumulation.
Graceful Degradation Score (GDS) — rather than binary pass/fail, Sotis scores partial task completion using weighted subtask graphs, preserving measured progress across reset boundaries.
Performance
| Metric | Result |
|---|---|
| Entropy + loop detection latency | < 0.2ms per step |
| Context distillation token reduction | 86.14% (BPE cl100k_base) |
| Test suite | 127 tests, 88% coverage |
| Live recovery | Verified on circular import and AST recursive loop traps |
| Live LLM validation (llama-3.1-8b on Groq) | Raw agent: 1/4 requirements met. Sotis agent: 3/4 requirements met. |
| Detection accuracy (6-scenario gauntlet) | 100% true positive rate, 0% false negatives |
| Total API cost for full validation suite | < $0.01 (Groq free tier) |
Full empirical ledger: performance_metrics.txt
Real-world validation logs: ExperimentLog/real_world_validation/
Benchmarks
Reliability decay in frontier LLM agents as task horizon grows (Khanal et al. 2026 — arXiv:2603.29231)
Context distillation: token reduction after meltdown reset (measured with tiktoken BPE cl100k_base)
Real agent experiments — meltdown intercepts and outcomes (Gemini 3.5 · Groq Llama 70B · Mistral local · OpenRouter Gemini)
Project Structure
sotis/
core/ # Entropy, loop detection, checkpoint, decomposition, GDS
lib/ # ReAct runtime, LangGraph integration, LLM adapters
obs/ # Streamlit dashboard + structured JSON logger
bench/ # Benchmark harness and task generators
License
MIT
Project details
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 sotis-1.1.3.tar.gz.
File metadata
- Download URL: sotis-1.1.3.tar.gz
- Upload date:
- Size: 55.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b465eb61960009c662e4ad1f4e3322b53ad6cc4e87265e8fea5be7c41b3b3466
|
|
| MD5 |
7d068b94407076415011395e71d0f291
|
|
| BLAKE2b-256 |
095e28f361eec5afbb65f51dd60a3bd39290840267455fa791b11e3d52d3c733
|
File details
Details for the file sotis-1.1.3-py3-none-any.whl.
File metadata
- Download URL: sotis-1.1.3-py3-none-any.whl
- Upload date:
- Size: 59.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
199af171d685f540d56983ccc04c0c4b5359f9ba91f9fe3cf841d3eb778301c6
|
|
| MD5 |
dd32f86fe8474a4f815cd964f35c10cc
|
|
| BLAKE2b-256 |
6fa9af1fc273494cca6c91a3e3e41dcfb98ae9c8c5947fb93c19afa16ea610fb
|