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(codex): drop stale bootstrap turn state

cyhb5a78282fee3
diff --git a/modules/agents/codex/turn_state.py b/modules/agents/codex/turn_state.py
index b4b159b90..6b456fdae 100644
--- a/modules/agents/codex/turn_state.py
+++ b/modules/agents/codex/turn_state.py
@@ -72,6 +72,7 @@ class CodexTurnRegistry:
pending = self._pending_turn_starts.get(request.base_session_id)
if pending and pending.request is request:
if pending.turn_id and pending.turn_id != turn_id:
+ self.pop_turn(pending.turn_id)
self._pending_turn_starts.pop(request.base_session_id, None)
return self.register_turn(turn_id, request)
if pending.completed and pending.turn_id == turn_id:
diff --git a/tests/test_codex_turn_state.py b/tests/test_codex_turn_state.py
index 2bc1e3fa0..30731be83 100644
--- a/tests/test_codex_turn_state.py
+++ b/tests/test_codex_turn_state.py
@@ -56,3 +56,18 @@ def test_finalize_turn_start_response_prefers_response_turn_id_over_stale_pendin
assert registry.get_turn("turn-old") is None
assert registry.get_turn("turn-new") is state
assert registry.get_active_turn("session-1") == "turn-new"
+
+
+def test_finalize_turn_start_response_removes_old_bootstrapped_active_turn():
+ registry = CodexTurnRegistry()
+ request = SimpleNamespace(base_session_id="session-1")
+
+ registry.begin_turn_start(request, "thread-1")
+ registry.bootstrap_turn("turn-old", "session-1", "thread-1")
+
+ state = registry.finalize_turn_start_response("turn-new", request)
+
+ assert state is not None
+ assert registry.get_turn("turn-old") is None
+ assert registry.get_request_for_turn("turn-old") is None
+ assert registry.get_active_turn("session-1") == "turn-new"