Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🧠 fix: Restore Agent Memory Scope Control in Unified Builder (#14292)
Danny Avila21766b5b3cbf
diff --git a/client/src/components/SidePanel/Agents/Memory.tsx b/client/src/components/SidePanel/Agents/Memory.tsxdeleted file mode 100644index 69c409f8f6..0000000000--- a/client/src/components/SidePanel/Agents/Memory.tsx+++ /dev/null@@ -1,118 +0,0 @@-import { memo } from 'react';-import { useFormContext, Controller, useWatch } from 'react-hook-form';-import { MemoryScope, AgentCapabilities } from 'librechat-data-provider';-import {- Checkbox,- HoverCard,- HoverCardContent,- HoverCardPortal,- HoverCardTrigger,- CircleHelpIcon,-} from '@librechat/client';-import type { AgentForm } from '~/common';-import { useLocalize } from '~/hooks';-import { ESide } from '~/common';--function Memory() {- const localize = useLocalize();- const methods = useFormContext<AgentForm>();- const { control } = methods;- const memoryEnabled = useWatch({ control, name: AgentCapabilities.memory });-- return (- <div>- <HoverCard openDelay={50}>- <div className="my-2 flex items-center">- <Controller- name={AgentCapabilities.memory}- control={control}- render={({ field }) => (- <Checkbox- {...field}- id="memory-checkbox"- checked={field.value === true}- onCheckedChange={field.onChange}- className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"- value={(field.value === true).toString()}- aria-labelledby="memory-label"- />- )}- />- <label- id="memory-label"- htmlFor="memory-checkbox"- className="form-check-label text-token-text-primary cursor-pointer text-sm"- >- {localize('com_agents_enable_memory')}- </label>- <HoverCardTrigger asChild className="ml-2">- <button- type="button"- className="inline-flex items-center"- aria-label={localize('com_agents_memory_info')}- >- <CircleHelpIcon className="h-4 w-4 text-text-tertiary" />- </button>- </HoverCardTrigger>- <HoverCardPortal>- <HoverCardContent side={ESide.Top} className="w-80">- <div className="space-y-2">- <p className="text-sm text-text-secondary">{localize('com_agents_memory_info')}</p>- </div>- </HoverCardContent>- </HoverCardPortal>- </div>- </HoverCard>- {memoryEnabled === true && (- <HoverCard openDelay={50}>- <div className="my-2 ml-6 flex items-center">- <Controller- name="memory_scope"- control={control}- render={({ field }) => (- <Checkbox- {...field}- id="memory-scope-checkbox"- checked={field.value === MemoryScope.agent}- onCheckedChange={(checked) =>- field.onChange(checked === true ? MemoryScope.agent : MemoryScope.user)- }- className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"- value={(field.value === MemoryScope.agent).toString()}- aria-labelledby="memory-scope-label"- />- )}- />- <label- id="memory-scope-label"- htmlFor="memory-scope-checkbox"- className="form-check-label text-token-text-primary cursor-pointer text-sm"- >- {localize('com_agents_memory_scope')}- </label>- <HoverCardTrigger asChild className="ml-2">- <button- type="button"- className="inline-flex items-center"- aria-label={localize('com_agents_memory_scope_info')}- >- <CircleHelpIcon className="h-4 w-4 text-text-tertiary" />- </button>- </HoverCardTrigger>- <HoverCardPortal>- <HoverCardContent side={ESide.Top} className="w-80">- <div className="space-y-2">- <p className="text-sm text-text-secondary">- {localize('com_agents_memory_scope_info')}- </p>- </div>- </HoverCardContent>- </HoverCardPortal>- </div>- </HoverCard>- )}- </div>- );-}--export default memo(Memory);diff --git a/client/src/components/SidePanel/Agents/Tools/ItemDialog/__tests__/BuiltinSection.spec.tsx b/client/src/components/SidePanel/Agents/Tools/ItemDialog/__tests__/BuiltinSection.spec.tsxnew file mode 100644index 0000000000..938240e40b--- /dev/null+++ b/client/src/components/SidePanel/Agents/Tools/ItemDialog/__tests__/BuiltinSection.spec.tsx@@ -0,0 +1,80 @@+import '@testing-library/jest-dom/extend-expect';+import { MemoryScope } from 'librechat-data-provider';+import { useForm, FormProvider, useWatch } from 'react-hook-form';+import { render, screen, fireEvent } from '@testing-library/react';+import type { ReactNode } from 'react';+import type { AgentForm } from '~/common';+import BuiltinSection from '../sections/BuiltinSection';++jest.mock('~/hooks', () => ({ useLocalize: () => (key: string) => key }));+jest.mock('~/data-provider', () => ({ useVerifyAgentToolAuth: () => ({ data: undefined }) }));+jest.mock('../../../Search/Action', () => ({ __esModule: true, default: () => <div /> }));+jest.mock('../../../FileContext', () => ({ __esModule: true, default: () => <div /> }));+jest.mock('../../../FileSearch', () => ({ __esModule: true, default: () => <div /> }));+jest.mock('../../../Code/Files', () => ({ __esModule: true, default: () => <div /> }));++function ScopeProbe() {+ const value = useWatch<AgentForm>({ name: 'memory_scope' });+ return <span data-testid="scope">{String(value)}</span>;+}++function renderSection(builtinId: string, defaultValues: Partial<AgentForm> = {}) {+ function Wrapper({ children }: { children: ReactNode }) {+ const methods = useForm<AgentForm>({ defaultValues: defaultValues as AgentForm });+ return (+ <FormProvider {...methods}>+ {children}+ <ScopeProbe />+ </FormProvider>+ );+ }++ return render(+ <BuiltinSection+ builtinId={builtinId as never}+ agentId="a1"+ contextFiles={[]}+ knowledgeFiles={[]}+ codeFiles={[]}+ description="com_agents_memory_info"+ />,+ { wrapper: Wrapper },+ );+}++const scopeCheckbox = () => screen.getByRole('checkbox', { name: 'com_agents_memory_scope' });++describe('BuiltinSection memory scope', () => {+ test('renders the scope control unchecked when memory is on the shared pool', () => {+ renderSection('memory', { memory: true, memory_scope: MemoryScope.user });+ expect(scopeCheckbox()).not.toBeChecked();+ expect(screen.getByText('com_agents_memory_scope_info')).toBeInTheDocument();+ });++ test('defaults to the shared pool when the agent has no saved scope', () => {+ renderSection('memory', { memory: true });+ expect(scopeCheckbox()).not.toBeChecked();+ });++ test('renders checked for an agent already partitioned to its own memories', () => {+ renderSection('memory', { memory: true, memory_scope: MemoryScope.agent });+ expect(scopeCheckbox()).toBeChecked();+ });++ test('toggling writes the scope back to the form in both directions', () => {+ renderSection('memory', { memory: true, memory_scope: MemoryScope.user });++ fireEvent.click(scopeCheckbox());+ expect(screen.getByTestId('scope')).toHaveTextContent(MemoryScope.agent);+ expect(scopeCheckbox()).toBeChecked();++ fireEvent.click(scopeCheckbox());+ expect(screen.getByTestId('scope')).toHaveTextContent(MemoryScope.user);+ expect(scopeCheckbox()).not.toBeChecked();+ });++ test('other builtins do not render the scope control', () => {+ renderSection('execute_code', { memory: true, memory_scope: MemoryScope.agent });+ expect(screen.queryByRole('checkbox', { name: 'com_agents_memory_scope' })).toBeNull();+ });+});diff --git a/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/BuiltinSection.tsx b/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/BuiltinSection.tsxindex f3b3e9dae3..adc6a14b22 100644--- a/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/BuiltinSection.tsx+++ b/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/BuiltinSection.tsx@@ -1,6 +1,6 @@-import { Radio } from '@librechat/client';+import { Radio, Checkbox } from '@librechat/client';import { useFormContext, useWatch } from 'react-hook-form';-import { Tools, ArtifactModes, AgentCapabilities } from 'librechat-data-provider';+import { Tools, MemoryScope, ArtifactModes, AgentCapabilities } from 'librechat-data-provider';import type { TranslationKeys } from '~/hooks/useLocalize';import type { AgentForm, ExtendedFile } from '~/common';import type { BuiltinId } from '../../items/types';@@ -74,6 +74,43 @@ function ArtifactsConfig({ value, onChange }: ArtifactsConfigProps) {);}+interface MemoryConfigProps {+ value: string;+ onChange: (next: MemoryScope) => void;+}++function MemoryConfig({ value, onChange }: MemoryConfigProps) {+ const localize = useLocalize();+ const isolated = value === MemoryScope.agent;++ return (+ <div className="flex flex-col gap-3">+ <div className="flex items-center">+ <Checkbox+ id="memory-scope-checkbox"+ checked={isolated}+ onCheckedChange={(checked) =>+ onChange(checked === true ? MemoryScope.agent : MemoryScope.user)+ }+ className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"+ value={isolated.toString()}+ aria-labelledby="memory-scope-label"+ />+ <label+ id="memory-scope-label"+ htmlFor="memory-scope-checkbox"+ className="cursor-pointer text-sm font-medium text-text-primary"+ >+ {localize('com_agents_memory_scope')}+ </label>+ </div>+ <p className="text-sm leading-relaxed text-text-secondary">+ {localize('com_agents_memory_scope_info')}+ </p>+ </div>+ );+}+function WebSearchConfig() {const { data } = useVerifyAgentToolAuth({ toolId: Tools.web_search }, { retry: 1 });return <SearchAction authTypes={data?.authTypes} isToolAuthenticated={data?.authenticated} />;@@ -91,6 +128,7 @@ export default function BuiltinSection({const { control, setValue } = useFormContext<AgentForm>();const artifactsValue = (useWatch({ control, name: AgentCapabilities.artifacts }) ?? '') as string;+ const memoryScope = (useWatch({ control, name: 'memory_scope' }) ?? MemoryScope.user) as string;let body: React.ReactNode = null;@@ -109,6 +147,13 @@ export default function BuiltinSection({);} else if (builtinId === 'context') {body = <FileContext agent_id={agentId} files={contextFiles} showHeader={false} />;+ } else if (builtinId === 'memory') {+ body = (+ <MemoryConfig+ value={memoryScope}+ onChange={(next) => setValue('memory_scope', next, { shouldDirty: true })}+ />+ );}const localizedDescription = description ? localize(description as TranslationKeys) : '';diff --git a/client/src/components/SidePanel/Agents/Tools/items/__tests__/configurable.spec.ts b/client/src/components/SidePanel/Agents/Tools/items/__tests__/configurable.spec.tsindex aa12b7c3d9..741071890f 100644--- a/client/src/components/SidePanel/Agents/Tools/items/__tests__/configurable.spec.ts+++ b/client/src/components/SidePanel/Agents/Tools/items/__tests__/configurable.spec.ts@@ -6,15 +6,15 @@ const builtin = (id: string, extra: Record<string, unknown> = {}): AgentItem =>({ kind: 'builtin', id, name: '', description: '', iconKey: id, ...extra }) as AgentItem;describe('hasConfigurableSettings', () => {- test('artifacts, file_search, and context builtins are configurable', () => {+ test('artifacts, file_search, context, and memory builtins are configurable', () => {expect(hasConfigurableSettings(builtin('artifacts'))).toBe(true);expect(hasConfigurableSettings(builtin('file_search'))).toBe(true);expect(hasConfigurableSettings(builtin('context'))).toBe(true);+ expect(hasConfigurableSettings(builtin('memory'))).toBe(true);});- test('execute_code and memory builtins are not configurable', () => {+ test('execute_code builtin is not configurable', () => {expect(hasConfigurableSettings(builtin('execute_code'))).toBe(false);- expect(hasConfigurableSettings(builtin('memory'))).toBe(false);});test('web_search is configurable only when auth is user-provided', () => {diff --git a/client/src/components/SidePanel/Agents/Tools/items/configurable.ts b/client/src/components/SidePanel/Agents/Tools/items/configurable.tsindex 07bbdfecb6..8063c497d0 100644--- a/client/src/components/SidePanel/Agents/Tools/items/configurable.ts+++ b/client/src/components/SidePanel/Agents/Tools/items/configurable.ts@@ -14,6 +14,7 @@ export function hasConfigurableSettings(item: AgentItem): boolean {item.id === 'artifacts' ||item.id === 'file_search' ||item.id === 'context' ||+ item.id === 'memory' ||(item.id === 'web_search' && item.userProvidedAuth === true));case 'tool':diff --git a/client/src/locales/en/translation.json b/client/src/locales/en/translation.jsonindex 907147c5ce..cb6f0bd11e 100644--- a/client/src/locales/en/translation.json+++ b/client/src/locales/en/translation.json@@ -41,7 +41,6 @@"com_agents_description_card": "Description: {{description}}","com_agents_description_placeholder": "What this agent does","com_agents_empty_state_heading": "No agents found",- "com_agents_enable_memory": "Enable Memory","com_agents_error_bad_request_message": "The request could not be processed.","com_agents_error_bad_request_suggestion": "Please check your input and try again.","com_agents_error_category_title": "Category Error",