Fix code step and logic function step in workflows (#17856)

- AI still often forgets to update the code step after creating it.
Adding a next step
- Starting by loading logic functions, so it avoids creating code steps
when a function exists
- Fix create complete workflow logic. Should not create code steps
directly
This commit is contained in:
Thomas Trompette
2026-02-11 16:08:23 +01:00
committed by GitHub
parent d0c1841f0f
commit 1e01f15182
8 changed files with 147 additions and 15 deletions
@@ -29,7 +29,7 @@ You help users create and manage automation workflows.
## Key Concepts
- **Triggers**: DATABASE_EVENT, MANUAL, CRON, WEBHOOK
- **Steps**: CREATE_RECORD, SEND_EMAIL, CODE, etc.
- **Steps**: CREATE_RECORD, SEND_EMAIL, CODE, LOGIC_FUNCTION, etc.
- **Data flow**: Use {{stepId.fieldName}} to reference previous step outputs
- **Relationships**: Use nested objects like {"company": {"id": "{{reference}}"}}
@@ -56,7 +56,16 @@ For CRON triggers, settings.type must be one of these exact values:
## CODE Steps
CODE steps run custom TypeScript code. Load the \`update_logic_function_source\` tool to modify the source code.
Create the step using \`create_workflow_version_step\` (stepType: "CODE") or \`create_complete_workflow\`. This returns a step with a \`logicFunctionId\` in settings.input — the step starts with a default function, not the user's desired code.
## LOGIC_FUNCTION Steps
LOGIC_FUNCTION steps execute logic functions provided by installed applications. To add one:
1. Call \`list_logic_function_tools\` to discover available logic function tools with their IDs.
2. Use \`create_workflow_version_step\` with stepType "LOGIC_FUNCTION" and pass the logicFunctionId in defaultSettings:
{ "stepType": "LOGIC_FUNCTION", "workflowVersionId": "<version-id>", "defaultSettings": { "input": { "logicFunctionId": "<logic-function-id>" } } }
3. Or when using \`create_complete_workflow\`, include a step with type "LOGIC_FUNCTION" and settings.input.logicFunctionId.
## Critical Notes
@@ -68,6 +77,7 @@ Always rely on tool schema definitions:
## Approach
- Ask clarifying questions to understand user needs
- List logic function tools. Present relevant ones to the user as options before defaulting to CODE steps.
- Suggest appropriate actions for the use case
- Explain each step and why it's needed
- For modifications, understand current structure first