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-23 Codex P2 — system-as-assistant, release silent turns, honor pre-promoted rows
cyh02d2150d1438
diff --git a/core/message_mirror.py b/core/message_mirror.pyindex 12851d2c6..0c9485390 100644--- a/core/message_mirror.py+++ b/core/message_mirror.py@@ -114,15 +114,19 @@ def _scope_id_for_session(conn, session_id: str) -> Optional[str]:# Maps the dispatcher's canonical message type to the persisted ``messages.type``.-# ``system`` folds into ``notify`` (a process message, not a user-facing reply)-# so it never pollutes the result-only inbox preview.+# ``system`` folds into ``assistant`` (a process-log message, not a user-facing+# reply): once terminal-failure ``notify`` rows became inbox-eligible, routine+# system/init logs stored as ``notify`` would have created an Inbox card with a+# junk preview before any real reply. As process log, ``system`` belongs with+# ``assistant`` / ``tool_call`` — out of the inbox and out of the transcript+# (Codex P2). Genuine terminal failures persist via canonical ``notify``._AGENT_TYPE_BY_CANONICAL = {"result": "result","notify": "notify","assistant": "assistant","toolcall": "tool_call","tool_call": "tool_call",- "system": "notify",+ "system": "assistant",}diff --git a/modules/agents/base.py b/modules/agents/base.pyindex 0dbeda561..0fd6fdade 100644--- a/modules/agents/base.py+++ b/modules/agents/base.py@@ -284,6 +284,15 @@ class BaseAgent(ABC):if parts:formatted = "\n".join(parts)await self.controller.emit_agent_message(context, "result", formatted, parse_mode=parse_mode)+ else:+ # No visible text to send (show_duration off + empty result/suffix):+ # emit_agent_message is skipped, so nothing would release the web-Chat+ # streaming turn and it would hang until the 600s timeout. Mark the+ # turn complete (mirrors the silent-directive path); token-guarded ++ # no-op for IM/CLI (Codex P2).+ _mark = getattr(self.controller, "mark_turn_complete", None)+ if callable(_mark):+ _mark(context)else:formatted = self._get_formatter(context).format_result_message(subtype or "",diff --git a/tests/test_agent_silent_result.py b/tests/test_agent_silent_result.pyindex 5c30bb828..bf53a9d4e 100644--- a/tests/test_agent_silent_result.py+++ b/tests/test_agent_silent_result.py@@ -44,6 +44,22 @@ class AgentSilentResultTests(unittest.IsolatedAsyncioTestCase):self.assertEqual(controller.messages, [("result", "", "markdown")])+ async def test_no_visible_result_with_duration_hidden_releases_streaming_turn(self):+ # show_duration off + empty result/suffix => emit_agent_message is skipped,+ # so nothing would release the web-Chat streaming turn; it must be marked+ # complete instead of hanging to the 600s timeout (Codex P2).+ controller = _StubController()+ controller.config = SimpleNamespace(show_duration=False)+ marked = []+ controller.mark_turn_complete = lambda ctx: marked.append(ctx)+ agent = _StubAgent(controller)+ context = MessageContext(user_id="U1", channel_id="C1", platform="avibe")++ await agent.emit_result_message(context, "", subtype="success", duration_ms=0)++ self.assertEqual(controller.messages, [], "no visible text => no result emit")+ self.assertEqual(len(marked), 1, "the streaming turn must be released")+class AgentSessionIdContextTests(unittest.TestCase):def test_bind_agent_session_id_attaches_returned_public_session_id(self):diff --git a/tests/test_message_mirror.py b/tests/test_message_mirror.pyindex 3e6162b7d..3c42f7fa5 100644--- a/tests/test_message_mirror.py+++ b/tests/test_message_mirror.py@@ -300,6 +300,46 @@ def test_persist_agent_intermediate_streams_but_not_inbox(isolated_state):assert seen[0][1]["session_id"] == "ses_noresult"+def test_persist_system_message_maps_to_assistant_not_notify(isolated_state):+ """A canonical ``system`` (process/init log) persists as type ``assistant``,+ NOT ``notify`` — so it stays process log and does NOT become inbox-eligible+ (which would create a junk Inbox card before any real reply) (Codex P2)."""+ from core import inbox_events++ engine = create_sqlite_engine()+ now = "2026-05-30T12:00:00Z"+ with engine.begin() as conn:+ scope_id = upsert_scope(conn, platform="avibe", scope_type="project", native_id="proj_sys", now=now)+ conn.execute(+ agent_sessions.insert().values(+ id="ses_sys", scope_id=scope_id, agent_backend="claude", agent_variant="default",+ session_anchor="anchor_ses_sys", native_session_id="", status="active",+ metadata_json="{}", created_at=now, updated_at=now, last_active_at=now,+ )+ )++ ctx = MessageContext(+ user_id="workbench", channel_id="ses_sys", platform="avibe",+ platform_specific={"agent_session_id": "ses_sys"},+ )++ async def scenario():+ sub_id, queue = inbox_events.bus.subscribe()+ seen = []+ try:+ persist_agent_message(ctx, "system", "Claude session initialized")+ seen.append(await asyncio.wait_for(queue.get(), timeout=1.0))+ with pytest.raises(asyncio.TimeoutError): # no inbox event for process log+ await asyncio.wait_for(queue.get(), timeout=0.05)+ finally:+ inbox_events.bus.unsubscribe(sub_id)+ return seen++ seen = asyncio.run(scenario())+ assert [e[0] for e in seen] == ["message.new"]+ assert seen[0][1]["type"] == "assistant" # folded into process log, not notify++def test_persist_agent_terminal_notify_updates_inbox(isolated_state):"""A terminal ``notify`` (a turn that failed before any ``result``) DOESpublish ``inbox.session.updated`` so the failed conversation surfaces on thediff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex a42a24966..2543bea6d 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -3112,7 +3112,15 @@ async def sessions_messages_create(session_id: str):browser bridge, but the user row is persisted in this UI process so thecontroller bus never sees it."""with engine.begin() as conn:- messages_service.promote_pending(conn, row["id"], "user")+ promoted = messages_service.promote_pending(conn, row["id"], "user")+ if not promoted:+ # The row wasn't pending anymore: the controller already promoted it+ # (e.g. enqueued as 'queued' via the busy-session path) before our+ # dispatch call failed/returned. Don't publish a phantom 'user'+ # transcript row alongside the still-queued item — nudge the queue view+ # and report it as queued instead (Codex P2).+ broker.publish("queue.updated", {"session_id": session_id, "scope_id": session["scope_id"]})+ return {**row, "type": "queued"}row = {**row, "type": "user"}broker.publish("message.new", row)broker.publish(