Skip to content

fix(agent-email): /query error events carry raw exception text for Lemonade-down instead of actionable copy #2139

Closed

Description

@itomek

The sidecar's /v1/email/query loop emits str(exc) verbatim as the terminal error detail (query_routes.py error path). For the most common consumer failure — Lemonade Server not running/reachable — a raw exception repr reaches the client instead of the actionable "make sure Lemonade Server is running" guidance every other agent surface provides.

PR #2136 mitigates at the host boundary: the Agent UI relay appends an actionable hint when the detail matches connection/timeout-shaped patterns (never replacing the original text). The root fix belongs sidecar-side so ALL /query clients (CLI, gaia api, third-party) get actionable copy, not just the Agent UI: classify connection-shaped failures from the sidecar's own Lemonade client and emit the standard guidance in the error event detail, keeping the original exception text appended for debugging.

Acceptance: with Lemonade stopped, POST /v1/email/query returns a terminal error event whose detail leads with actionable guidance (what failed, what to do, where to look) and a test feeds a realistic ConnectionError (not a hand-written friendly string).

Ships via the agent release pipeline (hub/agents/python/email), independent of #2136.

Activity

  1. added
    enhancement
    agent::email
    on Jul 16, 2026
  2. github-actions commented on Jul 16, 2026

    @github-actions
    Contributor

    Confirmed — this is a real gap, and the fix belongs sidecar-side as you describe. When the agent run fails, the terminal error carries the raw exception text with no actionable guidance, so a Lemonade-down failure reaches every /query client (CLI, gaia api, third-party) as an opaque repr rather than "what failed / what to do / where to look." PR #2136 only patches the Agent UI relay, so those other clients stay in the dark.

    The right place to classify is where the exception is first caught and turned into the terminal error event, appending the original text for debugging rather than replacing it — exactly the shape your acceptance criteria call for. Good call insisting the test drive a realistic ConnectionError through the real path instead of asserting on a hand-written friendly string; that's the difference between proving the classifier fires and just proving a constant exists.

    One thing to nail down: reuse the canonical Lemonade-unreachable copy the rest of GAIA already emits rather than writing new wording here, so the guidance is consistent across surfaces.

    🔍 Technical details
    • Error path: hub/agents/python/email/gaia_agent_email/query_routes.py:346-348 — except Exception as exc: ... handler._emit({"type": "agent_error", "content": str(exc)}). That str(exc) is the raw repr that surfaces in the terminal error {detail} event (contract §3, canonical event set at query_routes.py:256-261).
    • Fix shape: classify connection/timeout-shaped failures from the sidecar's own Lemonade client at this catch site and lead the detail with actionable guidance, then append the original str(exc) for debugging. This keeps the "no silent fallback / fail loudly + name what to do" rule from CLAUDE.md and covers all clients, not just the Agent UI relay from feat(ui): route email chat through the sidecar /v1/email/query loop (V2-10) #2136.
    • Reuse existing copy: the canonical actionable pattern ("not reachable at …", "Run gaia init … or set LEMONADE_BASE_URL") lives in the core install/init paths (e.g. src/gaia/installer/init_command.py, and LemonadeClientError / LemonadeAuthError at src/gaia/llm/lemonade_client.py:496-500). Prefer classifying on the client's own exception types over string-matching the message.
    • Docs sync: per CLAUDE.md's bundled-doc rule, if the error contract is described in the email agent's CONTRACT.md / SPEC-equivalent / openapi.email.json, update the error-detail wording there in the same change.
    • Independent of feat(ui): route email chat through the sidecar /v1/email/query loop (V2-10) #2136 and ships via the email agent release pipeline (hub/agents/python/email), as noted.
  3. itomek commented on Jul 23, 2026

    @itomek
    CollaboratorAuthor

    Adjacent error-copy problem worth folding in: when a multi-step email turn exceeds the AgentUI→sidecar relay read-timeout (300s, src/gaia/ui/email_sidecar/relay.py:334) on slow inference, the user-facing error is "Email agent stream ended unexpectedly (the sidecar may have crashed). Check the sidecar log…" — but the sidecar had not crashed (still healthy, gaia daemon agents shows it running; the daemon log shows a clean Read timed out, not a crash). Reproduced 2× on t-win-acer-swft (iGPU ~12 tok/s) with "What meetings are being requested in my inbox?" (5-step loop). The message misattributes a timeout to a crash and sends the user log-hunting for a process that's fine. Root perf driver is the NPU FLM model not being downloaded (falls back to iGPU); but the message should say "timed out after 300s" not "may have crashed".

  4. itomek-amd commented on Jul 23, 2026

    @itomek-amd
    Collaborator

    Repro on a second machine (no-NPU Ryzen 7 PRO 6850U, iGPU ~60–90s per agent step). Bulk triage of 15 messages via the Agent-UI stream surfaced an agent_error at ~317s while the sidecar kept triaging server-side — the log shows triage_decision / triage_dispatch entries continuing after the stream had already errored and closed. Matches the 300s relay read-timeout described here: the client sees a "failure" but the tool is still running to completion. No ctx-overflow was involved (that part completed fine).

  5. added 2 commits that reference this issue on Jul 24, 2026
    4301c89
    3f6af0f
  6. added a commit that references this issue on Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent::emailenhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions