diff --git a/x-pack/plugins/observability_solution/observability_ai_assistant/public/hooks/use_chat.ts b/x-pack/plugins/observability_solution/observability_ai_assistant/public/hooks/use_chat.ts index b51b33797e285..b621b3b151713 100644 --- a/x-pack/plugins/observability_solution/observability_ai_assistant/public/hooks/use_chat.ts +++ b/x-pack/plugins/observability_solution/observability_ai_assistant/public/hooks/use_chat.ts @@ -104,10 +104,11 @@ function useChatWithoutContext({ (error: Error) => { if (error instanceof AbortError) { setChatState(ChatState.Aborted); - } else { - setChatState(ChatState.Error); + return; } + setChatState(ChatState.Error); + if (isTokenLimitReachedError(error)) { setMessages((msgs) => [ ...msgs,