mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
🤖 feat: Agent Handoffs (Routing) (#10176)
* feat: Add support for agent handoffs with edges in agent forms and schemas chore: Mark `agent_ids` field as deprecated in favor of edges across various schemas and types chore: Update dependencies for @langchain/core and @librechat/agents to latest versions chore: Update peer dependency for @librechat/agents to version 3.0.0-rc2 in package.json chore: Update @librechat/agents dependency to version 3.0.0-rc3 in package.json and package-lock.json feat: first pass, multi-agent handoffs fix: update output type to ToolMessage in memory handling functions fix: improve type checking for graphConfig in createRun function refactor: remove unused content filtering logic in AgentClient chore: update @librechat/agents dependency to version 3.0.0-rc4 in package.json and package-lock.json fix: update @langchain/core peer dependency version to ^0.3.72 in package.json and package-lock.json fix: update @librechat/agents dependency to version 3.0.0-rc6 in package.json and package-lock.json; refactor stream rate handling in various endpoints feat: Agent handoff UI chore: update @librechat/agents dependency to version 3.0.0-rc8 in package.json and package-lock.json fix: improve hasInfo condition and adjust UI element classes in AgentHandoff component refactor: remove current fixed agent display from AgentHandoffs component due to redundancy feat: enhance AgentHandoffs UI with localized beta label and improved layout chore: update @librechat/agents dependency to version 3.0.0-rc10 in package.json and package-lock.json feat: add `createSequentialChainEdges` function to add back agent chaining via multi-agents feat: update `createSequentialChainEdges` call to only provide conversation context between agents feat: deprecate Agent Chain functionality and update related methods for improved clarity * chore: update @librechat/agents dependency to version 3.0.0-rc11 in package.json and package-lock.json * refactor: remove unused addCacheControl function and related imports and import from @librechat/agents * chore: remove unused i18n keys * refactor: remove unused format export from index.ts * chore: update @librechat/agents to v3.0.0-rc13 * chore: remove BEDROCK_LEGACY provider from Providers enum * chore: update @librechat/agents to version 3.0.2 in package.json
This commit is contained in:
parent
958a6c7872
commit
8a4a5a4790
41 changed files with 1108 additions and 3810 deletions
|
|
@ -1615,6 +1615,10 @@ export enum Constants {
|
|||
* This helps inform the UI if the mcp server was previously added.
|
||||
* */
|
||||
mcp_server = 'sys__server__sys',
|
||||
/**
|
||||
* Handoff Tool Name Prefix
|
||||
*/
|
||||
LC_TRANSFER_TO_ = 'lc_transfer_to_',
|
||||
/** Placeholder Agent ID for Ephemeral Agents */
|
||||
EPHEMERAL_AGENT_ID = 'ephemeral',
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ export enum Providers {
|
|||
GOOGLE = 'google',
|
||||
VERTEXAI = 'vertexai',
|
||||
BEDROCK = 'bedrock',
|
||||
BEDROCK_LEGACY = 'bedrock_legacy',
|
||||
MISTRALAI = 'mistralai',
|
||||
MISTRAL = 'mistral',
|
||||
OLLAMA = 'ollama',
|
||||
|
|
@ -231,6 +230,7 @@ export const defaultAgentFormValues = {
|
|||
tools: [],
|
||||
provider: {},
|
||||
projectIds: [],
|
||||
edges: [],
|
||||
artifacts: '',
|
||||
/** @deprecated Use ACL permissions instead */
|
||||
isCollaborative: false,
|
||||
|
|
|
|||
|
|
@ -355,3 +355,45 @@ export type AgentToolType = {
|
|||
} & ({ assistant_id: string; agent_id?: never } | { assistant_id?: never; agent_id?: string });
|
||||
|
||||
export type ToolMetadata = TPlugin;
|
||||
|
||||
export interface BaseMessage {
|
||||
content: string;
|
||||
role?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface BaseGraphState {
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export type GraphEdge = {
|
||||
/** Agent ID, use a list for multiple sources */
|
||||
from: string | string[];
|
||||
/** Agent ID, use a list for multiple destinations */
|
||||
to: string | string[];
|
||||
description?: string;
|
||||
/** Can return boolean or specific destination(s) */
|
||||
condition?: (state: BaseGraphState) => boolean | string | string[];
|
||||
/** 'handoff' creates tools for dynamic routing, 'direct' creates direct edges, which also allow parallel execution */
|
||||
edgeType?: 'handoff' | 'direct';
|
||||
/**
|
||||
* For direct edges: Optional prompt to add when transitioning through this edge.
|
||||
* String prompts can include variables like {results} which will be replaced with
|
||||
* messages from startIndex onwards. When {results} is used, excludeResults defaults to true.
|
||||
*
|
||||
* For handoff edges: Description for the input parameter that the handoff tool accepts,
|
||||
* allowing the supervisor to pass specific instructions/context to the transferred agent.
|
||||
*/
|
||||
prompt?: string | ((messages: BaseMessage[], runStartIndex: number) => string | undefined);
|
||||
/**
|
||||
* When true, excludes messages from startIndex when adding prompt.
|
||||
* Automatically set to true when {results} variable is used in prompt.
|
||||
*/
|
||||
excludeResults?: boolean;
|
||||
/**
|
||||
* For handoff edges: Customizes the parameter name for the handoff input.
|
||||
* Defaults to "instructions" if not specified.
|
||||
* Only applies when prompt is provided for handoff edges.
|
||||
*/
|
||||
promptKey?: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type { OpenAPIV3 } from 'openapi-types';
|
||||
import type { AssistantsEndpoint, AgentProvider } from 'src/schemas';
|
||||
import type { Agents, GraphEdge } from './agents';
|
||||
import type { ContentTypes } from './runs';
|
||||
import type { Agents } from './agents';
|
||||
import type { TFile } from './files';
|
||||
import { ArtifactModes } from 'src/artifacts';
|
||||
|
||||
|
|
@ -229,7 +229,9 @@ export type Agent = {
|
|||
/** @deprecated Use ACL permissions instead */
|
||||
isCollaborative?: boolean;
|
||||
tool_resources?: AgentToolResources;
|
||||
/** @deprecated Use edges instead */
|
||||
agent_ids?: string[];
|
||||
edges?: GraphEdge[];
|
||||
end_after_tools?: boolean;
|
||||
hide_sequential_outputs?: boolean;
|
||||
artifacts?: ArtifactModes;
|
||||
|
|
@ -255,6 +257,7 @@ export type AgentCreateParams = {
|
|||
} & Pick<
|
||||
Agent,
|
||||
| 'agent_ids'
|
||||
| 'edges'
|
||||
| 'end_after_tools'
|
||||
| 'hide_sequential_outputs'
|
||||
| 'artifacts'
|
||||
|
|
@ -280,6 +283,7 @@ export type AgentUpdateParams = {
|
|||
} & Pick<
|
||||
Agent,
|
||||
| 'agent_ids'
|
||||
| 'edges'
|
||||
| 'end_after_tools'
|
||||
| 'hide_sequential_outputs'
|
||||
| 'artifacts'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue