🪚 chore: Deprecate Agent Chain Authoring (#16745)

* feat: consolidate orchestration into a native tool

* test: complete persisted subagent graph fixture

* fix: keep orchestration pickers inside the modal focus scope

* chore: deprecate agent chain authoring

* fix: preserve runtime-equivalent legacy handoff classification

* test: stabilize orchestration dialog lifecycle coverage

* test: wait for stream completion before final title polling

---------

Co-authored-by: Lia <lia@librechat.ai>
This commit is contained in:
lia-by-librechat[bot] 2026-10-04 17:36:13 -04:00 • committed by GitHub
parent 7e575c047f
commit af35fe5439
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 109 additions and 113 deletions

View file

@ -3888,7 +3888,7 @@ describe('ToolService - Action Capability Gating', () => {
expect(defaultAgentCapabilities).toContain(AgentCapabilities.context);
expect(defaultAgentCapabilities).toContain(AgentCapabilities.ask_user_question);
expect(defaultAgentCapabilities).toContain(AgentCapabilities.tools);
expect(defaultAgentCapabilities).toContain(AgentCapabilities.chain);
expect(defaultAgentCapabilities).not.toContain(AgentCapabilities.chain);
expect(defaultAgentCapabilities).toContain(AgentCapabilities.ocr);
});
});

View file

@ -1,6 +1,5 @@
import { useState } from 'react';
import { ChevronLeft, Check, Copy } from 'lucide-react';
import { AgentCapabilities } from 'librechat-data-provider';
import { Controller, useFormContext } from 'react-hook-form';
import { Button, TooltipAnchor, labelVariants, useToastContext } from '@librechat/client';
import type { AgentForm } from '~/common';
@ -16,9 +15,10 @@ export default function AdvancedPanel() {
const { showToast } = useToastContext();
const { watch, control } = useFormContext<AgentForm>();
const currentAgentId = watch('id');
const chainIds = watch('agent_ids');
const [copied, setCopied] = useState(false);
const { setActivePanel, agentsConfig } = useAgentPanelContext();
const { setActivePanel } = useAgentPanelContext();
const handleCopyAgentId = async () => {
if (!currentAgentId) return;
@ -59,7 +59,7 @@ export default function AdvancedPanel() {
<MaxAgentSteps />
</section>
{agentsConfig?.capabilities.includes(AgentCapabilities.chain) && (
{(chainIds?.length ?? 0) > 0 && (
<Controller
name="agent_ids"
control={control}

View file

@ -1,16 +1,9 @@
import React, { useState, useMemo, useEffect } from 'react';
import { Link2, ListOrdered } from 'lucide-react';
import { ListOrdered } from 'lucide-react';
import { Button } from '@librechat/client';
import type { ControllerRenderProps } from 'react-hook-form';
import type { AgentForm } from '~/common';
import {
AgentGlyph,
AgentRow,
agentIcon,
AddAgentSelect,
AgentSelectInline,
useSelectableAgents,
} from './AgentList';
import OrchestrationPattern from './OrchestrationPattern';
import { useSelectableAgents } from './AgentList';
import { useLocalize } from '~/hooks';
import { CountPill } from './ui';
@ -19,107 +12,34 @@ interface AgentChainProps {
currentAgentId: string;
}
/** TODO: make configurable */
const MAX_AGENTS = 10;
const Connector = () => (
<Link2 className="mx-auto text-text-tertiary" size={14} aria-hidden="true" />
);
const AgentChain: React.FC<AgentChainProps> = ({ field, currentAgentId }) => {
export default function AgentChain({ field, currentAgentId }: AgentChainProps) {
const localize = useLocalize();
const [newAgentId, setNewAgentId] = useState('');
const agentIds = useMemo(() => field.value ?? [], [field.value]);
const agentIds = field.value ?? [];
const { getAgent } = useSelectableAgents({ currentAgentId });
const { options, getAgent } = useSelectableAgents({ currentAgentId });
useEffect(() => {
if (newAgentId && agentIds.length < MAX_AGENTS) {
field.onChange([...agentIds, newAgentId]);
setNewAgentId('');
}
}, [newAgentId, agentIds, field]);
const removeAgentAt = (index: number) => {
field.onChange(agentIds.filter((_, i) => i !== index));
};
const updateAgentAt = (index: number, id: string) => {
const updated = [...agentIds];
updated[index] = id;
field.onChange(updated);
};
const currentAgent = currentAgentId ? getAgent(currentAgentId) : undefined;
const currentName = currentAgent?.name?.trim();
if (agentIds.length === 0) {
return null;
}
return (
<OrchestrationPattern
icon={<ListOrdered className="h-4 w-4" strokeWidth={1.75} aria-hidden="true" />}
title={localize('com_ui_agent_chain')}
subtitle={localize('com_ui_agent_chain_subtitle')}
info={<p className="text-sm text-text-secondary">{localize('com_ui_agent_chain_info')}</p>}
trailing={
<CountPill>
{agentIds.length} / {MAX_AGENTS}
</CountPill>
}
subtitle={localize('com_ui_agent_chain_deprecated')}
info={<p className="text-text-secondary text-sm">{localize('com_ui_agent_chain_info')}</p>}
trailing={<CountPill>{agentIds.length}</CountPill>}
>
<div className="flex flex-col gap-1.5">
<div className="flex items-center gap-2 px-1 py-1">
{currentName ? (
<>
<AgentGlyph agent={currentAgent} />
<span className="truncate text-sm font-medium text-text-primary">{currentName}</span>
</>
) : (
<span className="text-sm font-medium text-text-secondary">
{localize('com_ui_agent_chain_self')}
</span>
)}
</div>
{agentIds.map((agentId, idx) => (
<React.Fragment key={`${agentId}-${idx}`}>
<Connector />
<AgentRow
onRemove={() => removeAgentAt(idx)}
removeLabel={localize('com_ui_remove_agent_from_chain', {
0: getAgent(agentId)?.name || localize('com_ui_agent'),
})}
>
<AgentSelectInline
options={options}
selectedValue={agentId}
onChange={(id) => updateAgentAt(idx, id)}
displayValue={getAgent(agentId)?.name ?? ''}
icon={agentIcon(getAgent(agentId))}
ariaLabel={localize('com_ui_agent_var', { 0: localize('com_ui_select') })}
/>
</AgentRow>
</React.Fragment>
<ol className="flex flex-col gap-1" aria-label={localize('com_ui_agent_chain')}>
{agentIds.map((agentId, index) => (
<li key={`${agentId}-${index}`} className="text-text-secondary text-sm">
{index + 1}. {getAgent(agentId)?.name ?? agentId}
</li>
))}
{agentIds.length < MAX_AGENTS && (
<>
<Connector />
<AddAgentSelect
options={options}
onSelect={setNewAgentId}
placeholder={localize('com_ui_agent_var', { 0: localize('com_ui_add') })}
ariaLabel={localize('com_ui_agent_var', { 0: localize('com_ui_add') })}
/>
</>
)}
{agentIds.length >= MAX_AGENTS && (
<p className="pt-1 text-center text-xs italic text-text-tertiary">
{localize('com_ui_agent_chain_max', { 0: MAX_AGENTS })}
</p>
)}
</div>
</ol>
<p className="text-text-secondary text-sm">{localize('com_ui_agent_chain_migrate')}</p>
<Button type="button" variant="outline" onClick={() => field.onChange([])}>
{localize('com_ui_agent_chain_remove')}
</Button>
</OrchestrationPattern>
);
};
export default AgentChain;
}

View file

@ -0,0 +1,54 @@
import { Controller, useForm } from 'react-hook-form';
import { fireEvent, render, screen } from '@testing-library/react';
import type { UseFormReturn } from 'react-hook-form';
import type { ReactNode } from 'react';
import type { AgentForm } from '~/common';
import AgentChain from '../AgentChain';
let mockGetValues: UseFormReturn<AgentForm>['getValues'];
jest.mock('~/hooks', () => ({ useLocalize: () => (key: string) => key }));
jest.mock('../AgentList', () => ({
useSelectableAgents: () => ({ getAgent: (id: string) => ({ name: id }) }),
}));
jest.mock('../OrchestrationPattern', () => ({
__esModule: true,
default: ({ children, subtitle }: { children: ReactNode; subtitle: string }) => (
<section>
{subtitle}
{children}
</section>
),
}));
function Harness({ ids }: { ids: string[] }) {
const methods = useForm<AgentForm>({
defaultValues: { agent_ids: ids, subagents: { enabled: true, agent_ids: ['reviewer'] } },
});
mockGetValues = methods.getValues;
return (
<Controller
name="agent_ids"
control={methods.control}
render={({ field }) => <AgentChain field={field} currentAgentId="parent" />}
/>
);
}
test('offers no chain authoring for a new or unchained agent', () => {
const { container } = render(<Harness ids={[]} />);
expect(container).toBeEmptyDOMElement();
});
test('preserves legacy order and exposes only explicit removal', () => {
render(<Harness ids={['first', 'second']} />);
expect(screen.getByText('com_ui_agent_chain_deprecated')).toBeInTheDocument();
expect(screen.getAllByRole('listitem').map((item) => item.textContent)).toEqual([
'1. first',
'2. second',
]);
expect(screen.queryByRole('combobox')).not.toBeInTheDocument();
expect(mockGetValues('agent_ids')).toEqual(['first', 'second']);
fireEvent.click(screen.getByRole('button', { name: 'com_ui_agent_chain_remove' }));
expect(mockGetValues('agent_ids')).toEqual([]);
expect(mockGetValues('subagents')).toEqual({ enabled: true, agent_ids: ['reviewer'] });
});

View file

@ -61,6 +61,16 @@ const createForm = (): AgentForm => ({
});
describe('composeAgentUpdatePayload', () => {
it('preserves a legacy chain on unrelated saves and sends explicit removal', () => {
const form = createForm();
form.agent_ids = ['first', 'second'];
expect(composeAgentUpdatePayload(form, 'agent_123').payload.agent_ids).toEqual([
'first',
'second',
]);
form.agent_ids = [];
expect(composeAgentUpdatePayload(form, 'agent_123').payload.agent_ids).toEqual([]);
});
it('omits unchanged unavailable machine choices but submits an explicit removal', () => {
const form = createForm();
form.agent = {

View file

@ -1069,10 +1069,10 @@
"com_ui_agent_category_sales": "Sales",
"com_ui_agent_category_selector_aria": "Agent's category selector",
"com_ui_agent_chain": "Chain",
"com_ui_agent_chain_deprecated": "Agent chains are deprecated. Existing chains still run.",
"com_ui_agent_chain_migrate": "Use subagents or handoffs for new orchestration. Remove this chain before migrating.",
"com_ui_agent_chain_remove": "Remove chain",
"com_ui_agent_chain_info": "Enables creating sequences of agents. Each agent can access outputs from previous agents in the chain. Based on the \"Mixture-of-Agents\" architecture where agents use previous outputs as auxiliary information.",
"com_ui_agent_chain_max": "You have reached the maximum of {{0}} agents.",
"com_ui_agent_chain_self": "This agent",
"com_ui_agent_chain_subtitle": "Run a fixed sequence of agents, one after another.",
"com_ui_agent_delete_error": "There was an error deleting the agent",
"com_ui_agent_deleted": "Successfully deleted agent",
"com_ui_agent_description": "Agent description",
@ -2346,7 +2346,6 @@
"com_ui_remote_agents_allow_share": "Allow users to grant API access to agents to others",
"com_ui_remote_agents_allow_share_public": "Allow users to grant API access to agents to all users",
"com_ui_remote_agents_allow_use": "Allow users to create API keys and query agents remotely",
"com_ui_remove_agent_from_chain": "Remove {{0}} from chain",
"com_ui_remove_from_project": "Remove from project",
"com_ui_remove_queued": "Remove message",
"com_ui_dismiss_unconfirmed_delivery": "Dismiss unconfirmed delivery",

View file

@ -373,6 +373,11 @@ test.describe('conversation management', () => {
}),
);
await expect(row).toContainText(renamedTitle);
if (titleTiming === 'final') {
await expect(page.getByRole('button', { name: 'Stop generating' })).toBeHidden({
timeout: 30000,
});
}
await expect.poll(async () => !!(await titleRequest())).toBe(true);
const published = page.waitForResponse(
(response) =>

View file

@ -792,7 +792,7 @@ endpoints:
# # (optional) Agent Capabilities available to all users. Omit the ones you wish to exclude. Defaults to list below.
# # web_search controls only LibreChat's external pipeline, not provider-native search.
# # Both require WEB_SEARCH.USE, seeded by interface.webSearch. See UPGRADING.md.
# capabilities: ["deferred_tools", "execute_code", "file_search", "web_search", "artifacts", "subagents", "actions", "context", "skills", "memory", "ask_user_question", "tools", "chain", "ocr"]
# capabilities: ["deferred_tools", "execute_code", "file_search", "web_search", "artifacts", "subagents", "actions", "context", "skills", "memory", "ask_user_question", "tools", "ocr"]
# # The following capabilities are opt-in and must be added explicitly:
# # "programmatic_tools", "stateful_code_sessions", "run_in_background", "tool_intents"
# # "stateful_code_sessions" is highly experimental and may change substantially.

View file

@ -0,0 +1,8 @@
import { AgentCapabilities, defaultAgentCapabilities, agentsEndpointSchema } from './config';
test('retires chain from defaults without rejecting legacy deployment configuration', () => {
expect(defaultAgentCapabilities).not.toContain(AgentCapabilities.chain);
expect(
agentsEndpointSchema.parse({ capabilities: [AgentCapabilities.chain] }).capabilities,
).toEqual([AgentCapabilities.chain]);
});

View file

@ -709,6 +709,7 @@ export enum AgentCapabilities {
memory = 'memory',
ask_user_question = 'ask_user_question',
tools = 'tools',
/** @deprecated Retained for legacy configuration. Chain authoring is retired. */
chain = 'chain',
ocr = 'ocr',
run_in_background = 'run_in_background',
@ -887,7 +888,6 @@ export const defaultAgentCapabilities = [
AgentCapabilities.memory,
AgentCapabilities.ask_user_question,
AgentCapabilities.tools,
AgentCapabilities.chain,
AgentCapabilities.ocr,
];