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(vibey): degrade unannotated citation markers (#2969)

Call Whitec290870df3d1
diff --git a/modules/agents/vibey/agent.py b/modules/agents/vibey/agent.py
index 88da1fef6..7677db9d9 100644
--- a/modules/agents/vibey/agent.py
+++ b/modules/agents/vibey/agent.py
@@ -90,7 +90,7 @@ from core.services.agent_steering import (
)
from core.backend_failure import emit_backend_failure
from core.agent_output import Narration, Reply, ToolActivity, TurnEnd, TurnOutcome, emit_output
-from core.citations import CitationBundle, register_text_citations
+from core.citations import CitationBundle, register_citations, register_text_citations
from core.hosted_activity import HostedActivity, hosted_line, native_activities, proxy_activity
from core.message_output import MessageOutput, terminal_output_for
from core.native_dispatch_phase import mark_backend_dispatch_attempted
@@ -1615,15 +1615,22 @@ class VibeyAgent(BaseAgent):
def _display_with_citations(
self, message: AssistantMessage, *, final: bool, replied: bool = False, images: Sequence[HostedImage] = ()
) -> tuple[str, Optional[CitationBundle]]:
- """The display text and, when the provider cited sources, the bundle that links them.
+ """The display text and citation bundle for provider citations or raw citation markers.
The same text ``_display_source`` gives, with each cited span carrying a
token that delivery writes out as a Markdown link (IM) and a badge (Web),
- through ``core.citations`` like every other backend's citations.
+ through ``core.citations`` like every other backend. A marker without
+ trustworthy structured source evidence is registered with an empty source
+ map and becomes the localized source-unavailable fallback instead.
"""
blocks = [(separator, block.text, block.citations or ()) for separator, block in text_parts(message)]
if not any(citations for _, _, citations in blocks):
- return self._display_source(message, final=final, replied=replied, images=images), None
+ body = self._display_source(message, final=final, replied=replied, images=images)
+ return register_citations(
+ body,
+ {},
+ unresolved_label=i18n_t("message.citationUnresolved", self._language()),
+ )
body, bundle = register_text_citations(
blocks,
unresolved_label=i18n_t("message.citationUnresolved", self._language()),
diff --git a/tests/test_vibey_agent.py b/tests/test_vibey_agent.py
index fd31ac71e..c08b8ebbf 100644
--- a/tests/test_vibey_agent.py
+++ b/tests/test_vibey_agent.py
@@ -5358,6 +5358,54 @@ async def test_an_answer_split_into_adjacent_text_blocks_reads_as_written(
assert [citation["url"] for citation in citations] == ([RELEASE] if cited else [])
[email protected]("platform", ["avibe", "telegram"])
+async def test_unannotated_citation_markers_degrade_before_delivery_and_reload(
+ engine, session, tmp_path, published, platform
+) -> None:
+ """A raw provider marker is safe fallback text, not Web syntax, without annotations."""
+ marker = "\ue200cite\ue202turn0view0\ue201"
+ answer = (
+ f"Claim {marker} repeats {marker}.\n\n"
+ f"Inline `{marker}` remains literal.\n\n"
+ f"```\n{marker}\n```"
+ )
+ expected = (
+ "Claim (source unavailable) repeats (source unavailable).\n\n"
+ f"Inline `{marker}` remains literal.\n\n"
+ f"```\n{marker}\n```"
+ )
+ harness = _Harness(engine, tmp_path, platform, [[Done(assistant(answer))]])
+
+ await harness.agent.handle_message(harness.request("show the answer"))
+
+ [result] = harness.rows("result")
+ assert result["content_text"] == expected
+ assert "citations" not in json.loads(result["content_json"])
+ if platform == "telegram":
+ assert expected in harness.controller.im_client.sent
+ return
+
+ live = [
+ payload
+ for name, payload in published
+ if name == "message.new" and payload.get("id") == result["id"]
+ ]
+ assert len(live) == 1
+ assert live[0]["content"]["text"] == expected
+ assert "citations" not in live[0]["content"]
+
+ from storage import messages_service
+
+ with engine.connect() as conn:
+ [reloaded] = [
+ row
+ for row in messages_service.list_session_messages(conn, session_id=SESSION)["messages"]
+ if row["id"] == result["id"]
+ ]
+ assert reloaded["text"] == expected
+ assert "citations" not in (reloaded["content"] or {})
+
+
async def test_a_native_hosted_call_reaches_the_workbench_as_a_card_and_cited_answer(
engine, session, tmp_path, published
) -> None: