Skip to main content

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.

PyPI version Python 3.10+ License: MIT Architecture Usage

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)

Reliability Decay

Context distillation: token reduction after meltdown reset (measured with tiktoken BPE cl100k_base)

Token Reduction

Real agent experiments — meltdown intercepts and outcomes (Gemini 3.5 · Groq Llama 70B · Mistral local · OpenRouter Gemini)

Real Experiments


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

sotis-1.1.2.tar.gz (54.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sotis-1.1.2-py3-none-any.whl (59.0 kB view details)

Uploaded Python 3

File details

Details for the file sotis-1.1.2.tar.gz.

File metadata

  • Download URL: sotis-1.1.2.tar.gz
  • Upload date:
  • Size: 54.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for sotis-1.1.2.tar.gz
Algorithm Hash digest
SHA256 6fad472385f75ad6b4c26a6ca0acc712ce57f92dbd5dbe7c641b8a7700dd7b5c
MD5 09ce15d8818fd987f7793ce1a1bccece
BLAKE2b-256 d5a8c14759c6c7c261f3c7e481b2475b51d4b0d1a0732f5ca6e781c9ec022c9c

See more details on using hashes here.

File details

Details for the file sotis-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: sotis-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 59.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for sotis-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d7604677c0e6703c922d0370f195e3527eb743c4aa8b049facbb909ca85c6031
MD5 b222cfbc6e4dcf3f825db328ead85eac
BLAKE2b-256 ae8237e10fd07fc521c2b6e48b3927fdee7ee0cf21b08f85081c9eba46425267

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page