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(workbench): round-20 Codex P2 — durable recovery text (centralized) + dispatch-failure row promotion
cyh459d7129f55f
diff --git a/core/agent_auth_service.py b/core/agent_auth_service.pyindex f7ad4dccb..2744adac5 100644--- a/core/agent_auth_service.py+++ b/core/agent_auth_service.py@@ -751,12 +751,25 @@ class AgentAuthService:if not classify_auth_error(backend, error_text):return False+ recovery_text = f"{error_text}\n\n{self._t('command.setup.resetPrompt', backend=backend)}"await self._send_message_with_button(context,- f"{error_text}\n\n{self._t('command.setup.resetPrompt', backend=backend)}",+ recovery_text,button_text=self._t("button.resetOAuth"),callback_data=f"auth_setup:{backend}",)+ # The IM send above goes through ``send_message_with_buttons``, which is NOT+ # a durable ``messages`` row, and the web Chat renders only durable rows —+ # so persist the recovery text (error + reset instruction) HERE, the single+ # home for it, rather than each backend persisting an error-only copy that+ # drops the actionable reset prompt (Codex P2). No-op for contexts without+ # a resolvable scope (persist_agent_message guards internally).+ try:+ from core.message_mirror import persist_agent_message++ persist_agent_message(context, "notify", recovery_text)+ except Exception:+ logger.debug("auth recovery: failed to persist durable notify", exc_info=True)return Trueasync def _send_message(self, context: MessageContext, text: str) -> Optional[str]:diff --git a/modules/agents/claude_agent.py b/modules/agents/claude_agent.pyindex 079f1e482..4826b1297 100644--- a/modules/agents/claude_agent.py+++ b/modules/agents/claude_agent.py@@ -122,18 +122,18 @@ class ClaudeAgent(BaseAgent):)if not handled:await self.session_handler.handle_session_error(runtime_session_key, context, e)- # Persist a durable terminal notify in BOTH branches: the IM sends- # (handle_session_error / the auth-recovery reset-OAuth button via- # send_message_with_buttons) don't write to ``messages``, and the web- # Chat renders only durable ``message.new`` rows — so without this the- # avibe user sees their prompt stop with no explanation, including on- # an expired Claude login (Codex P2). Mirrors _stream_terminal_error.- try:- from core.message_mirror import persist_agent_message+ # ``handle_session_error`` sends through the IM client, which doesn't+ # write to ``messages``, and the web Chat renders only durable+ # ``message.new`` rows — so persist a terminal notify or the avibe+ # user's prompt stops with no explanation (Codex P2). The HANDLED+ # (auth) branch instead persists the full recovery text centrally in+ # ``maybe_emit_auth_recovery_message``.+ try:+ from core.message_mirror import persist_agent_message- persist_agent_message(context, "notify", f"❌ Claude error: {e}")- except Exception:- logger.debug("claude: failed to persist terminal error row", exc_info=True)+ persist_agent_message(context, "notify", f"❌ Claude error: {e}")+ except Exception:+ logger.debug("claude: failed to persist terminal error row", exc_info=True)# Synchronous failure (query/setup raised) — no async receiver# result is coming for this turn, so release the web-Chat stream# waiter now (token-guarded, no-op for IM/CLI) instead of waiting@@ -521,17 +521,11 @@ class ClaudeAgent(BaseAgent):# then ``_stream_chunk`` refuses to complete the live turn and Stop# sticks until the safety timeout (Codex P2).failed_request = self._pop_pending_request(composite_key)- # Release THIS failed turn's Chat stream too: the reset-OAuth prompt- # goes out over the IM client but isn't a durable ``messages`` row, so- # persist a terminal notify (otherwise the web Chat shows nothing) and- # mark the streaming turn complete under its own token.+ # Release THIS failed turn's Chat stream under its own token.+ # ``_handle_auth_failure_result`` already persisted the durable+ # recovery notify (error + reset prompt) centrally via+ # ``maybe_emit_auth_recovery_message``, so we don't persist here.self._adopt_pending_turn_token(context, failed_request)- try:- from core.message_mirror import persist_agent_message-- persist_agent_message(context, "notify", f"❌ Claude error: {result_text}")- except Exception:- logger.debug("claude: failed to persist auth-failure notify", exc_info=True)_mark = getattr(self.controller, "mark_turn_complete", None)if callable(_mark):_mark(context)diff --git a/modules/agents/codex/agent.py b/modules/agents/codex/agent.pyindex 5675c0476..23a9894b3 100644--- a/modules/agents/codex/agent.py+++ b/modules/agents/codex/agent.py@@ -190,19 +190,9 @@ class CodexAgent(BaseAgent):"notify",error_text,)- else:- # The reset-OAuth prompt went out over the IM client- # (``send_message_with_buttons``) but isn't a durable ``messages``- # row, and the web Chat renders only durable rows — so persist a- # terminal notify here too, or an expired Codex login stops the- # prompt with no on-screen explanation (Codex P2). The not-handled- # branch already persists via ``emit_agent_message``.- try:- from core.message_mirror import persist_agent_message-- persist_agent_message(request.context, "notify", error_text)- except Exception:- logger.debug("codex: failed to persist auth-recovery notify", exc_info=True)+ # handled == True persists the durable recovery notify centrally in+ # ``maybe_emit_auth_recovery_message``; the not-handled branch persists+ # via ``emit_agent_message`` above.await self._remove_ack_reaction(request)# The turn never started (all retries failed) — release the# web-Chat working/Stop state instead of leaving it until thediff --git a/modules/agents/codex/event_handler.py b/modules/agents/codex/event_handler.pyindex 2eb3bf470..486814e37 100644--- a/modules/agents/codex/event_handler.py+++ b/modules/agents/codex/event_handler.py@@ -165,19 +165,10 @@ class CodexEventHandler:"notify",message,)- else:- # The reset-OAuth prompt went out over the IM client- # (``send_message_with_buttons``) but isn't a durable ``messages``- # row, and the web Chat renders only durable ``message.new`` rows —- # so persist a terminal notify here too, or an expired Codex login- # stops the prompt with no on-screen explanation (Codex P2). The- # not-handled branch already persists via ``emit_agent_message``.- try:- from core.message_mirror import persist_agent_message-- persist_agent_message(tracked_request.context, "notify", message)- except Exception:- logger.debug("codex: failed to persist auth-recovery notify", exc_info=True)+ # handled == True persists the durable recovery notify centrally in+ # ``maybe_emit_auth_recovery_message`` (the auth service is the single+ # home for the reset-prompt text); the not-handled branch persists via+ # ``emit_agent_message`` above.error_was_user_visible = Trueelse:logger.info("Suppressing inactive Codex turn failure for %s: %s", turn_id, error_msg)diff --git a/modules/agents/opencode/agent.py b/modules/agents/opencode/agent.pyindex 30176f391..eecdb3127 100644--- a/modules/agents/opencode/agent.py+++ b/modules/agents/opencode/agent.py@@ -352,19 +352,9 @@ class OpenCodeAgent(OpenCodeMessageProcessorMixin, BaseAgent):"notify",message,)- else:- # The reset-OAuth prompt went out over the IM client- # (``send_message_with_buttons``) but isn't a durable ``messages``- # row, and the web Chat renders only durable rows — so persist a- # terminal notify here too, or an expired OpenCode/provider login- # ends the turn with no on-screen explanation (Codex P2). The- # not-handled branch already persists via ``emit_agent_message``.- try:- from core.message_mirror import persist_agent_message-- persist_agent_message(request.context, "notify", message)- except Exception:- logger.debug("opencode: failed to persist auth-recovery notify", exc_info=True)+ # handled == True persists the durable recovery notify centrally in+ # ``maybe_emit_auth_recovery_message``; the not-handled branch persists+ # via ``emit_agent_message`` above.finally:if run_registered:await server.mark_run_inactive(session_id)diff --git a/tests/test_agent_auth_service.py b/tests/test_agent_auth_service.pyindex 0df81cf2f..59c94cc8b 100644--- a/tests/test_agent_auth_service.py+++ b/tests/test_agent_auth_service.py@@ -144,17 +144,26 @@ class AgentAuthServiceTests(unittest.IsolatedAsyncioTestCase):service = AgentAuthService(controller)context = MessageContext(user_id="U1", channel_id="C1")- handled = await service.maybe_emit_auth_recovery_message(- context,- "codex",- "❌ Codex error: 401 Unauthorized",- )+ with patch("core.message_mirror.persist_agent_message") as persist:+ handled = await service.maybe_emit_auth_recovery_message(+ context,+ "codex",+ "❌ Codex error: 401 Unauthorized",+ )self.assertTrue(handled)self.assertEqual(len(controller.im_client.sent_button_messages), 1)_, text, keyboard = controller.im_client.sent_button_messages[0]self.assertIn("401 Unauthorized", text)self.assertEqual(keyboard.buttons[0][0].callback_data, "auth_setup:codex")+ # The recovery text is also persisted as a durable notify (the single home+ # for it) so the web Chat shows the error + reset instruction, not just the+ # transient button payload (Codex P2). Same composed text that was sent.+ persist.assert_called_once()+ persisted_ctx, persisted_kind, persisted_text = persist.call_args.args[:3]+ self.assertEqual(persisted_kind, "notify")+ self.assertEqual(persisted_text, text)+ self.assertIn("401 Unauthorized", persisted_text)async def test_handle_process_text_emits_codex_link_once_url_and_code_exist(self):controller = _StubController()diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex 41b99a171..a42a24966 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -3152,6 +3152,15 @@ async def sessions_messages_create(session_id: str):# user still sees their message, plus the failure.published = _promote_and_publish(message)return jsonify({**published, "dispatch_error": "internal_unavailable", "detail": str(exc)}), 502+ except Exception as exc:+ # The socket existed but the call failed another way (ReadTimeout, a+ # non-JSON / 500 response, etc.). The row is still reserved as hidden+ # ``pending`` and the draft was cleared, so WITHOUT this the user's text+ # would vanish from both transcript and queue behind an error. Promote ++ # publish it with the error, same as the unavailable branch (Codex P2).+ logger.warning("dispatch_async call failed for session %s: %s", session_id, exc, exc_info=True)+ published = _promote_and_publish(message)+ return jsonify({**published, "dispatch_error": "dispatch_failed", "detail": str(exc)}), 502status = result.get("status_code", 500)body = result.get("body") or {}if status == 202 and body.get("queued"):