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
feat(chat): surface substantial interim assistant messages as muted Web bubbles (#2204)
Call Whitee282f7a81edc
diff --git a/core/message_dispatcher.py b/core/message_dispatcher.pyindex 143987034..17b8f3bca 100644--- a/core/message_dispatcher.py+++ b/core/message_dispatcher.py@@ -279,6 +279,12 @@ _WECHAT_CONSOLIDATED_SPLIT_THRESHOLD = 1700# normal fast step stays a clean label. This is the always-moving "still running"# signal that the heartbeat keeps ticking even when no new emit arrives._ACTION_TIME_HINT_S = 10.0+# An intermediate assistant message this substantial is also shown in the Web+# transcript as a muted ``interim`` bubble, so the user sees it without opening+# the Activity log. Either bound qualifies: three non-empty lines, or a single+# long paragraph (CJK prose often carries a whole thought on one line).+_INTERIM_MIN_LINES = 3+_INTERIM_MIN_CHARS = 150# Name the result attachment gets when a platform has no native Markdown upload# and the full text has to ride its ordinary file path instead._RESULT_DOCUMENT_NAME = "result.md"@@ -2554,6 +2560,13 @@ class ConsolidatedMessageDispatcher:while len(self._harness_prompt_echo_order) > HARNESS_PROMPT_ECHO_MEMORY:self._harness_prompt_echo_keys.discard(self._harness_prompt_echo_order.pop(0))+ @staticmethod+ def _is_interim_worthy(text: Optional[str]) -> bool:+ body = (text or "").strip()+ if len(body) >= _INTERIM_MIN_CHARS:+ return True+ return sum(1 for line in body.splitlines() if line.strip()) >= _INTERIM_MIN_LINES+async def emit_agent_message(self,context: MessageContext,@@ -2589,6 +2602,8 @@ class ConsolidatedMessageDispatcher:type says what role the message plays (and drives the dot + unread); thelevel says whether the user should SEE it:- ``"normal"`` (default): delivered / persisted / streamed as usual.+ - ``"process"``: an intermediate ``assistant`` row that stays in the+ process log only and is never promoted to a Web ``interim`` bubble.- ``"silent"``: settles the dot + releases the SSE waiter for a terminal``result``, then returns WITHOUT delivering, persisting, or streaming.Used when lifecycle settlement must not add another visible bubble,@@ -3606,6 +3621,18 @@ class ConsolidatedMessageDispatcher:# assistant / tool_call messages still land in the store (product# requirement: the process log is complete even when a channel hides it).persist_agent_message(target_context, canonical_type, persist_text, citations=citations)+ # Web only: the same text additionally lands as a transcript-visible+ # ``interim`` row. Every backend emits ``assistant`` only once later output+ # has proved the text is not the Turn's final answer, so this never+ # duplicates the result. ``level="process"`` keeps a row log-only (for+ # example reasoning summaries).+ if (+ canonical_type == "assistant"+ and level != "process"+ and target_context.platform == "avibe"+ and self._is_interim_worthy(persist_text)+ ):+ persist_agent_message(target_context, "interim", persist_text, citations=citations)# The row above is the only copy of an intermediate message that carries a# sidecar. Everything left below is what the channel is shown - the concisediff --git a/core/message_mirror.py b/core/message_mirror.pyindex 82af776be..b496b3d12 100644--- a/core/message_mirror.py+++ b/core/message_mirror.py@@ -257,6 +257,7 @@ _AGENT_TYPE_BY_CANONICAL = {"notify": "notify","output": "output","assistant": "assistant",+ "interim": "interim","system": "assistant",}@@ -384,11 +385,11 @@ def persist_agent_message(# to same-origin media-proxy URLs so the browser renders agent images# inline + files as download cards. IM rows keep the raw ``file://``# (the dispatcher uploads those to the platform separately). Scoped to- # the user-visible result/notify rows so we don't mint tokens for the- # hidden intermediate assistant stream.+ # transcript-visible rows (result/notify/interim …) so we don't mint+ # tokens for the hidden intermediate assistant stream.if (context.platform == "avibe"- and spec_for(message_type)["inboxPreview"]+ and spec_for(message_type)["transcript"]and row_session_id):try:diff --git a/core/services/session_fork.py b/core/services/session_fork.pyindex 05db576e0..3fe64a8dc 100644--- a/core/services/session_fork.py+++ b/core/services/session_fork.py@@ -41,10 +41,16 @@ ACTIVE_SOURCE_RUN_STATUSES = ("pending", "queued", "processing", "running")INPUT_TURN_MESSAGE_TYPES = tuple(message_type for _, message_type in INPUT_TURN_AUTHOR_TYPES)_CONDITIONAL_TERMINAL_TYPES = types_with("terminalWhenEvents")_DETACHED_COMPLETION_TYPES = types_with("detachedCompletion")+# Muted ``interim`` narration is a copy of process log, not a Turn boundary, so+# it never becomes the anchor a fork resumes from._FORK_ANCHOR_TYPES = tuple(dict.fromkeys((- *types_with("transcript"),+ *(+ message_type+ for message_type in types_with("transcript")+ if spec_for(message_type)["render"] != "muted"+ ),*(message_typefor message_type in types_with("activityRole")diff --git a/modules/agents/codex/event_handler.py b/modules/agents/codex/event_handler.pyindex a10a2bcf3..e04a2f710 100644--- a/modules/agents/codex/event_handler.py+++ b/modules/agents/codex/event_handler.py@@ -364,8 +364,10 @@ class CodexEventHandler:parts.append(c)text = "\n".join(parts)if text:+ # Reasoning summaries are process log, never an interim bubble.await self._narrate(- request, turn_state, thread_id, "assistant", f"_🧠 {text}_"+ request, turn_state, thread_id, "assistant", f"_🧠 {text}_",+ level="process",)# One predicate for both readings, so the live path and the recorded one@@ -538,6 +540,7 @@ class CodexEventHandler:role: str,text: str,parse_mode: str | None = "markdown",+ level: str = "normal",) -> None:"""Deliver one intermediate message, or hold it until it can be attributed.@@ -550,10 +553,12 @@ class CodexEventHandler:"""if turn_state is None:resolved, citations, _ = await self._prepare_citations(text, thread_id, request)- await self._emit_narration(request, role, resolved, parse_mode, citations)+ await self._emit_narration(request, role, resolved, parse_mode, citations, level)returnturn_state.pending_narration.append(- CodexHeldMessage(role=role, text=text, parse_mode=parse_mode, thread_id=thread_id)+ CodexHeldMessage(+ role=role, text=text, parse_mode=parse_mode, thread_id=thread_id, level=level+ ))await self._drain_narration(turn_state)@@ -564,12 +569,15 @@ class CodexEventHandler:text: str | None,parse_mode: str | None,citations: CitationBundle | None,+ level: str = "normal",) -> None:await self._agent.controller.emit_agent_message(request.context,role,text,parse_mode=parse_mode or "markdown",+ # Forwarded only when non-default, like ``citations`` below.+ **({"level": level} if level != "normal" else {}),# Forwarded only when there is a sidecar, so a message without# citations keeps the call it always had.**({"citations": citations} if citations else {}),@@ -596,7 +604,9 @@ class CodexEventHandler:if missing and not force:returnheld.pop(0)- await self._emit_narration(request, entry.role, resolved, entry.parse_mode, citations)+ await self._emit_narration(+ request, entry.role, resolved, entry.parse_mode, citations, entry.level+ )def _persist_turn_generated_images(self, params: dict[str, Any]) -> None:turn = params.get("turn")diff --git a/modules/agents/codex/turn_state.py b/modules/agents/codex/turn_state.pyindex eaded1529..27892c883 100644--- a/modules/agents/codex/turn_state.py+++ b/modules/agents/codex/turn_state.py@@ -22,6 +22,7 @@ class CodexHeldMessage:text: strparse_mode: Optional[str]thread_id: str+ level: str = "normal"@dataclassdiff --git a/modules/agents/opencode/poll_loop.py b/modules/agents/opencode/poll_loop.pyindex ddee331e3..c5571d88c 100644--- a/modules/agents/opencode/poll_loop.py+++ b/modules/agents/opencode/poll_loop.py@@ -1092,6 +1092,25 @@ class OpenCodePollLoop:await self._agent.controller.emit_agent_message(context, "tool_call", tool_summary)+ if (+ info.get("time", {}).get("completed")+ and message_id not in emitted_assistant_messages+ and info.get("finish") == "tool-calls"+ ):+ text = self._agent._extract_response_text(message)+ if text:+ await self._agent.controller.emit_agent_message(+ context,+ "assistant",+ text,+ parse_mode="markdown",+ )+ emitted_assistant_messages.add(message_id)+ poll_info.emitted_assistant_messages = sorted(emitted_assistant_messages)+ self._persist_emitted_assistant_messages(+ session_id, emitted_assistant_messages+ )+if messages:remaining = deadline - time.monotonic()awaiting_after_ids = getattr(diff --git a/tests/test_codex_event_handler.py b/tests/test_codex_event_handler.pyindex 90e993644..3cbd6e459 100644--- a/tests/test_codex_event_handler.py+++ b/tests/test_codex_event_handler.py@@ -588,6 +588,28 @@ class CodexEventHandlerTests(unittest.IsolatedAsyncioTestCase):agent.emit_result_message.assert_awaited_once()assert agent.emit_result_message.await_args.args[1] == "Final answer"+ async def test_reasoning_summary_stays_process_only(self):+ agent = _StubAgent()+ handler = CodexEventHandler(agent)+ request = SimpleNamespace(base_session_id="session-1", context=object(), started_at=0)+ agent._turn_registry.register_turn("turn-1", request)++ await handler._on_item_completed(+ {+ "turnId": "turn-1",+ "item": {"type": "reasoning", "summary": ["Weighing the options"]},+ },+ request,+ )++ agent.controller.emit_agent_message.assert_awaited_once_with(+ request.context,+ "assistant",+ "_🧠 Weighing the options_",+ parse_mode="markdown",+ level="process",+ )+async def test_empty_success_result_falls_back_to_new_thread_generated_images(self):agent = _StubAgent()handler = CodexEventHandler(agent)diff --git a/tests/test_message_dispatcher_interim.py b/tests/test_message_dispatcher_interim.pynew file mode 100644index 000000000..c10417884--- /dev/null+++ b/tests/test_message_dispatcher_interim.py@@ -0,0 +1,45 @@+"""An intermediate assistant message also becomes a Web ``interim`` bubble."""++from __future__ import annotations++import sys+import unittest+from pathlib import Path+from unittest import mock++sys.path.insert(0, str(Path(__file__).resolve().parents[1]))++from core.message_dispatcher import ConsolidatedMessageDispatcher+from modules.im import MessageContext+from tests.test_message_dispatcher_platform_limits import _StubController++LONG_LINE = "根因已经定位:" + "并发下重入" * 40+THREE_LINES = "Found it.\nThe cache is shared.\nFixing the lock next."+TWO_LINES = "Reading a.py\nthen b.py"+++class InterimBubbleTests(unittest.IsolatedAsyncioTestCase):+ async def _persisted_types(self, platform, text, **kwargs):+ controller = _StubController(platform)+ dispatcher = ConsolidatedMessageDispatcher(controller)+ context = MessageContext(user_id="u", channel_id="c", platform=platform)+ with mock.patch("core.message_dispatcher.persist_agent_message") as persist:+ await dispatcher.emit_agent_message(context, "assistant", text, **kwargs)+ return [call.args[1] for call in persist.call_args_list]++ async def test_promotion_rule(self):+ cases = [+ ("avibe", THREE_LINES, {}, ["assistant", "interim"]),+ ("avibe", LONG_LINE, {}, ["assistant", "interim"]),+ ("avibe", TWO_LINES, {}, ["assistant"]),+ ("avibe", "a\n\n\n\nb", {}, ["assistant"]),+ ("avibe", THREE_LINES, {"level": "process"}, ["assistant"]),+ ("slack", THREE_LINES, {}, ["assistant"]),+ ]+ for platform, text, kwargs, expected in cases:+ with self.subTest(platform=platform, text=text[:20], kwargs=kwargs):+ self.assertEqual(await self._persisted_types(platform, text, **kwargs), expected)+++if __name__ == "__main__":+ unittest.main()diff --git a/tests/test_message_mirror.py b/tests/test_message_mirror.pyindex 8b34df3e4..ea95a51ef 100644--- a/tests/test_message_mirror.py+++ b/tests/test_message_mirror.py@@ -1209,7 +1209,8 @@ def test_background_standalone_persists_full_turn_without_realtime_delivery(isolassert {row["scope_id"] for row in rows} == {None}-def test_background_standalone_rewrites_agent_file_links(isolated_state, tmp_path):[email protected]("canonical_type", ["result", "interim"])+def test_background_standalone_rewrites_agent_file_links(isolated_state, tmp_path, canonical_type):local_file = tmp_path / "report.txt"local_file.write_text("standalone artifact", encoding="utf-8")engine = create_sqlite_engine()@@ -1241,7 +1242,7 @@ def test_background_standalone_rewrites_agent_file_links(isolated_state, tmp_pat"suppress_delivery": True,},)- persist_agent_message(context, "result", f"[report]({local_file.as_uri()})")+ persist_agent_message(context, canonical_type, f"[report]({local_file.as_uri()})")with engine.connect() as conn:message = conn.execute(diff --git a/tests/test_message_type_catalog.py b/tests/test_message_type_catalog.pyindex 59a6f0159..83e936af0 100644--- a/tests/test_message_type_catalog.py+++ b/tests/test_message_type_catalog.py@@ -97,6 +97,7 @@ def test_transcript_types_match_current_constant() -> None:"notify","vault","error",+ "interim",)assert types_with("transcript") == expectedassert messages_service.TRANSCRIPT_TYPES == expected@@ -106,7 +107,7 @@ def test_searchable_types_match_current_default_query() -> None:connection = _CaptureConnection()messages_service.search_messages(connection, query="catalog-probe")- expected = ("user", "harness", "annotation", "output", "result", "vault")+ expected = ("user", "harness", "annotation", "output", "result", "vault", "interim")assert types_with("searchable") == expectedassert _message_type_sequences(connection.statements[-1]) == {expected}diff --git a/tests/test_multi_platform_runtime.py b/tests/test_multi_platform_runtime.pyindex 9c6ff9f44..475f7f58b 100644--- a/tests/test_multi_platform_runtime.py+++ b/tests/test_multi_platform_runtime.py@@ -2801,6 +2801,92 @@ def test_opencode_restored_poll_keeps_empty_completion_successful():assert isinstance(results[0][1]["started_at"], float)+def test_opencode_restored_poll_emits_intermediate_assistant_once():+ """A turn restored after restart still surfaces its tool-calls narration.++ ``msg-old`` was already emitted before the restart (persisted id), so only+ ``msg-new`` is emitted, and the persisted id set grows to cover it.+ """+ emitted = []+ persisted = []++ class _Controller:+ def __init__(self):+ self.config = type("Config", (), {"language": "en"})()+ self.processing_indicator = ProcessingIndicatorService(self)++ def _t(self, key, **kwargs):+ return f"translated:{key}"++ async def emit_agent_message(self, context, message_type, text, parse_mode=None, **kwargs):+ emitted.append((message_type, text))++ class _Sessions:+ def update_active_poll_state(self, session_id, **kwargs):+ persisted.append(kwargs)++ def remove_active_poll(self, session_id):+ return None++ def _narration(message_id):+ return {+ "info": {"id": message_id, "role": "assistant", "time": {"completed": 1}, "finish": "tool-calls"},+ "parts": [{"type": "text", "text": message_id}],+ }++ class _Server:+ async def list_messages(self, session_id, directory):+ return [+ _narration("msg-old"),+ _narration("msg-new"),+ {+ "info": {"id": "msg-final", "role": "assistant", "time": {"completed": 2}, "finish": "stop"},+ "parts": [{"type": "text", "text": "done"}],+ },+ ]++ async def get_session_status(self, session_id, directory):+ return {"type": "idle"}++ server = _Server()++ class _Agent:+ opencode_config = type("OpenCodeConfig", (), {"error_retry_limit": 0})()+ controller = _Controller()+ sessions = _Sessions()++ async def _get_server(self):+ return server++ def _extract_response_text(self, message):+ return "".join(part.get("text", "") for part in message.get("parts", []))++ async def emit_result_message(self, context, text, **kwargs):+ emitted.append(("result", text))++ async def _remove_ack_reaction(self, request):+ return None++ poll = ActivePollInfo(+ opencode_session_id="oc-session",+ base_session_id="base",+ channel_id="c",+ thread_id="t",+ settings_key="c",+ working_path="/tmp/work",+ baseline_message_ids=[],+ platform="avibe",+ emitted_assistant_messages=["msg-old"],+ prompt_started_at=time.time(),+ )++ assert asyncio.run(OpenCodePollLoop(_Agent()).run_restored_poll_loop(poll)) is True++ assert [item for item in emitted if item[0] == "assistant"] == [("assistant", "msg-new")]+ assert ("result", "done") in emitted+ assert {"emitted_assistant_messages": ["msg-new", "msg-old"]} in persisted++def test_opencode_restored_poll_settles_after_consecutive_transport_failures(monkeypatch,):diff --git a/ui/src/lib/chatRowKind.test.ts b/ui/src/lib/chatRowKind.test.tsindex de46b8602..941c63685 100644--- a/ui/src/lib/chatRowKind.test.ts+++ b/ui/src/lib/chatRowKind.test.ts@@ -27,6 +27,7 @@ describe('chatRowKind', () => {expect(row({ author: 'user', source: 'user' })).toEqual({ kind: 'user' });expect(row({ author: 'agent', type: 'result' })).toEqual({ kind: 'agent' });expect(row({ author: 'agent', type: 'output' })).toEqual({ kind: 'boundary' });+ expect(row({ author: 'agent', type: 'interim' })).toEqual({ kind: 'boundary' });expect(row({ author: 'system', type: 'user' })).toEqual({ kind: 'system' });expect(row({ author: 'harness', source: 'harness', type: 'harness' })).toEqual({ kind: 'harness' });expect(row({ author: 'harness', source: 'harness', type: 'vault' })).toEqual({ kind: 'harness' });diff --git a/ui/src/lib/chatRowKind.ts b/ui/src/lib/chatRowKind.tsindex d0e03f47c..b85f520f3 100644--- a/ui/src/lib/chatRowKind.ts+++ b/ui/src/lib/chatRowKind.ts@@ -20,6 +20,7 @@// typed row is that type.import { isBoundaryMessage, isNotifyMessageType } from './chatMessageTypes';import { readAnnotationView, type AnnotationView } from './annotationView';+import { specFor } from './messageTypes';// A row typed ``annotation`` whose display record is unreadable. Every writer of// the type emits one, and the migration backfills ``direction: "agent"`` onto the@@ -54,7 +55,9 @@ export function chatRowKind(message: ChatRowFields): ChatRowKind {if (message.type === 'annotation') {return { kind: 'annotation', annotation: readAnnotationView(message.content) ?? UNREADABLE_ANNOTATION };}- if (isBoundaryMessage(message)) return { kind: 'boundary' };+ // A phase boundary and an ``interim`` narration share the muted Agent bubble:+ // both are the agent's words that do not end the Turn.+ if (isBoundaryMessage(message) || specFor(message.type).render === 'muted') return { kind: 'boundary' };// Runtime notifications and legacy error rows are compact status pills, not// Agent-authored answers.if (isNotifyMessageType(message.type)) return { kind: 'notify' };diff --git a/ui/src/lib/vaultRequestPlacement.test.ts b/ui/src/lib/vaultRequestPlacement.test.tsindex bb5a5db0f..5197ce9b8 100644--- a/ui/src/lib/vaultRequestPlacement.test.ts+++ b/ui/src/lib/vaultRequestPlacement.test.ts@@ -132,6 +132,18 @@ describe('placeVaultProvisionRequests', () => {expect(placed.unanchored).toEqual([]);});+ it('skips interim narration when inferring the request owner', () => {+ const interim = { ...message('agent-interim', '2026-07-30T10:00:05Z'), type: 'interim' };+ const reply = message('agent-reply', '2026-07-30T10:00:10Z');+ const placed = placeVaultProvisionRequests(+ [message('user-before', '2026-07-30T09:59:00Z', 'user'), interim, reply],+ [request('p', 'provision', '2026-07-30T10:00:00Z')],+ );++ expect(placed.byMessageId.get(reply.id)?.map((item) => item.id)).toEqual(['p']);+ expect(placed.byMessageId.has(interim.id)).toBe(false);+ });+it('does not infer an unrelated detached completion as the request owner', () => {const detached = {...message('background-completion', '2026-07-30T10:00:05Z'),diff --git a/ui/src/lib/vaultRequestPlacement.ts b/ui/src/lib/vaultRequestPlacement.tsindex fb39fc03c..8ce592952 100644--- a/ui/src/lib/vaultRequestPlacement.ts+++ b/ui/src/lib/vaultRequestPlacement.ts@@ -23,6 +23,9 @@ export type VaultProvisionPlacement = {};function isAgentReplyWithExplicitProvenance(message: WorkbenchMessage): boolean {+ // Muted ``interim`` narration shares the boundary card but is not a reply that+ // owns the Turn's requests.+ if (specFor(message.type).render === 'muted') return false;const kind = chatRowKind(message).kind;return kind === 'agent' || kind === 'boundary';}diff --git a/vibe/message_types.json b/vibe/message_types.jsonindex 86df7d338..bb1a69c83 100644--- a/vibe/message_types.json+++ b/vibe/message_types.json@@ -104,6 +104,11 @@"inboxActivity": true,"activityRole": "activity","render": "activity"+ },+ "interim": {+ "transcript": true,+ "searchable": true,+ "render": "muted"}}}diff --git a/vibe/message_types.py b/vibe/message_types.pyindex 367cbfe74..2a9e22f31 100644--- a/vibe/message_types.py+++ b/vibe/message_types.py@@ -30,6 +30,7 @@ _ENUM_PROPERTIES = {"harness","annotation","agent",+ "muted","status","activity",},