Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

fix(memory): fence incomplete empty probe responses

cyh3355e77782e9
diff --git a/core/memory/everos.py b/core/memory/everos.py
index a34eb92af..15b9d306c 100644
--- a/core/memory/everos.py
+++ b/core/memory/everos.py
@@ -67,6 +67,9 @@ _PROCESSING_TIMEOUT_SECONDS = PROCESSING_PROBE_REQUEST_TIMEOUT_SECONDS
_PREFLIGHT_TIMEOUT_SECONDS = 5.0
_PREFLIGHT_RESPONSE_BYTES = _MAX_RESPONSE_BYTES
_CHAT_PROBE_MAX_TOKENS = 8
+_CHAT_PROBE_TERMINAL_FINISH_REASONS = frozenset(
+ {"stop", "length", "content_filter", "tool_calls", "function_call"}
+)
_PREFLIGHT_IMAGE_DATA_URI = (
"data:image/png;base64,"
"iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAYElEQVR42u3QAQ0AAAwC"
@@ -1600,8 +1603,17 @@ def _chat_probe_response_issue(value: Any) -> str | None:
return "provider_response_missing_message"
if "content" not in message:
return "provider_response_missing_content"
- if not isinstance(message["content"], str):
+ content = message["content"]
+ if not isinstance(content, str):
return "provider_response_invalid_content"
+ if not content:
+ if message.get("role") != "assistant":
+ return "provider_response_invalid_role"
+ finish_reason = choices[0].get("finish_reason")
+ if finish_reason is None:
+ return "provider_response_missing_finish_reason"
+ if finish_reason not in _CHAT_PROBE_TERMINAL_FINISH_REASONS:
+ return "provider_response_invalid_finish_reason"
return None
diff --git a/tests/test_memory_everos.py b/tests/test_memory_everos.py
index b61ec000a..d13b82a35 100644
--- a/tests/test_memory_everos.py
+++ b/tests/test_memory_everos.py
@@ -1520,6 +1520,44 @@ def test_processing_preflight_reports_the_rejected_2xx_shape() -> None:
assert result.failure.diagnostic.message == "provider_response_missing_message"
+ ("message", "expected"),
+ [
+ ({"content": ""}, "provider_response_invalid_role"),
+ ({"role": "assistant", "content": ""}, "provider_response_missing_finish_reason"),
+ ],
+)
+def test_processing_preflight_requires_completion_metadata_for_empty_chat_content(
+ message: dict[str, str], expected: str
+) -> None:
+ def handler(request: httpx.Request) -> httpx.Response:
+ if request.url.path.endswith("/chat/completions"):
+ return httpx.Response(200, json={"choices": [{"message": message}]})
+ return httpx.Response(200, json={"data": [{"embedding": [0.1]}]})
+
+ async def run():
+ return await EverOSPort(
+ Path("/tmp/everos.sock"),
+ llm_base_url="https://llm.example.test/v1",
+ llm_model="chat",
+ llm_api_key="secret",
+ embedding_base_url="https://embed.example.test/v1",
+ embedding_model="embed",
+ embedding_api_key="secret",
+ ).preflight()
+
+ real_async_client = httpx.AsyncClient
+ with patch("core.memory.everos.httpx.AsyncClient", autospec=True) as client_type:
+ client_type.side_effect = lambda **kwargs: real_async_client(
+ transport=httpx.MockTransport(handler), **kwargs
+ )
+ result = asyncio.run(run())
+
+ assert result.ok is False
+ assert result.failure is not None
+ assert result.failure.diagnostic.message == expected
+
+
def test_processing_preflight_probes_configured_rerank_endpoint() -> None:
requests: list[httpx.Request] = []
recorded: list[dict[str, object]] = []
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index 3ca5b890b..ee8eb6625 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -1690,6 +1690,18 @@
"memory_multimodal_unavailable": "The attachment processing provider is unavailable",
"provider_request_timed_out": "The provider request timed out.",
"provider_response_too_large": "The provider response exceeded the safety limit.",
+ "provider_response_invalid": "The provider returned an invalid response.",
+ "provider_response_not_object": "The provider response was not a JSON object.",
+ "provider_response_missing_choices": "The provider response did not include choices.",
+ "provider_response_invalid_choice": "The provider response included an invalid choice.",
+ "provider_response_missing_message": "The provider response did not include an assistant message.",
+ "provider_response_missing_content": "The provider response did not include message content.",
+ "provider_response_invalid_content": "The provider response included invalid message content.",
+ "provider_response_invalid_role": "The provider response did not identify an assistant message.",
+ "provider_response_missing_finish_reason": "The provider response did not include a completion status.",
+ "provider_response_invalid_finish_reason": "The provider response included an invalid completion status.",
+ "provider_embedding_response_invalid": "The embedding provider returned an invalid response.",
+ "provider_rerank_response_invalid": "The reranking provider returned an invalid response.",
"provider_unavailable": "The provider is unavailable.",
"provider_error": "The provider rejected the request.",
"endpoint_not_configured": "The provider endpoint is not configured."
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index d2a8bafd0..10689639e 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -1690,6 +1690,18 @@
"memory_multimodal_unavailable": "附件处理服务商不可用",
"provider_request_timed_out": "提供商请求超时。",
"provider_response_too_large": "提供商响应超过安全限制。",
+ "provider_response_invalid": "提供商返回了无效响应。",
+ "provider_response_not_object": "提供商响应不是 JSON 对象。",
+ "provider_response_missing_choices": "提供商响应缺少 choices。",
+ "provider_response_invalid_choice": "提供商响应包含无效的 choice。",
+ "provider_response_missing_message": "提供商响应缺少 assistant 消息。",
+ "provider_response_missing_content": "提供商响应缺少消息内容。",
+ "provider_response_invalid_content": "提供商响应包含无效的消息内容。",
+ "provider_response_invalid_role": "提供商响应未标识 assistant 消息。",
+ "provider_response_missing_finish_reason": "提供商响应缺少完成状态。",
+ "provider_response_invalid_finish_reason": "提供商响应包含无效的完成状态。",
+ "provider_embedding_response_invalid": "Embedding 提供商返回了无效响应。",
+ "provider_rerank_response_invalid": "重排序提供商返回了无效响应。",
"provider_unavailable": "提供商不可用。",
"provider_error": "提供商拒绝了请求。",
"endpoint_not_configured": "尚未配置提供商端点。"