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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(runs): support JSON fallback cancellation
cyh1ce4cc110d04
diff --git a/core/scheduled_tasks.py b/core/scheduled_tasks.pyindex 329c9a886..c6d75f2b9 100644--- a/core/scheduled_tasks.py+++ b/core/scheduled_tasks.py@@ -60,6 +60,8 @@ def _run_file_state_for_status(status: Optional[str]) -> Optional[str]:"succeeded": "completed","failed": "completed","completed": "completed",+ "canceled": "completed",+ "cancelled": "completed",}.get(status, status)@@ -75,7 +77,9 @@ def _normalize_requested_run_status(status: Optional[str]) -> Optional[str]:def _normalize_file_run_status(payload: dict[str, Any], state: str) -> str:raw_status = str(payload.get("status") or "").strip()- if raw_status in {"queued", "running", "succeeded", "failed", "cancelled"}:+ if raw_status in {"queued", "running", "succeeded", "failed", "canceled", "cancelled"}:+ if raw_status == "cancelled":+ return "canceled"return raw_statusif state == "pending":return "queued"@@ -816,6 +820,66 @@ class TaskExecutionStore:def cancel_run(self, run_id: str) -> bool:if self._sqlite is not None:return self._sqlite.cancel_run(run_id)+ now = _utc_now_iso()+ pending_path = self._request_path(run_id, state="pending")+ if pending_path.exists():+ try:+ payload = json.loads(pending_path.read_text(encoding="utf-8"))+ except Exception:+ payload = {"id": run_id}+ if not isinstance(payload, dict):+ payload = {"id": run_id}+ payload.update(+ {+ "id": run_id,+ "status": "canceled",+ "cancel_requested": True,+ "cancel_requested_at": now,+ "completed_at": now,+ "updated_at": now,+ }+ )+ completed_path = self._request_path(run_id, state="completed")+ with tempfile.NamedTemporaryFile(+ mode="w",+ dir=self.completed_dir,+ suffix=".tmp",+ delete=False,+ encoding="utf-8",+ ) as handle:+ json.dump(payload, handle, indent=2)+ tmp_path = Path(handle.name)+ tmp_path.replace(completed_path)+ pending_path.unlink(missing_ok=True)+ return True++ processing_path = self._request_path(run_id, state="processing")+ if processing_path.exists():+ try:+ payload = json.loads(processing_path.read_text(encoding="utf-8"))+ except Exception:+ payload = {"id": run_id}+ if not isinstance(payload, dict):+ payload = {"id": run_id}+ payload.update(+ {+ "id": run_id,+ "cancel_requested": True,+ "cancel_requested_at": now,+ "updated_at": now,+ }+ )+ with tempfile.NamedTemporaryFile(+ mode="w",+ dir=self.processing_dir,+ suffix=".tmp",+ delete=False,+ encoding="utf-8",+ ) as handle:+ json.dump(payload, handle, indent=2)+ tmp_path = Path(handle.name)+ tmp_path.replace(processing_path)+ return Truereturn Falsedef claim(self, request_id: str) -> Optional[TaskExecutionRequest]:diff --git a/tests/test_scheduled_tasks.py b/tests/test_scheduled_tasks.pyindex e5f4abc9e..ca466a652 100644--- a/tests/test_scheduled_tasks.py+++ b/tests/test_scheduled_tasks.py@@ -272,6 +272,45 @@ def test_sqlite_cancel_pending_run_marks_canceled(tmp_path: Path) -> None:assert store.claim(request.id) is None+def test_file_backend_cancel_pending_run_marks_canceled(tmp_path: Path) -> None:+ store = TaskExecutionStore(tmp_path / "task_requests")+ request = store.enqueue_agent_run(+ session_key="slack::channel::C123",+ message="hello",+ agent_name="default",+ )++ assert store.cancel_run(request.id) is True++ saved = store.get_run(request.id)+ assert saved is not None+ assert saved["status"] == "canceled"+ assert saved["cancel_requested"] is True+ assert [item["id"] for item in store.list_runs(status="canceled")] == [request.id]+ assert not (store.pending_dir / f"{request.id}.json").exists()+ assert (store.completed_dir / f"{request.id}.json").exists()+ assert store.claim(request.id) is None+++def test_file_backend_cancel_running_run_sets_cancel_requested(tmp_path: Path) -> None:+ store = TaskExecutionStore(tmp_path / "task_requests")+ request = store.enqueue_agent_run(+ session_key="slack::channel::C123",+ message="hello",+ agent_name="default",+ )+ claimed = store.claim(request.id)+ assert claimed is not None++ assert store.cancel_run(request.id) is True++ saved = store.get_run(request.id)+ assert saved is not None+ assert saved["status"] == "running"+ assert saved["cancel_requested"] is True+ assert (store.processing_dir / f"{request.id}.json").exists()++def test_store_round_trip_persists_task(tmp_path: Path) -> None:store = ScheduledTaskStore(tmp_path / "scheduled_tasks.json")task = store.add_task(