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
Codex Turn Lifecycle Refactor
Status: Completed
Background
modules/agents/codex/agent.py, modules/agents/codex/event_handler.py, and modules/agents/codex/session.py currently split Codex turn lifecycle state across several structures:
- thread/session state in
CodexSessionManager - active request tracking in
CodexAgent - turn-to-request routing in
CodexAgent - pending assistant content in
CodexEventHandler - terminal error state in
CodexEventHandler
This has led to repeated race-condition fixes around follow-up messages, interrupts, stale turn notifications, and duplicated or missing terminal outcomes.
Goal
Introduce a single Codex turn lifecycle layer that:
- owns turn-scoped request routing and per-turn state,
- makes notification delivery rules explicit instead of scattered across handlers,
- keeps thread/session persistence logic separate from in-memory turn lifecycle,
- and reflects the current product preference for stale turns:
- stale or interrupted turn errors should be logged, not shown to the user,
- visible message types should still flow through the existing dispatcher rules,
- and current-turn behavior should remain unchanged.
Solution
- Add a dedicated in-memory turn registry for Codex turn lifecycle state.
- Move active-turn ownership, originating request mapping, pending assistant buffers, and terminal error bookkeeping into that registry.
- Reduce
CodexSessionManagerback to persisted/session-level concerns (thread IDs and settings scope). - Update
CodexAgentnotification routing to resolve turn-scoped notifications from the registry first. - Update
CodexEventHandlerto use registry-backed state and centralized delivery policy helpers rather than ad-hoc dictionaries. - Keep stale/interrupted turn terminal errors as logs only; do not emit them into the conversation.
- Add focused tests for routing, lifecycle cleanup, and stale-turn policy.
Todo
- Inspect the current Codex routing and lifecycle code paths.
- Define the target product behavior for stale turns.
- Implement a dedicated turn lifecycle registry.
- Refactor agent/event handler/session manager to use the registry.
- Add regression tests and run focused validation.