Stabilize task execution and UI lifecycle

This commit is contained in:
somew1nd committed 2026-08-19 00:47:45 -07:00
1 parent c78c201e94
commit 4927c4f0b9
35 files changed
+6680 -239

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
from artemis.services import llm
class _RecordingEngine:
current_step_id = "step-7"
def __init__(self):
self.trace_kwargs = None
self.published = None
def record_trace(self, **kwargs):
self.trace_kwargs = kwargs
def _publish(self, event_type, payload):
self.published = (event_type, payload)
def test_pause_error_is_persisted_and_published(monkeypatch, tmp_path):
engine = _RecordingEngine()
monkeypatch.setattr(llm, "_CURRENT_DATA_ENGINE", engine)
monkeypatch.setattr(llm.settings, "TRACES_PATH", str(tmp_path / "traces"))
pause_file = llm._handle_llm_pause_and_resume(RuntimeError("503 high demand"))
assert pause_file.read_text() == "LLM Error: 503 high demand"
assert engine.trace_kwargs == {
"type": "llm_call",
"name": "llm_pause",
"payload": {"error": "503 high demand", "pause": True},
"step_id": "step-7",
"status": "failed",
}
event_type, payload = engine.published
assert event_type == "task_paused"
assert payload["error"] == "503 high demand"
assert payload["step_id"] == "step-7"
assert isinstance(payload["timestamp"], float)