Skip to content

Commit 2ba5442

Browse files
authored
fix: Update builder to better work with loops and binary data (no-changelog) (#19040)
1 parent 38de3ee commit 2ba5442

File tree

6 files changed

+46
-8
lines changed

6 files changed

+46
-8
lines changed

packages/@n8n/ai-workflow-builder.ee/evaluations/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ Violations are categorized by severity:
123123
# Run with default settings
124124
pnpm eval
125125

126+
# Run a specific test case
127+
pnpm eval --test-case google-sheets-processing
128+
pnpm eval --test-case extract-from-file
129+
126130
# With additional generated test cases
127131
GENERATE_TEST_CASES=true pnpm eval
128132

packages/@n8n/ai-workflow-builder.ee/evaluations/chains/test-case-generator.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,16 @@ export const basicTestCases: TestCase[] = [
142142
prompt:
143143
'Create a multi-agent AI workflow where different AI agents collaborate to research a topic, fact-check information, and compile comprehensive reports.',
144144
},
145+
{
146+
id: 'google-sheets-processing',
147+
name: 'Process large Google Sheets data',
148+
prompt:
149+
'Create a workflow that reads all rows from a Google Sheets document with thousands of customer records. For each row, call an external API to get additional customer data, process the response, and update the row with the enriched information. Handle rate limiting and errors gracefully.',
150+
},
151+
{
152+
id: 'extract-from-file',
153+
name: 'Extract data from uploaded files',
154+
prompt:
155+
'Build a workflow that accepts file uploads through an n8n form. When users upload PDF documents, CSV files, or Excel spreadsheets, automatically extract the text content and data from these files. Transform the extracted data into a structured format and save it to a database or send it via email as a summary.',
156+
},
145157
];

packages/@n8n/ai-workflow-builder.ee/evaluations/chains/workflow-evaluator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Evaluate whether the workflow correctly implements what the user EXPLICITLY requ
5454
- Missing core functionality explicitly requested
5555
- Incorrect operation logic that prevents the workflow from working
5656
- Workflows missing a trigger node when they need to start automatically or by some external event
57+
- Using Split In Batches node
5758
- **Major (-15 to -25 points)**:
5859
- Missing explicitly required data transformations
5960
- Incomplete implementation of requested features

packages/@n8n/ai-workflow-builder.ee/evaluations/cli/runner.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { generateMarkdownReport } from '../utils/evaluation-reporter.js';
2424
* Main CLI evaluation runner that executes all test cases in parallel
2525
* Supports concurrency control via EVALUATION_CONCURRENCY environment variable
2626
*/
27-
export async function runCliEvaluation(): Promise<void> {
27+
export async function runCliEvaluation(testCaseFilter?: string): Promise<void> {
2828
console.log(formatHeader('AI Workflow Builder Full Evaluation', 70));
2929
console.log();
3030
try {
@@ -34,11 +34,24 @@ export async function runCliEvaluation(): Promise<void> {
3434
// Determine test cases to run
3535
let testCases: TestCase[] = basicTestCases;
3636

37-
// Optionally generate additional test cases
38-
if (shouldGenerateTestCases()) {
39-
console.log(pc.blue('➔ Generating additional test cases...'));
40-
const generatedCases = await generateTestCases(llm, howManyTestCasesToGenerate());
41-
testCases = [...testCases, ...generatedCases];
37+
// Filter to single test case if specified
38+
if (testCaseFilter) {
39+
const filteredCase = testCases.find((tc) => tc.id === testCaseFilter);
40+
if (filteredCase) {
41+
testCases = [filteredCase];
42+
console.log(pc.blue(`➔ Running single test case: ${filteredCase.name}`));
43+
} else {
44+
console.log(pc.red(`❌ Test case '${testCaseFilter}' not found`));
45+
console.log(pc.dim(`Available test cases: ${testCases.map((tc) => tc.id).join(', ')}`));
46+
return;
47+
}
48+
} else {
49+
// Optionally generate additional test cases
50+
if (shouldGenerateTestCases()) {
51+
console.log(pc.blue('➔ Generating additional test cases...'));
52+
const generatedCases = await generateTestCases(llm, howManyTestCasesToGenerate());
53+
testCases = [...testCases, ...generatedCases];
54+
}
4255
}
4356

4457
// Get concurrency from environment

packages/@n8n/ai-workflow-builder.ee/evaluations/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ export { setupTestEnvironment, createAgent } from './core/environment.js';
1414
async function main(): Promise<void> {
1515
const useLangsmith = process.env.USE_LANGSMITH_EVAL === 'true';
1616

17+
// Parse command line arguments for single test case
18+
const testCaseId = process.argv.includes('--test-case')
19+
? process.argv[process.argv.indexOf('--test-case') + 1]
20+
: undefined;
21+
1722
if (useLangsmith) {
1823
await runLangsmithEvaluation();
1924
} else {
20-
await runCliEvaluation();
25+
await runCliEvaluation(testCaseId);
2126
}
2227
}
2328

packages/@n8n/ai-workflow-builder.ee/src/tools/prompts/main-agent.prompt.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ Why: Unconfigured nodes WILL fail at runtime
238238
For AI-generated structured data, prefer Structured Output Parser nodes over Code nodes.
239239
Why: Purpose-built parsers are more reliable and handle edge cases better than custom code.
240240
241+
For binary file data, use Extract From File node to extract content from files before processing.
242+
241243
Use Code nodes only for:
242244
- Simple string manipulations
243245
- Already structured data (JSON, CSV)
@@ -321,9 +323,10 @@ Anticipate workflow needs and suggest enhancements:
321323
- Set nodes for data transformation between incompatible formats
322324
- Schedule Triggers for recurring tasks
323325
- Error handling for external service calls
324-
- Split In Batches for large dataset processing
325326
326327
Why: Proactive suggestions create more robust, production-ready workflows
328+
329+
NEVER use Split In Batches nodes.
327330
</proactive_design>
328331
329332
<parameter_updates>

0 commit comments

Comments
 (0)