Fix ai agent node prompt and variables (#18275)

- prompt stored on workflow lvl so input variables can be resolved and
it can evolves with versions
- make ai agent node output available as variables
This commit is contained in:
Thomas Trompette
2026-02-26 17:17:48 +01:00
committed by GitHub
parent 81698ff32c
commit def5ea5764
6 changed files with 69 additions and 84 deletions
@@ -44,15 +44,6 @@ describe('computeStepOutputSchema', () => {
expect(result).toBeUndefined();
});
it('should return undefined for AI_AGENT step type', () => {
const result = computeStepOutputSchema({
step: { type: 'AI_AGENT', settings: {} } as any,
objectMetadataItems: [],
});
expect(result).toBeUndefined();
});
it('should return undefined for WEBHOOK step type', () => {
const result = computeStepOutputSchema({
step: { type: 'WEBHOOK', settings: {} } as any,
@@ -417,6 +408,24 @@ describe('computeStepOutputSchema', () => {
});
});
describe('AI_AGENT step', () => {
it('should return response schema', () => {
const result = computeStepOutputSchema({
step: { type: 'AI_AGENT', settings: {} } as any,
objectMetadataItems: [],
});
expect(result).toEqual({
response: {
isLeaf: true,
type: FieldMetadataType.TEXT,
label: 'Response',
value: null,
},
});
});
});
describe('Empty output schema steps', () => {
it.each(['FILTER', 'DELAY', 'EMPTY'])(
'should return empty object for %s step type',
@@ -452,8 +461,8 @@ describe('shouldComputeOutputSchemaOnFrontend', () => {
expect(shouldComputeOutputSchemaOnFrontend('HTTP_REQUEST')).toBe(false);
});
it('should return false for AI_AGENT', () => {
expect(shouldComputeOutputSchemaOnFrontend('AI_AGENT')).toBe(false);
it('should return true for AI_AGENT', () => {
expect(shouldComputeOutputSchemaOnFrontend('AI_AGENT')).toBe(true);
});
it('should return false for WEBHOOK', () => {
@@ -16,7 +16,6 @@ import { DatabaseEventAction } from '~/generated-metadata/graphql';
const PERSISTED_OUTPUT_SCHEMA_TYPES = [
'CODE',
'HTTP_REQUEST',
'AI_AGENT',
'WEBHOOK',
'ITERATOR',
];
@@ -191,6 +190,17 @@ export const computeStepOutputSchema = ({
return generateFormOutputSchema(formFields, objectMetadataItems);
}
case 'AI_AGENT': {
return {
response: {
isLeaf: true,
type: FieldMetadataType.TEXT,
label: 'Response',
value: null,
},
};
}
case 'SEND_EMAIL':
case 'DRAFT_EMAIL': {
return {