sotis 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. sotis-1.0.1/PKG-INFO +180 -0
  2. sotis-1.0.1/README.md +156 -0
  3. sotis-1.0.1/pyproject.toml +38 -0
  4. sotis-1.0.1/setup.cfg +4 -0
  5. sotis-1.0.1/sotis/__init__.py +101 -0
  6. sotis-1.0.1/sotis/bench/runner.py +285 -0
  7. sotis-1.0.1/sotis/bench/tasks.py +117 -0
  8. sotis-1.0.1/sotis/core/__init__.py +59 -0
  9. sotis-1.0.1/sotis/core/checkpoint.py +427 -0
  10. sotis-1.0.1/sotis/core/decomposition.py +193 -0
  11. sotis-1.0.1/sotis/core/entropy.py +324 -0
  12. sotis-1.0.1/sotis/core/gds.py +49 -0
  13. sotis-1.0.1/sotis/core/loops.py +366 -0
  14. sotis-1.0.1/sotis/core/reset.py +358 -0
  15. sotis-1.0.1/sotis/core/schemas.py +230 -0
  16. sotis-1.0.1/sotis/lib/__init__.py +7 -0
  17. sotis-1.0.1/sotis/lib/adapters.py +464 -0
  18. sotis-1.0.1/sotis/lib/langgraph_integration.py +339 -0
  19. sotis-1.0.1/sotis/lib/runtime.py +408 -0
  20. sotis-1.0.1/sotis/obs/app.py +494 -0
  21. sotis-1.0.1/sotis/obs/logger.py +58 -0
  22. sotis-1.0.1/sotis.egg-info/PKG-INFO +180 -0
  23. sotis-1.0.1/sotis.egg-info/SOURCES.txt +33 -0
  24. sotis-1.0.1/sotis.egg-info/dependency_links.txt +1 -0
  25. sotis-1.0.1/sotis.egg-info/requires.txt +20 -0
  26. sotis-1.0.1/sotis.egg-info/top_level.txt +1 -0
  27. sotis-1.0.1/tests/test_benchmark.py +137 -0
  28. sotis-1.0.1/tests/test_checkpoint.py +245 -0
  29. sotis-1.0.1/tests/test_context_reset.py +254 -0
  30. sotis-1.0.1/tests/test_core_entropy.py +428 -0
  31. sotis-1.0.1/tests/test_core_loops.py +488 -0
  32. sotis-1.0.1/tests/test_decomposer.py +223 -0
  33. sotis-1.0.1/tests/test_live_langgraph.py +119 -0
  34. sotis-1.0.1/tests/test_runtime.py +328 -0
  35. sotis-1.0.1/tests/test_sotis_guard.py +44 -0
sotis-1.0.1/PKG-INFO ADDED
@@ -0,0 +1,180 @@
1
+ Metadata-Version: 2.4
2
+ Name: sotis
3
+ Version: 1.0.1
4
+ Summary: Python reliability library for long-running LLM agents
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: numpy>=1.26.0
8
+ Requires-Dist: pydantic>=2.6.0
9
+ Requires-Dist: python-dateutil>=2.9.0
10
+ Requires-Dist: openai>=1.25.0
11
+ Requires-Dist: anthropic>=0.25.0
12
+ Requires-Dist: rich>=13.7.0
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest>=8.2.0; extra == "dev"
15
+ Requires-Dist: pytest-benchmark>=4.0.0; extra == "dev"
16
+ Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
17
+ Requires-Dist: langchain>=0.2.0; extra == "dev"
18
+ Requires-Dist: langgraph>=0.0.60; extra == "dev"
19
+ Provides-Extra: langgraph
20
+ Requires-Dist: langchain>=0.2.0; extra == "langgraph"
21
+ Requires-Dist: langgraph>=0.0.60; extra == "langgraph"
22
+ Provides-Extra: obs
23
+ Requires-Dist: streamlit>=1.35.0; extra == "obs"
24
+
25
+ # Sotis
26
+
27
+ Sotis is a Python reliability library for long-running LLM agents that detects meltdown behavior and automatically resets execution before agents spiral into loops or context collapse.
28
+
29
+ ---
30
+
31
+ ## The Long-Horizon Failure Problem
32
+
33
+ Current AI agents fail predictably under long-horizon execution. As they run for longer periods, they accumulate error and drift into terminal failure modes:
34
+
35
+ * **Infinite Loops**: Repeating the same tool calls with identical arguments.
36
+ * **Semantic Spirals**: Rephrasing failed queries or tool calls hoping for different outcomes.
37
+ * **Context Poisoning**: Flooding the chat history with massive error traces and linter warnings.
38
+ * **Edit Storms**: Making rapid, uncoordinated file edits without shifting validation outputs.
39
+
40
+ Frontier models do not fail because they are simple, but because long-horizon execution decays their reliability envelope until strategy collapse occurs. Sotis acts as an active runtime stabilizer, monitoring execution in real time, detecting behavioral meltdowns, and transparently resetting context to restore forward progress.
41
+
42
+ ---
43
+
44
+ ## Active Execution Recovery in 3 sets of Lines
45
+
46
+ Unlike passive tracing systems, Sotis operates actively. It intercepts spiraling tool calls, restores files to the last stable checkpoint, compresses history, and injects a resumption briefing.
47
+
48
+ ```python
49
+ from sotis import SotisGuard
50
+
51
+ # 1. Initialize the reliability guard
52
+ guard = SotisGuard()
53
+
54
+ # 2. Watch tool execution events in your agent's loop
55
+ for step in range(max_steps):
56
+ action = agent.decide()
57
+ result = tools.execute(action)
58
+
59
+ meltdown = guard.watch(action.name, action.args, result.summary)
60
+
61
+ # 3. Intercept and recover automatically
62
+ if meltdown:
63
+ print("Sotis blocked an execution loop! Restoring stable baseline...")
64
+ guard.reset()
65
+ ```
66
+
67
+ ### Raw Telemetry Trace
68
+
69
+ Here is how Sotis stabilizes execution in real time:
70
+
71
+ ```text
72
+ [Step 22] write_file -> {"path": "src/main.py", "content": "import math"} | Outcome: SUCCESS
73
+ [Step 23] run_tests -> {"cmd": "pytest"} | Outcome: FAIL (ImportError)
74
+ [Step 24] write_file -> {"path": "src/main.py", "content": "import math"} | Outcome: SUCCESS
75
+ [Step 25] run_tests -> {"cmd": "pytest"} | Outcome: FAIL (ImportError)
76
+
77
+ [WARNING] Anomaly detected: Workspace edit storm and exact argument loops
78
+ [INTERCEPT] Sotis Meltdown Interception Triggered!
79
+ [RECOVER] Restored workspace files to stable baseline step 22 diff
80
+ [RECOVER] Distilled session context history (78% token savings)
81
+ [RESUME] Injecting resumption briefing prompt into agent context...
82
+
83
+ [Step 26] grep_search -> {"query": "math"} | Execution resumed cleanly
84
+ ```
85
+
86
+ ---
87
+
88
+ ## Visual Execution Flow
89
+
90
+ ```
91
+ Agent Begins Task
92
+ |
93
+ v
94
+ Execution Step Loop
95
+ |
96
+ v
97
+ Entropy Rises / Loops Detected (Step 20)
98
+ |
99
+ v
100
+ Sotis Intercepts Meltdown (Step 25)
101
+ |
102
+ v
103
+ Workspace Rolled Back and Context Distilled (>= 60% Token Savings)
104
+ |
105
+ v
106
+ Resumption Briefing Injected
107
+ |
108
+ v
109
+ Execution Resumes Cleanly to Completion
110
+ ```
111
+
112
+ ---
113
+
114
+ ## The Science: Research-Inspired Reliability
115
+
116
+ Sotis operationalizes the formal reliability engineering framework introduced in the April 2026 paper:
117
+ *["Beyond pass@1: A Reliability Science Framework for Long-Horizon LLM Agents"](https://arxiv.org/abs/2603.29231)* (arXiv:2603.29231)
118
+
119
+ We translate key theoretical concepts from this paper directly into active runtime layers:
120
+
121
+ * **Meltdown Onset Point (MOP)**: Quantifies the transition from coherent planning to chaotic looping. Sotis monitors the Shannon entropy of the tool-call distribution over a sliding window (size w=5). A spike in entropy or a tight repeating sequence triggers an immediate Meltdown Onset Point flag.
122
+ * **Reliability Decay**: Demonstrates that agent success rates decay super-linearly with task duration due to positively correlated errors (a confused agent stays confused). Sotis acts as a runtime circuit breaker to reset the error correlation coefficient.
123
+ * **Episodic Memory Failures**: The paper proves that naive episodic memory scaffolds universally degrade long-horizon performance by accumulating step budget and context overhead. Sotis maintains reliability through **controlled checkpointed resets** rather than continuous memory accumulation.
124
+ * **Graceful Degradation Score (GDS)**: Evaluates agent trajectories using weighted directed acyclic graphs of subtask completion. When a meltdown is intercepted, Sotis scores partial progress and resets execution context, allowing agents to preserve partial GDS while starting fresh.
125
+
126
+ ---
127
+
128
+ ## Strongest Differentiator: Active Stabilization vs Passive Tracing
129
+
130
+ Passive AI developer tooling (such as LangSmith, Langfuse, or Helicone) merely monitors failure, logging tokens and rendering traces *after* your agent has already spent $20 looping in production.
131
+
132
+ Sotis is closer to **runtime reliability middleware**. It does not merely observe agent degradation—it actively intercepts loops, rolls back uncommitted file edits, distills conversation context, and redirects the model's reasoning loop in real time.
133
+
134
+ ---
135
+
136
+ ## Project Structure
137
+
138
+ ```
139
+ Sotis/
140
+ sotis/
141
+ core/ # Pure computation: entropy, loops, checkpoint, decomposition, GDS
142
+ lib/ # ReAct runtime, LangGraph integration + LLM adapters
143
+ obs/ # Telemetry app + structured JSON logger
144
+ bench/ # Benchmark harness and task generators
145
+ tests/ # High-coverage automated test suite (127 tests)
146
+ ExperimentLog/ # Real-agent Track 2 stress test run logs
147
+ performance_metrics.txt # Empirical proof-of-performance ledger
148
+ pyproject.toml # Package configuration
149
+ requirements.txt # Core dependencies
150
+ pytest.ini # Testing settings
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Build Phases
156
+
157
+ All phases of the project have been built, rigorously tested, and successfully finalized:
158
+
159
+ | Phase | Focus | Status |
160
+ |---|---|---|
161
+ | **1** | Core Engine: Schemas, Shannon Entropy, Loop Detection | COMPLETED |
162
+ | **2** | Checkpoint, Context Reset and Resumption | COMPLETED |
163
+ | **3** | Task Decomposition and GDS Scorer | COMPLETED |
164
+ | **4** | Telemetry, Streamlit Dashboard and Benchmark Harness | COMPLETED |
165
+ | **5** | LangGraph Node Middleware Integration and Packaging | COMPLETED |
166
+ | **6** | Workspace Density Guard and AST Query Engine Stress Testing | COMPLETED |
167
+ | **7** | Streamlit Dashboard Polish and Interactive Log Viewer | COMPLETED |
168
+ | **8** | Three-Line Developer Facade API and End-to-End Validation | COMPLETED |
169
+ | **9** | GitHub Release Preparation and Packaging Metadata | COMPLETED |
170
+ | **10** | Live Web Research Stress Test and Crawler Tools | COMPLETED |
171
+ | **11** | Document Handling and Jaccard Semantic Loops (PDF, Excel, Word, CSV) | COMPLETED |
172
+
173
+ ---
174
+
175
+ ## Performance Metrics
176
+
177
+ See [`performance_metrics.txt`](https://github.com/Shaurya-34/Sotis/blob/main/performance_metrics.txt) — a real-time updated ledger tracking empirical outcomes across all phases showing:
178
+ - **Entropy and Loop Detection Latency**: < 0.2ms overhead per step.
179
+ - **Context Distillation Reduction**: **86.14%** token savings in the resumption briefing.
180
+ - **Resilience Gains**: Real-world recovery on circular imports and AST recursive loop traps.
sotis-1.0.1/README.md ADDED
@@ -0,0 +1,156 @@
1
+ # Sotis
2
+
3
+ Sotis is a Python reliability library for long-running LLM agents that detects meltdown behavior and automatically resets execution before agents spiral into loops or context collapse.
4
+
5
+ ---
6
+
7
+ ## The Long-Horizon Failure Problem
8
+
9
+ Current AI agents fail predictably under long-horizon execution. As they run for longer periods, they accumulate error and drift into terminal failure modes:
10
+
11
+ * **Infinite Loops**: Repeating the same tool calls with identical arguments.
12
+ * **Semantic Spirals**: Rephrasing failed queries or tool calls hoping for different outcomes.
13
+ * **Context Poisoning**: Flooding the chat history with massive error traces and linter warnings.
14
+ * **Edit Storms**: Making rapid, uncoordinated file edits without shifting validation outputs.
15
+
16
+ Frontier models do not fail because they are simple, but because long-horizon execution decays their reliability envelope until strategy collapse occurs. Sotis acts as an active runtime stabilizer, monitoring execution in real time, detecting behavioral meltdowns, and transparently resetting context to restore forward progress.
17
+
18
+ ---
19
+
20
+ ## Active Execution Recovery in 3 sets of Lines
21
+
22
+ Unlike passive tracing systems, Sotis operates actively. It intercepts spiraling tool calls, restores files to the last stable checkpoint, compresses history, and injects a resumption briefing.
23
+
24
+ ```python
25
+ from sotis import SotisGuard
26
+
27
+ # 1. Initialize the reliability guard
28
+ guard = SotisGuard()
29
+
30
+ # 2. Watch tool execution events in your agent's loop
31
+ for step in range(max_steps):
32
+ action = agent.decide()
33
+ result = tools.execute(action)
34
+
35
+ meltdown = guard.watch(action.name, action.args, result.summary)
36
+
37
+ # 3. Intercept and recover automatically
38
+ if meltdown:
39
+ print("Sotis blocked an execution loop! Restoring stable baseline...")
40
+ guard.reset()
41
+ ```
42
+
43
+ ### Raw Telemetry Trace
44
+
45
+ Here is how Sotis stabilizes execution in real time:
46
+
47
+ ```text
48
+ [Step 22] write_file -> {"path": "src/main.py", "content": "import math"} | Outcome: SUCCESS
49
+ [Step 23] run_tests -> {"cmd": "pytest"} | Outcome: FAIL (ImportError)
50
+ [Step 24] write_file -> {"path": "src/main.py", "content": "import math"} | Outcome: SUCCESS
51
+ [Step 25] run_tests -> {"cmd": "pytest"} | Outcome: FAIL (ImportError)
52
+
53
+ [WARNING] Anomaly detected: Workspace edit storm and exact argument loops
54
+ [INTERCEPT] Sotis Meltdown Interception Triggered!
55
+ [RECOVER] Restored workspace files to stable baseline step 22 diff
56
+ [RECOVER] Distilled session context history (78% token savings)
57
+ [RESUME] Injecting resumption briefing prompt into agent context...
58
+
59
+ [Step 26] grep_search -> {"query": "math"} | Execution resumed cleanly
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Visual Execution Flow
65
+
66
+ ```
67
+ Agent Begins Task
68
+ |
69
+ v
70
+ Execution Step Loop
71
+ |
72
+ v
73
+ Entropy Rises / Loops Detected (Step 20)
74
+ |
75
+ v
76
+ Sotis Intercepts Meltdown (Step 25)
77
+ |
78
+ v
79
+ Workspace Rolled Back and Context Distilled (>= 60% Token Savings)
80
+ |
81
+ v
82
+ Resumption Briefing Injected
83
+ |
84
+ v
85
+ Execution Resumes Cleanly to Completion
86
+ ```
87
+
88
+ ---
89
+
90
+ ## The Science: Research-Inspired Reliability
91
+
92
+ Sotis operationalizes the formal reliability engineering framework introduced in the April 2026 paper:
93
+ *["Beyond pass@1: A Reliability Science Framework for Long-Horizon LLM Agents"](https://arxiv.org/abs/2603.29231)* (arXiv:2603.29231)
94
+
95
+ We translate key theoretical concepts from this paper directly into active runtime layers:
96
+
97
+ * **Meltdown Onset Point (MOP)**: Quantifies the transition from coherent planning to chaotic looping. Sotis monitors the Shannon entropy of the tool-call distribution over a sliding window (size w=5). A spike in entropy or a tight repeating sequence triggers an immediate Meltdown Onset Point flag.
98
+ * **Reliability Decay**: Demonstrates that agent success rates decay super-linearly with task duration due to positively correlated errors (a confused agent stays confused). Sotis acts as a runtime circuit breaker to reset the error correlation coefficient.
99
+ * **Episodic Memory Failures**: The paper proves that naive episodic memory scaffolds universally degrade long-horizon performance by accumulating step budget and context overhead. Sotis maintains reliability through **controlled checkpointed resets** rather than continuous memory accumulation.
100
+ * **Graceful Degradation Score (GDS)**: Evaluates agent trajectories using weighted directed acyclic graphs of subtask completion. When a meltdown is intercepted, Sotis scores partial progress and resets execution context, allowing agents to preserve partial GDS while starting fresh.
101
+
102
+ ---
103
+
104
+ ## Strongest Differentiator: Active Stabilization vs Passive Tracing
105
+
106
+ Passive AI developer tooling (such as LangSmith, Langfuse, or Helicone) merely monitors failure, logging tokens and rendering traces *after* your agent has already spent $20 looping in production.
107
+
108
+ Sotis is closer to **runtime reliability middleware**. It does not merely observe agent degradation—it actively intercepts loops, rolls back uncommitted file edits, distills conversation context, and redirects the model's reasoning loop in real time.
109
+
110
+ ---
111
+
112
+ ## Project Structure
113
+
114
+ ```
115
+ Sotis/
116
+ sotis/
117
+ core/ # Pure computation: entropy, loops, checkpoint, decomposition, GDS
118
+ lib/ # ReAct runtime, LangGraph integration + LLM adapters
119
+ obs/ # Telemetry app + structured JSON logger
120
+ bench/ # Benchmark harness and task generators
121
+ tests/ # High-coverage automated test suite (127 tests)
122
+ ExperimentLog/ # Real-agent Track 2 stress test run logs
123
+ performance_metrics.txt # Empirical proof-of-performance ledger
124
+ pyproject.toml # Package configuration
125
+ requirements.txt # Core dependencies
126
+ pytest.ini # Testing settings
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Build Phases
132
+
133
+ All phases of the project have been built, rigorously tested, and successfully finalized:
134
+
135
+ | Phase | Focus | Status |
136
+ |---|---|---|
137
+ | **1** | Core Engine: Schemas, Shannon Entropy, Loop Detection | COMPLETED |
138
+ | **2** | Checkpoint, Context Reset and Resumption | COMPLETED |
139
+ | **3** | Task Decomposition and GDS Scorer | COMPLETED |
140
+ | **4** | Telemetry, Streamlit Dashboard and Benchmark Harness | COMPLETED |
141
+ | **5** | LangGraph Node Middleware Integration and Packaging | COMPLETED |
142
+ | **6** | Workspace Density Guard and AST Query Engine Stress Testing | COMPLETED |
143
+ | **7** | Streamlit Dashboard Polish and Interactive Log Viewer | COMPLETED |
144
+ | **8** | Three-Line Developer Facade API and End-to-End Validation | COMPLETED |
145
+ | **9** | GitHub Release Preparation and Packaging Metadata | COMPLETED |
146
+ | **10** | Live Web Research Stress Test and Crawler Tools | COMPLETED |
147
+ | **11** | Document Handling and Jaccard Semantic Loops (PDF, Excel, Word, CSV) | COMPLETED |
148
+
149
+ ---
150
+
151
+ ## Performance Metrics
152
+
153
+ See [`performance_metrics.txt`](https://github.com/Shaurya-34/Sotis/blob/main/performance_metrics.txt) — a real-time updated ledger tracking empirical outcomes across all phases showing:
154
+ - **Entropy and Loop Detection Latency**: < 0.2ms overhead per step.
155
+ - **Context Distillation Reduction**: **86.14%** token savings in the resumption briefing.
156
+ - **Resilience Gains**: Real-world recovery on circular imports and AST recursive loop traps.
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sotis"
7
+ version = "1.0.1"
8
+ description = "Python reliability library for long-running LLM agents"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "numpy>=1.26.0",
13
+ "pydantic>=2.6.0",
14
+ "python-dateutil>=2.9.0",
15
+ "openai>=1.25.0",
16
+ "anthropic>=0.25.0",
17
+ "rich>=13.7.0"
18
+ ]
19
+
20
+ [project.optional-dependencies]
21
+ dev = [
22
+ "pytest>=8.2.0",
23
+ "pytest-benchmark>=4.0.0",
24
+ "pytest-cov>=5.0.0",
25
+ "langchain>=0.2.0",
26
+ "langgraph>=0.0.60"
27
+ ]
28
+ langgraph = [
29
+ "langchain>=0.2.0",
30
+ "langgraph>=0.0.60"
31
+ ]
32
+ obs = [
33
+ "streamlit>=1.35.0"
34
+ ]
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["."]
38
+ include = ["sotis*"]
sotis-1.0.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,101 @@
1
+ """
2
+ Sotis — MOP-Triggered Context Reset Agent
3
+ ==========================================
4
+ Reliability middleware that monitors long-horizon LLM agent sessions,
5
+ detects meltdowns via sliding-window Shannon entropy analysis, and
6
+ transparently resets context to restore forward progress.
7
+
8
+ Based on: "Beyond pass@1: A Reliability Science Framework for
9
+ Long-Horizon LLM Agents" (arXiv:2603.29231v1)
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ from typing import Any, Dict, Optional, Union
15
+
16
+ from sotis.core.schemas import StepEvent, MeltdownSignal, Domain, MeltdownReason
17
+ from sotis.core.entropy import SessionEntropyTracker, EntropyConfig
18
+ from sotis.core.loops import SessionLoopTracker, LoopConfig, WorkspaceDensityGuard
19
+
20
+ __version__ = "0.1.0"
21
+ __author__ = "Sotis Contributors"
22
+
23
+
24
+ class SotisGuard:
25
+ """
26
+ SotisGuard
27
+ ==========
28
+ High-level user-facing developer facade designed to watch agent trajectories
29
+ and detect meltdown conditions in 3 lines of code.
30
+
31
+ Usage:
32
+ ------
33
+ >>> from sotis import SotisGuard
34
+ >>> guard = SotisGuard()
35
+ >>> meltdown = guard.watch("write_file", {"file_path": "app.py"}, "Written successfully")
36
+ """
37
+
38
+ def __init__(
39
+ self,
40
+ entropy_config: Optional[EntropyConfig] = None,
41
+ loop_config: Optional[LoopConfig] = None,
42
+ max_consecutive_edits: int = 3,
43
+ ) -> None:
44
+ self.entropy_tracker = SessionEntropyTracker(entropy_config)
45
+ self.loop_tracker = SessionLoopTracker(loop_config)
46
+ self.density_guard = WorkspaceDensityGuard(max_consecutive_edits)
47
+ self._step_counter = 0
48
+
49
+ def watch(
50
+ self,
51
+ tool_name: Union[str, StepEvent],
52
+ tool_args: Optional[Dict[str, Any]] = None,
53
+ result_summary: Optional[str] = None,
54
+ subtask_id: Optional[str] = None,
55
+ ) -> bool:
56
+ """
57
+ Record a step event and evaluate it for meltdown patterns.
58
+
59
+ Returns True if a tool-loop, high-entropy, or edit-density meltdown is triggered.
60
+ """
61
+ if isinstance(tool_name, StepEvent):
62
+ event = tool_name
63
+ else:
64
+ event = StepEvent(
65
+ step_index=self._step_counter,
66
+ tool_name=tool_name,
67
+ tool_args=tool_args or {},
68
+ result_summary=result_summary,
69
+ subtask_id=subtask_id,
70
+ )
71
+ self._step_counter += 1
72
+
73
+ # Push to all three monitors
74
+ entropy_res = self.entropy_tracker.push_event(event)
75
+ loop_res = self.loop_tracker.push_event(event)
76
+ density_res = self.density_guard.push_event(event)
77
+
78
+ # Returns True if any meltdown is triggered
79
+ return (
80
+ entropy_res.meltdown_detected or
81
+ loop_res.meltdown_detected or
82
+ density_res
83
+ )
84
+
85
+ def reset(self) -> None:
86
+ """Resets the state of all monitors."""
87
+ self.entropy_tracker.reset()
88
+ self.loop_tracker.reset()
89
+ self.density_guard.reset()
90
+ self._step_counter = 0
91
+
92
+
93
+ __all__ = [
94
+ "SotisGuard",
95
+ "StepEvent",
96
+ "MeltdownSignal",
97
+ "Domain",
98
+ "MeltdownReason",
99
+ "EntropyConfig",
100
+ "LoopConfig",
101
+ ]