🤯 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
🔨 chore(fetch-sse): enrich error context with provider, model, and network diagnostics (#13468)
Arvin Xu453db9f165ed
diff --git a/packages/fetch-sse/src/fetchSSE.ts b/packages/fetch-sse/src/fetchSSE.tsindex 8c9bed3a461..3f46613f7b4 100644--- a/packages/fetch-sse/src/fetchSSE.ts+++ b/packages/fetch-sse/src/fetchSSE.ts@@ -93,6 +93,13 @@ interface MessageToolCallsChunk {type: 'tool_calls';}+export interface FetchSSERequestContext {+ apiMode?: string;+ fetchOnClient?: boolean;+ model?: string;+ provider?: string;+}+export interface FetchSSEOptions {fetcher?: typeof fetch;onAbort?: (text: string) => Promise<void>;@@ -111,6 +118,7 @@ export interface FetchSSEOptions {| MessageSpeedChunk| MessageStopChunk,) => void;+ requestContext?: FetchSSERequestContext;responseAnimation?: ResponseAnimation;}@@ -235,6 +243,7 @@ export const fetchSSE = async (url: string, options: RequestInit & FetchSSEOptiolet finishedType: SSEFinishType = 'done';let response!: Response;+ const fetchStartTime = Date.now();const { text, speed: smoothingSpeed } = standardizeAnimationStyle(options.responseAnimation ?? {},@@ -303,14 +312,23 @@ export const fetchSSE = async (url: string, options: RequestInit & FetchSSEOptio} else {finishedType = 'error';+ const elapsedMs = Date.now() - fetchStartTime;+ const networkStatus = typeof navigator !== 'undefined' ? navigator.onLine : undefined;++ const contextBody = {+ ...options.requestContext,+ elapsedMs,+ networkStatus,+ };+options.onErrorHandle?.(error.type- ? error+ ? { ...error, body: { ...error.body, ...contextBody } }: {body: {- message: error.message,- name: error.name,- stack: error.stack,+ errorMessage: error.message,+ errorName: error.name,+ ...contextBody,},message: error.message,type: ChatErrorType.UnknownChatFetchError,diff --git a/src/services/chat/index.ts b/src/services/chat/index.tsindex d7393056b6f..ef84776bf9c 100644--- a/src/services/chat/index.ts+++ b/src/services/chat/index.ts@@ -435,6 +435,12 @@ class ChatService {onErrorHandle: options?.onErrorHandle,onFinish: options?.onFinish,onMessageHandle: options?.onMessageHandle,+ requestContext: {+ apiMode,+ fetchOnClient: enableFetchOnClient,+ model,+ provider,+ },responseAnimation: mergedResponseAnimation,signal,});diff --git a/src/store/chat/agents/createAgentExecutors.ts b/src/store/chat/agents/createAgentExecutors.tsindex 5ef7c40d412..e946a6bd1aa 100644--- a/src/store/chat/agents/createAgentExecutors.ts+++ b/src/store/chat/agents/createAgentExecutors.ts@@ -476,7 +476,14 @@ export const createAgentExecutors = (context: {traceName: TraceNameMap.Conversation,},onErrorHandle: async (error) => {- const localizedError = localizeError(error);+ const enrichedError = {+ ...error,+ body: {+ ...error.body,+ traceId,+ },+ };+ const localizedError = localizeError(enrichedError);await context.get().optimisticUpdateMessageError(assistantMessageId, localizedError, {operationId: context.operationId,