🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(home-inbox): make the run-failed error brief human-readable (#17373)
Arvin Xu3ce5ebbb6856
diff --git a/.agents/skills/ux-audit/references/example/home-inbox-error.md b/.agents/skills/ux-audit/references/example/home-inbox-error.mdnew file mode 100644index 00000000000..837fa3d6a73--- /dev/null+++ b/.agents/skills/ux-audit/references/example/home-inbox-error.md@@ -0,0 +1,133 @@+# Worked example — HomeInbox「需要你处理」error brief card 审计++A real run of this skill against the Home Inbox error-brief card (`src/features/HomeInbox`),+2026-07, triggered by the raw string **"T-1 topic #1 (tpc\_5UBuAjUU4z6B) error" /+"Execution failed: Workspace budget exceeded"** shown to the user. Surface = one error-type+brief card in the "需要你处理" (needsYou) column: meta row (`StatusGlyph` + task ref + task+name + time) → agent avatar + headline + summary → action row (`忽略` / `重试`).++**Layers run:** L1 (static / code) ✅. L2 (visual) ✅ — the user's screenshot of the rendered+card is real render evidence. L3 (dynamic) ⏳ not run — reproducing needs a task forced to a+terminal error; see §5 for what it'd add.++**Surface class + norms** (actionable error notification in an inbox — cf. GitHub Actions+failed run, Vercel failed deploy, Sentry issue, Linear notification). A mature card of this+class: ① reads **as an error** at a glance (color/icon severity, not text alone); ② states+**what** failed in human terms, **which** entity, **when**; ③ states **why** (cause), mapped+to a known/actionable cause where possible; ④ offers **recovery** (Retry); ⑤ offers+**dismiss** (Ignore); ⑥ offers **inspect** (open the failing run / logs); ⑦ when the cause is+user-actionable (budget), a **direct path to the fix** (top-up / upgrade); ⑧ a+feedback/report channel. Audit gaps below are measured against this list, not only the code.++## 1 — Patterns in use++| Pattern (family) | Where | Rating | Note |+| ------------------------------------- | ------------------------------------------------------------------- | ------ | -------------------------------------------------------------------- |+| Card Stack / Titled Sections (layout) | `needsYou` list under "需要你处理" (`HomeInbox/index.tsx:193`) | ✅ | grouped, errors sorted last (`splitBriefs.ts`) |+| Failure + Retry (feedback) | error brief → `重试` (`BriefCardActions.tsx:238`) | ⚠️ | Retry present, but bare on a deterministic (budget) cause |+| Button Groups (action) | `忽略` / `重试` (`BriefCardActions.tsx:228-247`) | ✅ | dismiss + recover grouped |+| Same-Page / Inline error (feedback) | error rendered in-card, not a wipe | ✅ | keeps the inbox intact |+| Status glyph / severity (feedback) | meta-row `StatusGlyph` (`StatusGlyph.tsx`) | ⚠️ | on error task = `paused`/`scheduled` → **hand/neutral, not failure** |+| Overview + Detail (data) | "View run" → topic drawer (`BriefCardActions.tsx:66`) | ⚠️→✅ | was dead (no `topicId` on brief); now wired (this run) |+| Error-message copy (feedback §4.5) | headline + summary (`InboxBriefCard.tsx`, `taskLifecycle/index.ts`) | ⚠️→✅ | was log-style w/ raw id; fixed this run |+| Remedy path for actionable cause | budget-exceeded → top-up/upgrade | — | **absent** — no link to billing (gap ②) |++**Read:** the card's skeleton (group, dismiss/recover buttons, in-card render) is sound; the+weakness clusters entirely in **Feedback** — how the failure _reads_ (copy, severity glyph)+and whether the offered action can actually resolve the cause.++## 2 — Strengths / good cases (don't regress)++- **✅ 亮点 — Errors are a first-class, sorted bucket.** `splitBriefs.ts` routes `error` ++ `decision` to `needsYou` and sorts errors last, so a failure always surfaces in the "needs+ you" column rather than being lost in the news feed — the inbox never silently swallows a+ failed run.+- **✅ 亮点 — In-card recover + dismiss, no surface wipe.** `重试` / `忽略` resolve in place+ (`BriefCardActions.tsx`) and the rest of the inbox stays intact — a Same-Page-error done+ right; the failure hands control back without blowing the surface away.+- **✅ 亮点 — Error copy fixed to human-facing (→ landed as ux §4.5 ✅).** Post-fix the headline+ localizes at the card (`t('inbox.error.title')`), the cause shows as a clean clause, and the+ topic id moved to the structured `topicId` field that lights up "View run" — the ✅ example+ now cited beside the new Feedback §4.5.++> ⚠️ **Review catch — the localized headline must be scoped, not blanket.** The first+> implementation overrode the title for _every_ `type: 'error'` brief, but there are **5**+> error-brief producers, and 4 carry legitimately distinct titles: verify (`failed+verification` / `verification errored`, `verify/settle.ts`), heartbeat (`heartbeat timeout`,+> `watchdog.ts` / `task.ts`), and agent-signal (`brief.agentSignal.selfReview.error.title` —+> **already localized** server-side, `briefText.ts`). A blanket "运行失败" clobbered all of+> them. Fix: scope the override to the run-failure brief only (server stores the stable English+> `<id> run failed`; client localizes just that, falls back to the stored title otherwise).+> Lesson for the checklist: **before overriding a shared record type's user-facing field by+> `type`, enumerate every producer of that type** — a `type` is rarely single-source.++## 3 — Experience gaps (ranked)++**① Log-style copy with internal ids — ux §4.5 (Meaningful)** 🟠 **\[fixed this run]** Title+`` `${taskIdentifier} topic #${seq} (${topicId}) error` `` → "T-1 topic #1 (tpc\_5UBuAjUU4z6B)+error": raw topic id in the headline, `topic #N` log syntax, `T-1` duplicated from the meta+row; summary `` `Execution failed: ${raw}` `` carried the console-line prefix; both+English-only for every locale. Evidence L1 (`taskLifecycle/index.ts` error brief) + L2+(screenshot). **Remedy (done):** localize the framing at the card, store a clean English+fallback, move the id onto structured `topicId`.++**② A deterministic cause offers only a futile Retry — ux §4.2 (Meaningful・Certainty)** 🟠+"Workspace budget exceeded" is a **deterministic, user-actionable** cause — retrying the same+run just re-hits the same wall — yet the card offers only `重试` / `忽略`, no path to the fix+(top-up / upgrade / billing). Evidence L1 (`BriefCardActions.tsx:238` bare Retry;+`taskLifecycle` stores raw cause, no error-type → action mapping) + L2 (only 忽略 / 重试 render).+**Remedy:** map known terminal error types (`InsufficientBudgetForModel` →+`limitation.workspace.insufficientBudget.*`) to a **remedy action** (link to billing/top-up)+that leads the row; keep Retry as secondary only for transient causes. _(Done — the+completion event's structured `errorType` is threaded through both `onTopicComplete`+callers into the brief; billing causes get an `upgrade` link action + `metadata.error.code`,+and `BriefCardActions` was fixed so a link-type primary navigates. Verified via agent-testing+T-220: budget card renders 忽略 + 升级方案 → app.lobehub.com/settings/plans, no 重试.)_++**③ The card doesn't read AS an error — severity legibility (Certainty)** 🟠 The only status+cue is the meta-row `StatusGlyph`, driven by **task status** — but on error the task is set to+`paused` (ad-hoc, `taskLifecycle/index.ts:260`) or `scheduled` (automation manual run, `:269`),+and `task:paused` **deliberately renders as the "waiting for human" hand** (`StatusGlyph.tsx:15-19`).+So a _failed_ run shows the same neutral/pending glyph as a healthy pause — no red, no alert+icon (confirmed L2: the screenshot's 🤚 is that hand). The card leans entirely on copy to say+"error". **Remedy:** for `type === 'error'` briefs give the card an error accent (error-colored+alert glyph on the content, or drive the glyph to a failure visual) so severity is legible+pre-reading. _(Done — a red `CircleAlert` renders on the headline for `type: 'error'` briefs.+Verified via agent-testing T-220.)_++**④ "View run" was dead on error briefs — Overview+Detail (Meaningful)** 🟡 **\[fixed this run]**+`showViewRun = taskId && topicId` (`BriefCardActions.tsx:66`), but the error brief's `create()`+never passed `topicId` — so the one affordance to **inspect why it failed** never rendered; the+user could Retry or Ignore but not _look_. **Remedy (done):** pass `topicId` to the error brief+so "View run" appears. Verified via agent-testing T-220: both seeded briefs carrying a+`topicId` render a visible 查看运行轨迹 entry; the legacy brief without one does not.++**⑤ `忽略` is a permanent dismiss with no undo — Act (Certainty)** 🟡 `忽略` resolves the brief+(`handleResolve('ignore')`) with no confirm/undo; an error dismissed by accident is gone from+the inbox. Low severity (the run is still in the task list), noted not landed.++## 4 — Skill feedback++- **Landed as new `ux` items (回灌):**+ - **Feedback §4.5 — "Error copy is written for a human, not a log line"** (new subsection ++ 4 checklist items + Quick-review mirror), citing the inbox error brief as the ❌ example and+ the fix as ✅. Covers: no internal id / no log framing / no meta-row duplication / localized.+ - **Feedback §4.2 — deterministic-cause extension** (new checklist item): a failure whose fix+ lives elsewhere (budget/quota/permission) leads with the **remedy action**, not a bare Retry.+ Mirrored into Quick review.+- **Validated existing rules:** §4.2 "failed state names the failure + offers Retry" (the card+ has Retry) and the Retry-gating principle (extended by gap ②).+- **Good case landed as ✅:** the fixed human-facing copy → §4.5 ✅ example.+- **Concrete fixes shipped this run:** gap ① (copy) + gap ④ (View-run wiring), with a+ server-side regression test (`onTopicComplete.test.ts` — brief title/summary carry no+ internal id / log framing, `topicId` on the structured field).+- **Follow-ups (not landed):** gap ② (remedy-action mapping), gap ③ (error severity glyph) —+ worth a Linear sub-issue under a "HomeInbox UX" parent.++## 5 — Pending: L3 dynamic++- Force a task to a terminal **budget-exceeded** error and confirm live: (a) "View run" now+ renders (gap ④ fix), (b) the card still reads as pending not failed (gap ③), (c) `重试`+ re-runs and re-fails immediately (gap ② — proves the futile-Retry claim behaviorally).+- Confirm the localized headline renders for a zh-CN session and legacy rows (with the old+ `Execution failed:` prefix) get the defensive strip.diff --git a/.agents/skills/ux/SKILL.md b/.agents/skills/ux/SKILL.mdindex b83fef354ed..1b29c32b8cf 100644--- a/.agents/skills/ux/SKILL.md+++ b/.agents/skills/ux/SKILL.md@@ -145,6 +145,7 @@ The one-screen scan. Each line links back to a module above for the full rule +- [ ] A compound gate waiting on a secondary/dependent fetch gates on its **in-flight** flag and releases on settled (data / resolved-`null` / error) — never on the dependency being present in a map, or an absent-by-design dependency hangs it forever. An error branch **ordered after** a data-presence gate (`{error && …}` below `if (isLoading = !map[id]) return <Skeleton/>`) is unreachable on first-load failure — it paints only on revalidation, and a resolved-`null` not-found hangs the same permanent skeleton; check error/not-found **before** the gate.- [ ] An awaited write that gates navigation/advance resets its busy flag in `finally` + offers retry — a failed write never permanently disables the forward/Back control.- [ ] Autosave surfaces a save-state (saving → saved → failed with retry), never a silent write; the save-state enum actually includes a `failed` variant (a catch that resets to `idle` is a silent write); one save-feedback convention across a multi-field surface, ideally in the shared form wrapper.+- [ ] Error copy is written for a human, not a log line (§4.5): no internal id (`tpc_…` / uuid / `#N` seq) or log framing (`Execution failed:` / `Error:`) in the headline — the id rides a structured field powering "View run", the framing is localized via i18n at the view, and the body doesn't repeat identity the meta row already shows. A **deterministic-cause** failure (budget/quota → top-up・upgrade; permission → request access) leads with the **remedy action**, not a bare Retry that just re-fails.- [ ] Capability-gated feature warns (soft, reactive, load-gated) when the model can't deliver it; copy gives the remedy.**Grow — discoverability & progressive disclosure** ([grow.md](references/grow.md))diff --git a/.agents/skills/ux/references/feedback.md b/.agents/skills/ux/references/feedback.mdindex cf6329f19c5..8b67c9e0f2b 100644--- a/.agents/skills/ux/references/feedback.md+++ b/.agents/skills/ux/references/feedback.md@@ -278,6 +278,7 @@ tail, kept distinct from the genuine end-of-list.- [ ] An awaited write that gates navigation resets its in-progress flag in `finally` and offers retry on `catch` — a failed write never permanently disables the advance / Back control. _(Certainty)_- [ ] The failed state names the failure and offers a **Reload / Retry** action. _(Meaningful)_- [ ] Retry is **gated on retryability**, not shown unconditionally — a `401` / `403` (or `meta.shouldRetry === false`) failure renders the reason but **omits Retry** (a retry there just fails again); derive it from the normalized error status, not per-surface. `401` session-expiry is assumed handled by a **global** redirect to sign-in, so a surface does not add its own redirect layer. _(Certainty・Meaningful)_+- [ ] A **deterministic-cause** failure whose fix lives elsewhere (budget / quota exceeded → top-up・upgrade; permission denied → request access; config invalid → open settings) leads with the **remedy action**, not a bare **Retry** — retrying the same run reproduces the same failure, so an unqualified Retry is a false promise. Map the known terminal error type to its action; keep Retry only as the secondary for genuinely transient causes. _(Meaningful・Certainty)_- [ ] Retry re-runs the same fetch, shows loading while re-running, and stays available on repeat failure. _(Certainty)_- [ ] Already-loaded context is preserved on failure — don't wipe the surface. _(Meaningful)_- [ ] In an auto-dismissing surface (upload dock / progress toast), auto-dismiss fires on **success only** — a failed item persists with a Retry, never cleared by the countdown. _(Certainty・Meaningful)_@@ -389,3 +390,44 @@ just moves it onto the button.- [ ] The save-state enum can **represent** failure — a `failed` variant exists and the write's `catch` drives it, not a reset to `idle` / neutral. _(Certainty)_- [ ] A failed autosave shows an inline error **with retry** and keeps the edited value. _(Meaningful)_- [ ] One save-feedback convention across a multi-field surface — ideally baked into the shared form wrapper, not re-invented per tab. _(Certainty)_++## 4.5 Error copy is written for a human, not a log line・Meaningful・Certainty++An error surfaced to the user is **product copy**, held to the same bar as any other string+in the UI — yet error paths are where raw internals leak, because the text is often+assembled far from the view (a server lifecycle hook, a `catch` that interpolates the thrown+message) and never passes an i18n file. Three smells mark a message that escaped that bar:++- **Internal ids in the headline** — a raw `tpc_…` / `msg_…` / uuid, a `#N` sequence, an+ operation id. The id is for a **log or an inspect link**, never the sentence the user reads;+ it belongs on a **structured field** (`topicId`, `taskId`) that powers a "View run" affordance,+ not baked into the title. A human reading "topic #1 (tpc\_5UBuAjUU4z6B)" learns nothing and+ distrusts the whole card.+- **Log / stack framing** — `Execution failed: …`, `Error: …`, `[TaskLifecycle]`, a+ prefixed severity. Framing that reads like a console line signals "this wasn't meant for+ you". State what happened in a plain clause; drop the engineering prefix.+- **Redundancy with the surface** — repeating identity the card's meta row already shows+ (the task ref, the agent name). If the row says `T-1 · 标题灵感`, the body headline restating+ `T-1 … error` is noise; the body should carry the _new_ information (what failed, why).++And because the copy is human-facing, it must be **localized** — a server-assembled error+string is English-only and reaches a zh user untranslated. Push the **framing** through+i18n at the view (`t('…error.title')`), keep the stored string a clean English fallback free+of the smells above, and localize the _cause_ too where it maps to a known error type+(don't hand-translate an arbitrary provider message — surface it as honest detail).++> ✅ The HomeInbox error brief headline is localized at the card (`t('inbox.error.title')` →+> "运行失败"), the cause shows as a clean clause, and the topic id rides the structured+> `topicId` field that lights up "View run" (`InboxBriefCard.tsx`,+> `taskLifecycle/index.ts` error brief). ❌ Its prior form baked the lot into the stored+> string — title `` `${taskIdentifier} topic #${seq} (${topicId}) error` `` → **"T-1 topic #1+> (tpc\_5UBuAjUU4z6B) error"**, summary `` `Execution failed: ${raw}` `` — internal id in the+> headline, log framing, task ref duplicated from the meta row, and English-only for every+> locale.++**Checklist**++- [ ] No internal id (`tpc_…` / uuid / `#N` seq / operation id) in the user-facing headline or body — it rides a **structured field** powering an inspect / "View run" link, never the sentence. _(Meaningful)_+- [ ] No log / stack framing in the copy — drop `Execution failed:` / `Error:` / `[Module]` prefixes; state what happened as a plain clause. _(Meaningful)_+- [ ] The message doesn't repeat identity the surface's meta row already shows (task ref, agent name) — the body carries the _new_ info (what failed, why). _(Certainty)_+- [ ] Error framing is **localized** through i18n at the view; any server-assembled stored string is a clean English fallback (no id / no log prefix), and a known error _cause_ is localized too. _(Meaningful・Certainty)_diff --git a/apps/server/src/services/taskLifecycle/index.ts b/apps/server/src/services/taskLifecycle/index.tsindex 9a0cce9ad33..17753b8ff59 100644--- a/apps/server/src/services/taskLifecycle/index.ts+++ b/apps/server/src/services/taskLifecycle/index.ts@@ -1,3 +1,4 @@+import { BRANDING_URL } from '@lobechat/business-const';import { TRACING_SCENARIOS } from '@lobechat/const';import type { TracingOptions } from '@lobechat/llm-generation-tracing';import {@@ -15,6 +16,7 @@ import {TASK_TOPIC_HANDOFF_SCHEMA_NAME,} from '@lobechat/prompts';import type {+ BriefAction,BriefArtifacts,BriefDecision,TaskItem,@@ -23,7 +25,7 @@ import type {TaskSchedulerContext,TaskTopicHandoff,} from '@lobechat/types';-import { DEFAULT_BRIEF_ACTIONS } from '@lobechat/types';+import { ChatErrorType, DEFAULT_BRIEF_ACTIONS } from '@lobechat/types';import debug from 'debug';import { BriefModel } from '@/database/models/brief';@@ -32,6 +34,7 @@ import { TaskTopicModel } from '@/database/models/taskTopic';import { TopicModel } from '@/database/models/topic';import { VerifyRunModel } from '@/database/models/verifyRun';import type { LobeChatDatabase } from '@/database/type';+import { translation } from '@/libs/i18n/serverTranslation';import { initModelRuntimeFromDB } from '@/server/modules/ModelRuntime';import { SystemAgentService } from '@/server/services/systemAgent';import { TaskResultBridgeService } from '@/server/services/taskResultBridge';@@ -68,7 +71,21 @@ const isTerminal = (status: string) => TERMINAL_STATUSES.has(status);// for now; move to task.config later if it needs to be tunable per-task.const AUTOMATION_FAILURE_FUSE = 3;+// Terminal error codes whose fix lives in billing, not in a retry — running the+// same task again just reproduces the same wall. For these the error brief leads+// with an "Upgrade" remedy instead of a futile Retry (ux Feedback §4.2).+// Everything else keeps the default retry + feedback actions.+const BILLING_ERROR_CODES = new Set<string>([+ ChatErrorType.InsufficientBudgetForModel,+ ChatErrorType.FreePlanLimit,+ ChatErrorType.SubscriptionPlanLimit,+ ChatErrorType.WorkspaceSubscriptionInactive,+]);+export interface TopicCompleteParams {+ /** Structured terminal error type (e.g. `InsufficientBudgetForModel`) from the+ * completion lifecycle event, used to pick the error brief's remedy action. */+ errorCode?: string;errorMessage?: string;lastAssistantContent?: string;operationId: string;@@ -114,7 +131,15 @@ export class TaskLifecycleService {* Flow: updateHeartbeat → updateTopicStatus → handoff → review → checkpoint*/async onTopicComplete(params: TopicCompleteParams): Promise<void> {- const { taskId, taskIdentifier, topicId, reason, lastAssistantContent, errorMessage } = params;+ const {+ taskId,+ taskIdentifier,+ topicId,+ reason,+ lastAssistantContent,+ errorMessage,+ errorCode,+ } = params;log('onTopicComplete: task=%s topic=%s reason=%s', taskIdentifier, topicId, reason);@@ -232,19 +257,67 @@ export class TaskLifecycleService {} else if (reason === 'error') {if (topicId) await this.taskTopicModel.updateStatus(taskId, topicId, 'failed');- const topicSeq = currentTask?.totalTopics || '?';- const topicRef = topicId ? ` #${topicSeq} (${topicId})` : '';const errorText = errorMessage || 'Unknown error';+ // A budget / plan failure won't clear on a blind Retry — lead the card with+ // the fix (Upgrade → plans page) instead. Other causes keep retry + feedback.+ const isBillingError = errorCode ? BILLING_ERROR_CODES.has(errorCode) : false;+ const errorActions: BriefAction[] =+ isBillingError && BRANDING_URL.subscription+ ? [+ {+ key: 'upgrade',+ label: 'Upgrade plan',+ type: 'link',+ url: BRANDING_URL.subscription,+ },+ { key: 'feedback', label: '💬 Feedback', type: 'comment' },+ ]+ : DEFAULT_BRIEF_ACTIONS['error'];++ // Resolve the user-facing copy in the user's language, at the source (not+ // by string-munging on the client):+ // - title: a plain localized "run failed" — the task identity already sits+ // in the card's meta row, so the headline needn't repeat it.+ // - summary: map the structured error code to the same human, localized+ // message the chat error card shows. The copy for a code lives in exactly+ // one of two namespaces — `modelRuntime:<code>` (runtime codes) or+ // `error:response.<code>` (HTTP status / Cloud ChatErrorType such as+ // `InsufficientBudgetForModel`) — so try both and take whichever resolves+ // (the server `t` returns the key unchanged when it has no entry). Fall+ // back to the raw runtime message for codes with no friendly copy, or copy+ // left with an unresolved `{{…}}` placeholder we can't fill here.+ const locale = await this.systemAgentService.getUserLocale();+ const [{ t: tHome }, { t: tRuntime }, { t: tError }] = await Promise.all([+ translation('home', locale),+ translation('modelRuntime', locale),+ translation('error', locale),+ ]);+ const resolveErrorSummary = () => {+ if (!errorCode) return errorText;+ const runtimeMsg = tRuntime(errorCode);+ if (runtimeMsg !== errorCode && !runtimeMsg.includes('{{')) return runtimeMsg;+ const responseKey = `response.${errorCode}`;+ const responseMsg = tError(responseKey);+ if (responseMsg !== responseKey && !responseMsg.includes('{{')) return responseMsg;+ return errorText;+ };+ const summary = resolveErrorSummary();+// Always surface an urgent error brief — a failed run is visible to the- // user regardless of what happens to the scheduling state below.+ // user regardless of what happens to the scheduling state below. The topic+ // id rides the structured `topicId` field (it also powers the card's+ // "View run" shortcut), never the headline.await this.briefModel.create({- actions: DEFAULT_BRIEF_ACTIONS['error'],+ actions: errorActions,agentId: currentTask?.assigneeAgentId || undefined,+ // Persist the structured cause for observability / future remedy mapping.+ metadata: errorCode ? { error: { code: errorCode } } : undefined,priority: 'urgent',- summary: `Execution failed: ${errorText}`,+ summary,taskId,- title: `${taskIdentifier} topic${topicRef} error`,+ title: tHome('inbox.error.title'),+ topicId,trigger: 'task',type: 'error',});diff --git a/apps/server/src/services/taskLifecycle/onTopicComplete.test.ts b/apps/server/src/services/taskLifecycle/onTopicComplete.test.tsindex 0fc76cd7a26..95f4a5ba314 100644--- a/apps/server/src/services/taskLifecycle/onTopicComplete.test.ts+++ b/apps/server/src/services/taskLifecycle/onTopicComplete.test.ts@@ -20,6 +20,17 @@ vi.mock('@/database/models/verifyRun', () => ({VerifyRunModel: vi.fn(() => ({ findByOperation: verifyFindByOperation })),}));+// Error-brief copy is localized at the source via the server translator; mock it+// with a tiny table so the error-branch tests can assert both the friendly-copy+// mapping (a known error code → its human message) and the raw-message fallback+// (unknown code → the key is returned unchanged, so the code falls back).+const FAKE_MESSAGES: Record<string, string> = {+ 'response.InsufficientBudgetForModel': 'Not enough credits — top up or upgrade to continue.',+};+vi.mock('@/libs/i18n/serverTranslation', () => ({+ translation: async () => ({ t: (key: string) => FAKE_MESSAGES[key] ?? key }),+}));+const baseTask = (overrides: Partial<TaskItem> = {}): TaskItem =>({automationMode: 'heartbeat',@@ -73,6 +84,8 @@ describe('TaskLifecycleService.onTopicComplete', () => {(service as any).taskTopicModel.updateHandoffContent = vi.fn().mockResolvedValue(undefined);(service as any).briefModel.create = createBrief;(service as any).briefModel.hasUnresolvedUrgentByTask = vi.fn().mockResolvedValue(false);+ // The error branch resolves the user's locale for brief copy.+ (service as any).systemAgentService.getUserLocale = vi.fn().mockResolvedValue('en-US');});afterEach(() => {@@ -493,6 +506,81 @@ describe('TaskLifecycleService.onTopicComplete', () => {expect.objectContaining({ priority: 'urgent', type: 'error' }),);});++ it('error brief keeps internal ids out of the user-facing copy', async () => {+ const task = baseTask({ automationMode: 'schedule' });+ findById.mockResolvedValue(task);++ await service.onTopicComplete({+ errorMessage: 'Workspace budget exceeded',+ operationId: 'op-1',+ reason: 'error',+ runTrigger: 'manual',+ taskId: 'task-1',+ taskIdentifier: 'TASK-1',+ topicId: 'topic-1',+ });++ const brief = createBrief.mock.calls.at(-1)?.[0];+ // Title/summary are human-facing: no raw topic id, no "topic #N", no+ // "Execution failed:" log framing. The topic id lives on `topicId`.+ expect(brief.title).not.toContain('topic-1');+ expect(brief.title).not.toMatch(/topic #/i);+ expect(brief.summary).not.toMatch(/execution failed/i);+ expect(brief.summary).toBe('Workspace budget exceeded');+ expect(brief.topicId).toBe('topic-1');+ });++ it('a budget error leads with an upgrade remedy instead of a futile retry', async () => {+ const task = baseTask({ automationMode: 'schedule' });+ findById.mockResolvedValue(task);++ await service.onTopicComplete({+ errorCode: 'InsufficientBudgetForModel',+ errorMessage: 'Workspace budget exceeded',+ operationId: 'op-1',+ reason: 'error',+ runTrigger: 'manual',+ taskId: 'task-1',+ taskIdentifier: 'TASK-1',+ topicId: 'topic-1',+ });++ const brief = createBrief.mock.calls.at(-1)?.[0];+ const keys = brief.actions.map((a: { key: string }) => a.key);+ // Retrying a budget failure just re-fails — offer the fix, not Retry.+ expect(keys).toContain('upgrade');+ expect(keys).not.toContain('retry');+ const upgrade = brief.actions.find((a: { key: string }) => a.key === 'upgrade');+ expect(upgrade.type).toBe('link');+ expect(upgrade.url).toBeTruthy();+ // Structured cause persisted for observability / future mapping.+ expect(brief.metadata).toEqual({ error: { code: 'InsufficientBudgetForModel' } });+ // Summary is the human, localized message mapped from the error code — not+ // the raw provider string.+ expect(brief.summary).toBe('Not enough credits — top up or upgrade to continue.');+ });++ it('a non-billing error keeps the default retry action', async () => {+ const task = baseTask({ automationMode: 'schedule' });+ findById.mockResolvedValue(task);++ await service.onTopicComplete({+ errorCode: 'ProviderBizError',+ errorMessage: 'upstream 500',+ operationId: 'op-1',+ reason: 'error',+ runTrigger: 'manual',+ taskId: 'task-1',+ taskIdentifier: 'TASK-1',+ topicId: 'topic-1',+ });++ const brief = createBrief.mock.calls.at(-1)?.[0];+ const keys = brief.actions.map((a: { key: string }) => a.key);+ expect(keys).toContain('retry');+ expect(keys).not.toContain('upgrade');+ });});describe('reason=done recovery audit (LOBE-11390)', () => {diff --git a/apps/server/src/services/taskRunner/index.ts b/apps/server/src/services/taskRunner/index.tsindex 372b209be4b..6c2a574afa9 100644--- a/apps/server/src/services/taskRunner/index.ts+++ b/apps/server/src/services/taskRunner/index.ts@@ -197,6 +197,7 @@ export class TaskRunnerService {{handler: async (event) => {await taskLifecycle.onTopicComplete({+ errorCode: event.errorType,errorMessage: event.errorMessage,lastAssistantContent: event.lastAssistantContent,operationId: event.operationId,diff --git a/apps/server/src/workflows-hono/task/handlers/onTopicComplete.ts b/apps/server/src/workflows-hono/task/handlers/onTopicComplete.tsindex 5ad18f168cf..38c7cdb4086 100644--- a/apps/server/src/workflows-hono/task/handlers/onTopicComplete.ts+++ b/apps/server/src/workflows-hono/task/handlers/onTopicComplete.ts@@ -11,6 +11,10 @@ const log = debug('lobe-server:workflows:task:on-topic-complete');export interface OnTopicCompletePayload {errorMessage?: string;+ /** Structured terminal error type (e.g. `InsufficientBudgetForModel`). Spread+ * onto the webhook body from the completion lifecycle event (no eventFields+ * filter), used to pick the error brief's remedy action. */+ errorType?: string;hookId?: string;hookType?: string;lastAssistantContent?: string;@@ -29,6 +33,7 @@ export async function onTopicComplete(c: Context) {const body = (await c.req.json()) as OnTopicCompletePayload;const {errorMessage,+ errorType,lastAssistantContent,operationId,reason,@@ -63,6 +68,7 @@ export async function onTopicComplete(c: Context) {const taskLifecycle = new TaskLifecycleService(db, userId, wsId);await taskLifecycle.onTopicComplete({+ errorCode: errorType,errorMessage,lastAssistantContent,operationId,diff --git a/locales/en-US/home.json b/locales/en-US/home.jsonindex 5d4dbcdba68..62dbc2fd679 100644--- a/locales/en-US/home.json+++ b/locales/en-US/home.json@@ -10,6 +10,7 @@"brief.action.feedback": "Feedback","brief.action.ignore": "Ignore","brief.action.retry": "Retry",+ "brief.action.upgrade": "Upgrade plan","brief.addFeedback": "Share feedback","brief.agentSignal.selfReview.applied.heading": "Updated","brief.agentSignal.selfReview.applied.summary": "{{count}} dream update was applied.",@@ -45,6 +46,7 @@"homePromoBanner.dismiss": "Dismiss","homePromoBanner.label": "{{model}} is now available","inbox.author.scheduled": "Scheduled",+ "inbox.error.title": "Run failed","inbox.needsYou.title": "Needs you","inbox.news.markAllRead": "Mark all read","inbox.news.subtitle": "Nothing to decide — just a glance",diff --git a/locales/zh-CN/home.json b/locales/zh-CN/home.jsonindex b879c47953f..72a2a405bd9 100644--- a/locales/zh-CN/home.json+++ b/locales/zh-CN/home.json@@ -10,6 +10,7 @@"brief.action.feedback": "反馈","brief.action.ignore": "忽略","brief.action.retry": "重试",+ "brief.action.upgrade": "升级方案","brief.addFeedback": "分享反馈","brief.agentSignal.selfReview.applied.heading": "已更新","brief.agentSignal.selfReview.applied.summary": "已应用 {{count}} 条夜间回顾更新。",@@ -45,6 +46,7 @@"homePromoBanner.dismiss": "关闭","homePromoBanner.label": "{{model}} 现已上线","inbox.author.scheduled": "定时触发",+ "inbox.error.title": "运行失败","inbox.needsYou.title": "需要你处理","inbox.news.markAllRead": "全部已读","inbox.news.subtitle": "不需要你做决定,扫一眼就行",diff --git a/packages/locales/src/default/home.ts b/packages/locales/src/default/home.tsindex efaf77d1ce8..b122b683c67 100644--- a/packages/locales/src/default/home.ts+++ b/packages/locales/src/default/home.ts@@ -11,6 +11,7 @@ export default {'brief.action.feedback': 'Feedback','brief.action.ignore': 'Ignore','brief.action.retry': 'Retry',+ 'brief.action.upgrade': 'Upgrade plan','brief.agentSignal.selfReview.applied.heading': 'Updated','brief.agentSignal.selfReview.applied.summary': '{{count}} dream update was applied.','brief.agentSignal.selfReview.applied.summary_plural': '{{count}} dream updates were applied.',@@ -47,6 +48,7 @@ export default {'homePromoBanner.dismiss': 'Dismiss','homePromoBanner.label': '{{model}} is now available','inbox.author.scheduled': 'Scheduled',+ 'inbox.error.title': 'Run failed','inbox.needsYou.title': 'Needs you','inbox.news.markAllRead': 'Mark all read','inbox.news.subtitle': 'Nothing to decide — just a glance',diff --git a/src/features/DailyBrief/BriefCardActions.tsx b/src/features/DailyBrief/BriefCardActions.tsxindex e0af1cc8991..d210e67fb10 100644--- a/src/features/DailyBrief/BriefCardActions.tsx+++ b/src/features/DailyBrief/BriefCardActions.tsx@@ -235,16 +235,29 @@ const BriefCardActions = memo<BriefCardActionsProps>({t('brief.action.ignore')}</Button>)}- {primaryActions && (- <Button- className={styles.actionBtnPrimary}- disabled={loadingKey === primaryActions.key}- shape={'round'}- onClick={() => handleResolve(primaryActions.key)}- >- {getActionLabel(primaryActions)}- </Button>- )}+ {primaryActions &&+ (primaryActions.type === 'link' ? (+ // A link primary (e.g. the budget-error "Upgrade" remedy) navigates+ // to its url instead of resolving the brief; render it as a filled+ // primary so the fix is the clear call to action.+ <Button+ className={styles.actionBtnPrimary}+ href={primaryActions.url}+ shape={'round'}+ type={'primary'}+ >+ {getActionLabel(primaryActions)}+ </Button>+ ) : (+ <Button+ className={styles.actionBtnPrimary}+ disabled={loadingKey === primaryActions.key}+ shape={'round'}+ onClick={() => handleResolve(primaryActions.key)}+ >+ {getActionLabel(primaryActions)}+ </Button>+ ))}</Flexbox></Flexbox>);diff --git a/src/features/HomeInbox/InboxBriefCard.tsx b/src/features/HomeInbox/InboxBriefCard.tsxindex 1e6696c43d0..0a2962ca06f 100644--- a/src/features/HomeInbox/InboxBriefCard.tsx+++ b/src/features/HomeInbox/InboxBriefCard.tsx@@ -53,6 +53,12 @@ const InboxBriefCard = memo<InboxBriefCardProps>(({ brief }) => {const isInbox = agent?.id === INBOX_SESSION_ID;const canNavigate = Boolean(brief.taskId);+ // Error briefs carry their title + human, localized summary from the server+ // (taskLifecycle / verify / watchdog / agent-signal each own their copy), so+ // the card renders them verbatim — no client-side title override or string+ // munging. `isError` only drives the severity glyph below.+ const isError = brief.type === 'error';+const hasTaskMeta = Boolean(brief.taskStatus || brief.taskIdentifier || brief.taskName);const openTask = () => {@@ -79,7 +85,16 @@ const InboxBriefCard = memo<InboxBriefCardProps>(({ brief }) => {gap={7}onClick={canNavigate ? openTask : undefined}>- {brief.taskStatus && <StatusGlyph status={brief.taskStatus} variant={'task'} />}+ {/* On error the task glyph would render its paused/scheduled state+ (the neutral "waiting for human" hand), which reads as pending, not+ failed. Show the topic-failed alert (red TriangleAlert) so the row+ reads as an error at a glance — the one true failure glyph, no extra+ icon on the headline. */}+ {isError ? (+ <StatusGlyph status={'failed'} variant={'topic'} />+ ) : (+ brief.taskStatus && <StatusGlyph status={brief.taskStatus} variant={'task'} />+ )}{brief.taskIdentifier && <span className={styles.taskRef}>{brief.taskIdentifier}</span>}{brief.taskName && <span className={styles.taskName}>{brief.taskName}</span>}<Flexbox flex={1} />