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(vibey): resume empty model replies once (#3035)
Call White79179b1b53e1
diff --git a/core/agent_core/agent/loop.py b/core/agent_core/agent/loop.pyindex 94c956c29..c9c275275 100644--- a/core/agent_core/agent/loop.py+++ b/core/agent_core/agent/loop.py@@ -155,6 +155,8 @@ from core.agent_core.messages import (HostedRecord,Message,Origin,+ TextBlock,+ ThinkingBlock,ToolCallBlock,ToolResultMessage,Usage,@@ -218,6 +220,14 @@ def _cache_of(origin: Origin) -> tuple[str, str]:return origin.provider, origin.model+def _silent_stop(message: AssistantMessage) -> bool:+ """Whether a normal stop contains no user-visible model content to preserve."""+ return all(+ isinstance(block, ThinkingBlock) or (isinstance(block, TextBlock) and not block.text.strip())+ for block in message.content+ )++async def _silent(*_: Any, **__: Any) -> None:"""A side turn's emit: it shows nothing (C-10 section 7)."""@@ -692,7 +702,7 @@ class Agent:self._run_tools = dict(zip(names, setup.tools))if consume:await self._consume(input)- self._outcome.primary(await self._loop(system, emit, selected))+ self._outcome.primary(await self._loop(system, emit, selected, discard_silent_final=consume))except _Ended:self._outcome.primary("ended_by_hook")except _Exhausted as error:@@ -731,8 +741,15 @@ class Agent:await emit(RunEnded, reason=self._outcome.reason, cause=self._outcome.cause)async def _error(- self, emit: Callable[..., Awaitable[Any]], kind: str, message: str, origin: ErrorOrigin, *, cause: bool,+ self,+ emit: Callable[..., Awaitable[Any]],+ kind: str,+ message: str,+ origin: ErrorOrigin,+ *,+ cause: bool,provider_error: Optional[ProviderError] = None,+ continuable: bool = False,) -> None:"""The one place the loop announces an error: ``origin`` as its caller states it, where the error is raised.@@ -742,7 +759,7 @@ class Agent:event = await emit(AgentError, kind=kind, message=message, origin=origin,retryable=provider_error.retryable if provider_error is not None else False,- continuable=provider_error.continuable if provider_error is not None else False,+ continuable=provider_error.continuable if provider_error is not None else continuable,retry_after_s=provider_error.retry_after_s if provider_error is not None else None,)if cause:@@ -1063,9 +1080,14 @@ class Agent:*,replied: bool,keep_open: bool = False,- ) -> tuple[ContextEntry, bool]:- """Commit the response: its row, and whether it is final. Finality and queued-input admission share one lock- with the commit. ``replied`` is the run's decision whether it replies, which the store takes as given."""+ discard_silent_final: bool = False,+ ) -> tuple[Optional[ContextEntry], bool]:+ """Commit the response and return whether it is final.++ A silent normal stop can be admitted as a retryable terminal without becoming a transcript final. The+ decision is made under the same lock as queued-input admission, so a concurrent steer still turns it into+ the ordinary non-final response path.+ """pending: list[tuple[AgentInput, bool]] = []consumed: list[tuple[AgentInput, bool]] = []failed = message.stop_reason in {"error", "aborted"}@@ -1077,12 +1099,14 @@ class Agent:if not pending:pending = [(item, False) for item in self._follow_ups]final = not message.tool_calls and not pending and not failed+ discard = discard_silent_final and final# A completed reply the pending input took the final word from: one cut off at its output limit# never completed, as ``final_outcome`` holds for a final.superseded = bool(pending) and replied and message.stop_reason != "length"if (final or failed) and not keep_open:self._open = False- row = await self._response(message, final=final, replied=replied, superseded=superseded)+ if not discard:+ row = await self._response(message, final=final, replied=replied, superseded=superseded)for item, is_steer in pending:await self._consume(item)(self._steers if is_steer else self._follow_ups).popleft()@@ -1101,7 +1125,14 @@ class Agent:await emit(SteerApplied, message_id=item.message_id)return row, final- async def _loop(self, system: str, emit: Callable[..., Awaitable[None]], selected: ModelSelection) -> RunEndReason:+ async def _loop(+ self,+ system: str,+ emit: Callable[..., Awaitable[None]],+ selected: ModelSelection,+ *,+ discard_silent_final: bool,+ ) -> RunEndReason:first_selection: Optional[ModelSelection] = selectedlength_tool_retries = 0while True:@@ -1125,6 +1156,7 @@ class Agent:response, _ = await self._commit_model_message(terminal.partial, emit, replied=replied, keep_open=True)+ assert response is not Nonemalformed_recovery = (terminal, tools, response)if malformed_recovery is None:if terminal.partial is not None and not terminal.partial.content:@@ -1163,12 +1195,36 @@ class Agent:"local" if aborted else "source",cause=decided,)- # Decided once: the empty-reply test, the row's type and settlement all take it (``has_reply``).+ # A normal stop with only private/blank content is a retryable source failure for Vibey. Do not+ # commit it as a final (or feed it back as assistant context); the adapter resumes this transcript.replied = has_reply(message, generated_images=bool(self._generated_images))- response, final = await self._commit_model_message(message, emit, replied=replied)+ retryable_empty = (+ discard_silent_final+ and message.stop_reason == "stop"+ and not message.tool_calls+ and _silent_stop(message)+ and not replied+ )+ response, final = await self._commit_model_message(+ message,+ emit,+ replied=replied,+ discard_silent_final=retryable_empty,+ )empty_reply = final and not repliedtruncated_reply = final and message.stop_reason == "length"- if empty_reply or truncated_reply:+ retryable_empty = retryable_empty and final+ if retryable_empty:+ decided = self._outcome.primary("error")+ await self._error(+ emit,+ "empty_response",+ f"Model stopped with {message.stop_reason} without a reply.",+ "source",+ cause=decided,+ continuable=True,+ )+ elif empty_reply or truncated_reply:decided = self._outcome.primary("error")await self._error(emit,diff --git a/modules/agents/vibey/agent.py b/modules/agents/vibey/agent.pyindex c6688c966..f2921b6a2 100644--- a/modules/agents/vibey/agent.py+++ b/modules/agents/vibey/agent.py@@ -134,6 +134,8 @@ BACKEND = "vibey"# Final responses whose empty text is explained by the stop itself (loop-control.md section 2)._EXPLAINED_STOPS = ("length", "refusal", "safety")_COMPLETED = ("completed", "ended_by_hook")+# A transient source failure may use the existing bounded continuation policy; a silent normal stop gets one+# transcript-only continuation before the ordinary empty-response failure is delivered._MAX_AUTO_CONTINUATIONS = 5_JOB_PRUNE_INTERVAL_S = 3600.0diff --git a/tests/agent_core/agent/test_loop.py b/tests/agent_core/agent/test_loop.pyindex 2690005d6..c183cde9b 100644--- a/tests/agent_core/agent/test_loop.py+++ b/tests/agent_core/agent/test_loop.py@@ -1411,25 +1411,38 @@ async def test_tool_free_final_reply_is_committed_and_empty_success_is_an_error(events = await collect(agent)rows = await agent.store.load("session")responses = [row for row in rows if row.kind == "response"]- assert responses[0].message == message+ retryable_empty = (+ continuation == "final" and stop_reason == "stop" and shape in {"empty", "whitespace", "thinking"}+ )+ if retryable_empty:+ assert responses == []+ else:+ assert responses[0].message == messagecommitted = [event for event in events if isinstance(event, MessageCommitted)]- expected_finals = [True] if continuation == "final" else [False, True]+ expected_finals = [] if retryable_empty else [True] if continuation == "final" else [False, True]assert [agent.store.final[row.row_id] for row in responses] == expected_finalsassert [event.final for event in committed] == expected_finalsassert [event.message_id for event in committed] == [row.row_id for row in responses]- assert len(provider.requests) == provider.closed_streams == len(expected_finals)+ assert len(provider.requests) == provider.closed_streams == (1 if retryable_empty else len(expected_finals))assert [row.row_id for row in rows if row.kind == "input"] == (["input"] if continuation == "final" else ["input", "pending"])errors = [event for event in events if isinstance(event, AgentError)]- if continuation != "final" or (shape == "visible" and stop_reason != "length"):+ if retryable_empty:+ assert len(errors) == 1+ assert errors[0].kind == "empty_response"+ assert errors[0].continuable is True+ assert committed == []+ assert events[-1].reason == "error"+ elif continuation != "final" or (shape == "visible" and stop_reason != "length"):assert errors == []assert events[-1].reason == "completed"else:assert len(errors) == 1assert errors[0].kind == (stop_reason if stop_reason in {"length", "refusal", "safety"} else "empty_response")assert errors[0].message- assert committed[0].seq < errors[0].seq < events[-1].seq+ if committed:+ assert committed[0].seq < errors[0].seq < events[-1].seqassert events[-1].reason == "error"project(rows)diff --git a/tests/agent_core/agent/test_outcomes.py b/tests/agent_core/agent/test_outcomes.pyindex 5f5edc2da..a34fe9e03 100644--- a/tests/agent_core/agent/test_outcomes.py+++ b/tests/agent_core/agent/test_outcomes.py@@ -160,7 +160,7 @@ async def test_primary_outcome_cross_cleanup_keeps_reason_rows_and_event_order(assert [event.seq for event in events] == list(range(len(events)))rows = await store.load("session")expected_rows = ["input"]- if primary not in {"abort", "provider_error", "overflow"}:+ if primary not in {"abort", "provider_error", "overflow", "empty_response"}:expected_rows.append("response")if has_tools:expected_rows.extend(["tool_result", "response"])@@ -171,7 +171,7 @@ async def test_primary_outcome_cross_cleanup_keeps_reason_rows_and_event_order(responses = [row for row in rows if row.kind == "response"]assert [event.message_id for event in committed] == [row.row_id for row in responses]assert [event.final for event in committed] == (- [False, True] if has_tools else [primary != "partial"] if responses else []+ [False, True] if has_tools else [primary not in {"partial", "empty_response"}] if responses else [])assert len(tool.calls) == (1 if has_tools else 0)assert provider.calls == (2 if has_tools else 1)diff --git a/tests/test_vibey_agent.py b/tests/test_vibey_agent.pyindex 50630c765..09e2a6584 100644--- a/tests/test_vibey_agent.py+++ b/tests/test_vibey_agent.py@@ -1231,7 +1231,7 @@ async def test_a_failed_run_shows_localized_copy_and_a_refusal_shows_its_explana) -> None:refusal = AssistantMessage((), ORIGIN, "refusal")harness = _Harness(- engine, tmp_path, "telegram", [[Done(assistant(""))], [Done(refusal)]], language=language+ engine, tmp_path, "telegram", [[Done(assistant(""))], [Done(assistant(""))], [Done(refusal)]], language=language)reported: list[str] = []@@ -1310,6 +1310,74 @@ async def test_a_transient_failure_continues_from_the_same_transcript_without_a_assert harness.controller.terminals[-1]["is_error"] is False+async def test_a_silent_stop_resumes_the_same_transcript_without_a_notice(+ engine, session, tmp_path, published, continuation_policy+) -> None:+ continuation_policy(initial_delay_s=0)+ harness = _Harness(+ engine,+ tmp_path,+ "telegram",+ [[Done(assistant(""))], [Done(assistant("recovered"))]],+ )++ await harness.agent.handle_message(harness.request("finish the task"))++ assert len(harness.provider.requests) == 2+ assert harness.provider.requests[0].messages == harness.provider.requests[1].messages+ assert harness.rows("notify") == []+ assert harness.controller.im_client.sent == ["recovered"]+ assert harness.controller.terminals[-1]["is_error"] is False+++async def test_a_second_silent_stop_keeps_the_existing_empty_response_failure(+ engine, session, tmp_path, published, continuation_policy+) -> None:+ continuation_policy(initial_delay_s=0)+ harness = _Harness(+ engine,+ tmp_path,+ "telegram",+ [[Done(assistant(""))], [Done(assistant(""))]],+ )++ await harness.agent.handle_message(harness.request("finish the task"))++ empty_copy = i18n_t("vibeyAgent.error.emptyResponse", "en")+ assert len(harness.provider.requests) == 2+ assert harness.controller.im_client.sent == [empty_copy]+ assert len(harness.rows("error")) == 1+ assert harness.controller.terminals[-1]["is_error"] is True+++async def test_a_silent_stop_after_a_tool_reuses_the_committed_result_without_rerunning_it(+ engine, session, tmp_path, published, continuation_policy+) -> None:+ continuation_policy(initial_delay_s=0)+ call = ToolCallBlock(id="call_1", name="echo", arguments={})+ tool = FakeTool("echo")+ harness = _Harness(+ engine,+ tmp_path,+ "telegram",+ [+ [Done(assistant("", calls=(call,)))],+ [Done(assistant(""))],+ [Done(assistant("recovered"))],+ ],+ tools=[tool],+ )++ await harness.agent.handle_message(harness.request("run the tool"))++ assert len(tool.calls) == 1+ assert len(harness.provider.requests) == 3+ assert harness.provider.requests[1].messages == harness.provider.requests[2].messages+ assert harness.rows("notify") == []+ assert harness.controller.im_client.sent == ["🔧 echo {}", "recovered"]+ assert harness.controller.terminals[-1]["is_error"] is False++async def test_malformed_tool_arguments_recover_without_executing_the_bad_call(engine, session, tmp_path, published, continuation_policy) -> None:@@ -3148,7 +3216,7 @@ async def test_a_final_is_stored_with_its_outcome_semantics("empty": assistant(""),"refusal": AssistantMessage((), ORIGIN, "refusal"),}[final]- harness = _Harness(engine, tmp_path, "avibe", [[Done(message)]])+ harness = _Harness(engine, tmp_path, "avibe", [[Done(message)], [Done(assistant(""))]])await harness.agent.handle_message(harness.request("answer me"))@@ -4350,11 +4418,14 @@ async def test_a_generated_image_reaches_the_user_with_the_turns_reply_even_whencall = ToolCallBlock(id="call_img", name="image_generate", arguments={"model": "gpt-image-2", "prompt": "a lighthouse"})final = AssistantMessage((TextBlock(text=said),) if said else (), ORIGIN, stop)async with httpx.AsyncClient(transport=httpx.MockTransport(gateway)) as client:+ scripts = [[Done(AssistantMessage((call,), ORIGIN, "tool_use"))], [Done(final)]]+ if status == "failed" and stop == "stop":+ scripts.append([Done(final)])harness = _Harness(engine,tmp_path,"telegram",- [[Done(AssistantMessage((call,), ORIGIN, "tool_use"))], [Done(final)]],+ scripts,gateway_client=client,)harness.controller.hub_hosted_tools = {"image_generate": _image_entry("gpt-image-2", "gemini-3.1-flash-image")}@@ -4374,10 +4445,12 @@ async def test_a_generated_image_reaches_the_user_with_the_turns_reply_even_whenpatch.setattr(AdapterTranscriptStore, "append_response", append_response)await harness.agent.handle_message(harness.request("draw a lighthouse"))- first, second = (+ image_tools = [next(tool for tool in request.tools if tool.name == "image_generate") for request in harness.provider.requests- )- assert first == second+ ]+ assert all(tool == image_tools[0] for tool in image_tools)+ assert len(image_tools) == (3 if status == "failed" and stop == "stop" else 2)+ first = image_tools[0]assert first.input_schema["properties"]["model"]["enum"] == ["gpt-image-2", "gemini-3.1-flash-image"]assert harness.controller.terminals[-1]["is_error"] is not repliedresult = next(row.message for row in await harness.context_rows() if isinstance(row.message, ToolResultMessage))