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(watch): honor timeout retry exit codes

cyhb5158c43bea9
diff --git a/core/watches.py b/core/watches.py
index 687b7c116..1025ccdc2 100644
--- a/core/watches.py
+++ b/core/watches.py
@@ -437,6 +437,10 @@ class ManagedWatchService:
if result.timed_out or result.exit_code == 124:
error_text = "timed out"
+ if watch.mode == "forever" and 124 in set(watch.retry_exit_codes):
+ self.store.mark_cycle_result(watch.id, exit_code=124, error=error_text, disable=False)
+ await asyncio.sleep(watch.retry_delay_seconds)
+ continue
self._enqueue_failure_hook(
watch,
exit_code=124,
diff --git a/tests/test_watches.py b/tests/test_watches.py
index 8eed1b5f4..c27de137a 100644
--- a/tests/test_watches.py
+++ b/tests/test_watches.py
@@ -165,6 +165,46 @@ def test_managed_watch_service_forever_timeout_disables_and_enqueues_failure(tmp
assert saved.last_exit_code == 124
+def test_managed_watch_service_forever_timeout_retries_when_explicitly_allowed(tmp_path: Path) -> None:
+ store = ManagedWatchStore(tmp_path / "watches.json")
+ request_store = TaskExecutionStore(tmp_path / "task_requests")
+ runtime_store = WatchRuntimeStateStore(tmp_path / "watch_runtime.json")
+ watch = store.add_watch(
+ name="Retry timeout forever",
+ session_key="slack::channel::C123",
+ command=["python3", "-c", "import time; time.sleep(0.2)"],
+ shell_command=None,
+ prefix="Should keep waiting.",
+ cwd=None,
+ mode="forever",
+ timeout_seconds=0.05,
+ lifetime_timeout_seconds=0,
+ retry_exit_codes=[75, 124],
+ retry_delay_seconds=0.01,
+ post_to=None,
+ deliver_key=None,
+ )
+ service = ManagedWatchService(
+ controller=SimpleNamespace(),
+ store=store,
+ request_store=request_store,
+ runtime_store=runtime_store,
+ )
+
+ async def _run() -> None:
+ service.start()
+ await asyncio.sleep(0.2)
+ await service.stop()
+
+ asyncio.run(_run())
+
+ saved = store.get_watch(watch.id)
+ assert saved is not None
+ assert saved.enabled is True
+ assert saved.last_exit_code == 124
+ assert request_store.list_pending() == []
+
+
def test_managed_watch_service_stop_terminates_running_waiter(tmp_path: Path) -> None:
store = ManagedWatchStore(tmp_path / "watches.json")
request_store = TaskExecutionStore(tmp_path / "task_requests")
@@ -304,7 +344,7 @@ def test_managed_watch_service_forever_retries_only_allowed_exit_code(tmp_path:
watch = store.add_watch(
name="Retry waiter",
session_key="slack::channel::C123",
- command=["/bin/sh", "-lc", "exit 75"],
+ command=[sys.executable, "-c", "import sys; sys.exit(75)"],
shell_command=None,
prefix="Retry only.",
cwd=None,