feat(core): Make Tools Agent the default Agent type, deprecate other agent types (#13459)

This commit is contained in:
Jaakko Husso 2025-02-26 10:23:22 +02:00 committed by GitHub
parent 461e39a74e
commit a60d106ebb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 4 deletions

View file

@ -27,7 +27,13 @@ import { toolsAgentExecute } from './agents/ToolsAgent/execute';
// Function used in the inputs expression to figure out which inputs to
// display based on the agent type
function getInputs(
agent: 'toolsAgent' | 'conversationalAgent' | 'openAiFunctionsAgent' | 'reActAgent' | 'sqlAgent',
agent:
| 'toolsAgent'
| 'conversationalAgent'
| 'openAiFunctionsAgent'
| 'planAndExecuteAgent'
| 'reActAgent'
| 'sqlAgent',
hasOutputParser?: boolean,
): Array<NodeConnectionType | INodeInputConfiguration> {
interface SpecialInput {
@ -256,7 +262,7 @@ export class Agent implements INodeType {
icon: 'fa:robot',
iconColor: 'black',
group: ['transform'],
version: [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7],
version: [1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8],
description: 'Generates an action plan and executes it. Can use external tools.',
subtitle:
"={{ { toolsAgent: 'Tools Agent', conversationalAgent: 'Conversational Agent', openAiFunctionsAgent: 'OpenAI Functions Agent', reActAgent: 'ReAct Agent', sqlAgent: 'SQL Agent', planAndExecuteAgent: 'Plan and Execute Agent' }[$parameter.agent] }}",
@ -322,6 +328,24 @@ export class Agent implements INodeType {
},
},
},
{
displayName:
"This node is using Agent that has been deprecated. Please switch to using 'Tools Agent' instead.",
name: 'deprecated',
type: 'notice',
default: '',
displayOptions: {
show: {
agent: [
'conversationalAgent',
'openAiFunctionsAgent',
'planAndExecuteAgent',
'reActAgent',
'sqlAgent',
],
},
},
},
// Make Conversational Agent the default agent for versions 1.5 and below
{
...agentTypeProperty,
@ -331,10 +355,17 @@ export class Agent implements INodeType {
displayOptions: { show: { '@version': [{ _cnd: { lte: 1.5 } }] } },
default: 'conversationalAgent',
},
// Make Tools Agent the default agent for versions 1.6 and above
// Make Tools Agent the default agent for versions 1.6 and 1.7
{
...agentTypeProperty,
displayOptions: { show: { '@version': [{ _cnd: { gte: 1.6 } }] } },
displayOptions: { show: { '@version': [{ _cnd: { between: { from: 1.6, to: 1.7 } } }] } },
default: 'toolsAgent',
},
// Make Tools Agent the only agent option for versions 1.8 and above
{
...agentTypeProperty,
type: 'hidden',
displayOptions: { show: { '@version': [{ _cnd: { gte: 1.8 } }] } },
default: 'toolsAgent',
},
{

View file

@ -96,6 +96,13 @@ export const reActAgentAgentProperties: INodeProperties[] = [
rows: 6,
},
},
{
displayName: 'Max Iterations',
name: 'maxIterations',
type: 'number',
default: 10,
description: 'The maximum number of iterations the agent will run before stopping',
},
{
displayName: 'Return Intermediate Steps',
name: 'returnIntermediateSteps',

View file

@ -38,6 +38,7 @@ export async function reActAgentAgentExecute(
prefix?: string;
suffix?: string;
suffixChat?: string;
maxIterations?: number;
humanMessageTemplate?: string;
returnIntermediateSteps?: boolean;
};
@ -60,6 +61,7 @@ export async function reActAgentAgentExecute(
agent,
tools,
returnIntermediateSteps: options?.returnIntermediateSteps === true,
maxIterations: options.maxIterations ?? 10,
});
const returnData: INodeExecutionData[] = [];