diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts index 8238daa0c6..8ed66f7676 100644 --- a/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts +++ b/autogpt_platform/frontend/src/app/(platform)/copilot/store.ts @@ -337,6 +337,11 @@ export const useCopilotUIStore = create((set) => ({ set((state) => { const next = new Map(state.sessionModes); next.set(sessionId, state.copilotMode); + // Cap at 200 entries — prune oldest when exceeded + if (next.size > 200) { + const oldest = next.keys().next().value; + if (oldest) next.delete(oldest); + } persistSessionModes(next); return { sessionModes: next }; }),