diff --git a/frontend/src/components/event-handler.tsx b/frontend/src/components/event-handler.tsx index 75eef4116476..a9e0085ae694 100644 --- a/frontend/src/components/event-handler.tsx +++ b/frontend/src/components/event-handler.tsx @@ -34,6 +34,7 @@ import { base64ToBlob } from "#/utils/base64-to-blob"; import { setCurrentAgentState } from "#/state/agentSlice"; import AgentState from "#/types/AgentState"; import { getSettings } from "#/services/settings"; +import { generateAgentStateChangeEvent } from "#/services/agentStateService"; interface ServerError { error: boolean | string; @@ -96,6 +97,14 @@ export function EventHandler({ children }: React.PropsWithChildren) { return; } + if (event.type === "error") { + const message: string = `${event.message}`; + if (message.startsWith("Agent reached maximum")) { + // We set the agent state to paused here - if the user clicks resume, it auto updates the max iterations + send(generateAgentStateChangeEvent(AgentState.PAUSED)); + } + } + if (isErrorObservation(event)) { dispatch( addErrorMessage({