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
"""User-facing copy for the built-in agent's failures, named by the catalog.
``AgentError.kind`` is the engine's stable discriminator (loop-control.md section 6);
``AgentError.message`` is diagnostic detail and is never shown as display copy.
Every kind maps to one ``vibe/i18n`` key under ``vibeyAgent.error``.
"""
from __future__ import annotations
from typing import Optional
from core.agent_core.agent.events import NAMED_ERROR_KINDS
from core.agent_core.ai._common import PROVIDER_SILENCE_TIMEOUT_S
from modules.agents.catalog import display_name_for_backend
from vibe.i18n import t as i18n_t
# Every named engine and provider kind (``NAMED_ERROR_KINDS``: C-2 error classification, C-3 run outcomes) has copy
# of its own; a contract test holds the two sets equal.
_KIND_KEYS: dict[str, str] = {
"refusal": "refusal",
"safety": "safety",
"empty_response": "emptyResponse",
"dependency_cancelled": "interrupted",
"aborted": "interrupted",
"overflow": "contextExhausted",
"context_exhausted": "contextExhausted",
# The newest unit alone cannot fit (C-9 section 8 d): starting over would not help, so the copy says what to do.
"tool_output_too_large": "toolOutputTooLarge",
"input_too_large": "inputTooLarge",
"step_too_large": "stepTooLarge",
"rate_limit": "rateLimit",
"overloaded": "overloaded",
"network": "network",
"stalled": "stalled",
"server": "server",
# The provider's stream broke off before its terminal (Model Hub's own frame), not a run the user stopped.
"interrupted": "streamInterrupted",
"auth": "auth",
"invalid_request": "invalidRequest",
# A provider failure C-2 could not classify: an unknown code, or an error frame no rule names.
"unknown": "unclassified",
"error": "modelError",
# An explicit output-limit stop with no answer, or repeatedly truncated tools.
"length": "outputLimit",
# Tool calls under a stop reason that cannot carry them.
"stop": "providerProtocol",
"stream_cleanup": "internal",
# A context row this build cannot read (a shape it no longer accepts): the session cannot continue.
"TranscriptError": "historyUnreadable",
# Model Hub could not route a later model call of the Turn. A refusal that explains itself (no Source, all cooling
# down) shows its own copy first (``_preflight``); this names the rest instead of calling it an internal error.
"ModelHubError": "modelHubRoute",
# The loop refuses a route that declares no tool support before any request.
"UnsupportedModelRoute": "toolsUnsupported",
# A provider answer the canonical transcript cannot hold.
"ProviderProtocolViolation": "providerProtocol",
}
# Run reasons that carry their own copy when no error event names a kind.
_REASON_KEYS: dict[str, str] = {
"context_exhausted": "contextExhausted",
"aborted": "interrupted",
}
def error_key(kind: Optional[str], *, reason: Optional[str] = None) -> str:
"""The i18n key for an error kind, falling back to the run reason, then to generic copy.
A kind outside ``NAMED_ERROR_KINDS`` names an exception the loop did not expect: an internal error.
"""
name = _KIND_KEYS.get(kind or "")
if name is None and kind and kind not in NAMED_ERROR_KINDS:
name = "internal"
name = name or _REASON_KEYS.get(reason or "") or "generic"
return f"vibeyAgent.error.{name}"
def error_text(kind: Optional[str], lang: str, *, reason: Optional[str] = None) -> str:
return i18n_t(
error_key(kind, reason=reason),
lang,
backend=display_name_for_backend("vibey"),
minutes=f"{PROVIDER_SILENCE_TIMEOUT_S / 60:g}",
)