Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(tasks): treat completed requests as terminal

cyh79bd52807ef3
diff --git a/core/scheduled_tasks.py b/core/scheduled_tasks.py
index 1dc7c3624..536ff83c4 100644
--- a/core/scheduled_tasks.py
+++ b/core/scheduled_tasks.py
@@ -301,9 +301,13 @@ class TaskExecutionStore:
self._ensure_dirs()
for path in self.processing_dir.glob("*.json"):
pending_path = self.pending_dir / path.name
+ completed_path = self.completed_dir / path.name
if pending_path.exists():
path.unlink(missing_ok=True)
continue
+ if completed_path.exists():
+ path.unlink(missing_ok=True)
+ continue
path.replace(pending_path)
def enqueue(self, request: TaskExecutionRequest) -> TaskExecutionRequest:
diff --git a/tests/test_scheduled_tasks.py b/tests/test_scheduled_tasks.py
index 90e759bd4..c5ed6f546 100644
--- a/tests/test_scheduled_tasks.py
+++ b/tests/test_scheduled_tasks.py
@@ -273,6 +273,24 @@ def test_request_store_constructor_does_not_requeue_processing_files(tmp_path: P
assert (producer_view.processing_dir / f"{request.id}.json").exists()
+def test_recover_processing_drops_completed_requests(tmp_path: Path) -> None:
+ root = tmp_path / "task_requests"
+ store = TaskExecutionStore(root)
+ request = store.enqueue_hook_send(session_key="slack::channel::C123", prompt="hello")
+ claimed = store.claim(request.id)
+
+ assert claimed is not None
+ store.complete(claimed, ok=True, session_key="slack::channel::C123")
+ stale_processing = store.processing_dir / f"{request.id}.json"
+ stale_processing.write_text(json.dumps(claimed.to_dict(), indent=2), encoding="utf-8")
+
+ store.recover_processing()
+
+ assert (store.completed_dir / f"{request.id}.json").exists()
+ assert not stale_processing.exists()
+ assert not (store.pending_dir / f"{request.id}.json").exists()
+
+
def test_drain_requests_executes_hook_send(tmp_path: Path) -> None:
request_store = TaskExecutionStore(tmp_path / "task_requests")
request = request_store.enqueue_hook_send(session_key="slack::channel::C123", prompt="ship it")