From 59f7093428b917049a7e1df97a4e88268355f94a Mon Sep 17 00:00:00 2001 From: tofarr Date: Tue, 12 Nov 2024 14:09:43 -0700 Subject: [PATCH] Fix max iterations (#4949) --- frontend/src/components/event-handler.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) 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({