Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(userErrors): rename UserErrorType to UserErrorCategory

Steven Enamakel8543959bead7
diff --git a/app/src/lib/userErrors/classify.ts b/app/src/lib/userErrors/classify.ts
index bf3422db87..1dab658b21 100644
--- a/app/src/lib/userErrors/classify.ts
+++ b/app/src/lib/userErrors/classify.ts
@@ -67,6 +67,40 @@ export function classifyMemoryPipelineFailure(
};
}
+/**
+ * A third-party integration is failing, so the connection state on screen is
+ * stale (#composio).
+ *
+ * Unlike the matchers below this does not sniff the prose: the caller already
+ * knows the integration errored, and the message is the backend's own
+ * user-facing explanation. It rides on `detail` verbatim rather than being
+ * pattern-matched into a billing entry — "your credits are exhausted" and
+ * "your connected tools have silently stopped" are different things to tell
+ * someone, and only the second explains why their agent stopped acting.
+ *
+ * @param message The integration client's user-facing error text.
+ * @param provider Integration slug (e.g. `composio`) — metadata only.
+ */
+export function classifyIntegrationError(
+ message: string | null | undefined,
+ provider: string
+): UserErrorDescriptor | null {
+ const detail = message?.trim();
+ if (!detail) return null;
+ return {
+ id: userErrorId('integration_degraded', 'integration', provider),
+ kind: 'integration_degraded',
+ severity: 'warning',
+ scope: 'integration',
+ sourceDomain: provider,
+ provider,
+ titleKey: 'userErrors.integrationDegraded.title',
+ bodyKey: 'userErrors.integrationDegraded.body',
+ detail,
+ action: 'open_connections',
+ };
+}
+
/** Build the stable dedupe identity for an error. */
export function userErrorId(
kind: UserErrorDescriptor['kind'],
diff --git a/app/src/types/userError.ts b/app/src/types/userError.ts
index 86d5cb37a2..8b25a69f6b 100644
--- a/app/src/types/userError.ts
+++ b/app/src/types/userError.ts
@@ -34,7 +34,16 @@ export type UserErrorKind =
* not running, or the configured model was never pulled (#5354). Mirrors the
* core-side `LOCAL_MODEL_UNAVAILABLE_KIND` token.
*/
- | 'local_model_unavailable';
+ | 'local_model_unavailable'
+ /**
+ * A third-party integration is answering with errors, so the connection
+ * state the app is showing is stale (today: Composio). Distinct from
+ * `budget_exceeded` even when the underlying cause is exhausted credits:
+ * the consequence is "your tools are silently not running", and naming that
+ * is the whole point — a billing-worded entry would not tell the user their
+ * connections have stopped working.
+ */
+ | 'integration_degraded';
/** Where the failure originated, for grouping/labelling (privacy-safe). */
export type UserErrorScope =
@@ -51,6 +60,8 @@ export type UserErrorAction =
| 'open_billing'
| 'open_provider_settings'
| 'open_embeddings_settings'
+ /** The connections screen — where integration health is polled and re-read. */
+ | 'open_connections'
| 'dismiss';
export type UserErrorSeverity = 'warning' | 'error';
@@ -74,6 +85,18 @@ export interface UserErrorDescriptor {
titleKey: string;
/** i18n key for the one-line explanation. */
bodyKey: string;
+ /**
+ * Extra already-user-facing detail from the source, shown verbatim beneath
+ * the translated body.
+ *
+ * The rest of this contract is deliberately i18n *keys* so all copy stays
+ * translatable, and that stays the rule. This is the narrow exception for a
+ * message a backend wrote **for the user** and that the app cannot restate
+ * without losing what actually went wrong (e.g. which integration call
+ * failed and why). Never put raw provider responses, tokens, prompts or PII
+ * here — only text already destined for the user's screen.
+ */
+ detail?: string;
action: UserErrorAction;
}