Templates
Templates allow dynamic content in workflow directives, conditions, and other fields. Use template variables to access execution context, step results, and workflow parameters.
Basic Syntax
Section titled “Basic Syntax”Template variables use double curly braces:
{{variableName}}Variables are resolved at runtime from the execution context.
Available Variables
Section titled “Available Variables”Execution Context
Section titled “Execution Context”{{executionId}} - Current execution ID{{workflowId}} - Workflow being executed{{currentNodeId}} - Current node IDUser Variables
Section titled “User Variables”Variables set during execution:
{{projectName}} - Custom variable{{results}} - Previous step output{{count}} - Numeric variableNode Results
Section titled “Node Results”Access previous step results:
{{input}} - Last step's input{{nodeStates.nodeId.result}} - Specific node's resultSetting Variables
Section titled “Setting Variables”Variables can be set in node definitions:
{ "id": "set-vars", "type": "step", "directive": "Initialize project", "completionCondition": "Project initialized", "setVariables": { "projectName": "my-project", "environment": "development" }}Or dynamically from agent response via inputSchema:
{ "inputSchema": { "type": "object", "properties": { "projectName": { "type": "string" } } }}The agent’s response values are automatically added to context.
Conditional Templates
Section titled “Conditional Templates”Use conditional blocks to include or exclude content based on context values:
{{#if variable}}Content when truthy{{else}}Content when falsy{{/if}}{{#if variable}}Content when truthy{{/if}}Falsy values: null, undefined, false, 0, "", "нет", "no"
Examples
Section titled “Examples”{{#if has_file_access}}Save to ./output.md{{else}}Return result in response{{/if}}{{#if approved}}Proceeding with deployment{{else}}Waiting for approval{{/if}}Conditional templates are processed in directive and completionCondition fields of agent-directive nodes.
Unless Templates
Section titled “Unless Templates”Use {{#unless}} for the opposite of {{#if}} - content is shown when variable is falsy:
{{#unless isLoggedIn}}Please log in{{/unless}}{{#unless hasError}}Success!{{else}}Error occurred{{/unless}}Equality Comparison Templates
Section titled “Equality Comparison Templates”Use {{#eq}} to compare a variable with a string value:
{{#eq variable 'value'}}Content when equal{{/eq}}{{#eq variable 'value'}}Content when equal{{else}}Content when not equal{{/eq}}Example:
{{#eq upload_target 'staging'}}Deploy to staging server{{/eq}}{{#eq upload_target 'production'}}Deploy to production server{{/eq}}Not-Equal Comparison Templates
Section titled “Not-Equal Comparison Templates”Use {{#neq}} to show content when variable does NOT equal a value:
{{#neq variable 'value'}}Content when not equal{{/neq}}{{#neq variable 'value'}}Content when not equal{{else}}Content when equal{{/neq}}Example:
{{#neq test_info 'skip'}}Run tests: {{test_command}}{{/neq}}Iteration Templates
Section titled “Iteration Templates”Use {{#each}} to iterate over arrays:
{{#each items}}{{this}}, {{/each}}{{#each users}}{{name}} ({{age}})\n{{/each}}{{#each steps}}{{@index}}: {{action}}{{/each}}Inside {{#each}}:
{{this}}- current item value (serialized for objects){{this.fieldName}}- access field of current item object{{this.nested.path}}- access nested fields{{@index}}- current index (0-based){{fieldName}}- shorthand for{{this.fieldName}}
Supports conditionals inside loops:
{{#each tasks}}{{#if done}}[x]{{else}}[ ]{{/if}} {{name}}\n{{/each}}Examples
Section titled “Examples”Dynamic Directive
Section titled “Dynamic Directive”{ "directive": "Implement the {{featureName}} feature in {{projectName}}", "completionCondition": "Feature {{featureName}} is implemented and tested"}Conditional Transition
Section titled “Conditional Transition”{ "transitions": [ { "condition": "{{testsPassed}} === true", "target": "deploy" }, { "condition": "{{retryCount}} < 3", "target": "fix-and-retry" }, { "target": "escalate" } ]}Loop with Counter
Section titled “Loop with Counter”{ "type": "loop", "directive": "Iteration {{iterationCount}}: Improve the solution", "loopCondition": "{{qualityScore}} < 8 && {{iterationCount}} < 5"}Template in Input Schema Description
Section titled “Template in Input Schema Description”Help agents understand expected format:
{ "inputSchema": { "type": "object", "properties": { "implementation": { "type": "string", "description": "Code for {{featureName}} in {{language}}" } } }}Escaping
Section titled “Escaping”To output literal curly braces, use double escaping:
\\{{notAVariable}} - Outputs: {{notAVariable}}Best Practices
Section titled “Best Practices”- Descriptive Names - Use clear variable names
- Default Values - Provide fallbacks for optional variables
- Type Consistency - Keep variable types consistent across usage
- Documentation - Document custom variables in workflow description
Debugging
Section titled “Debugging”Check variable values in execution context:
Agent: What are the current context variables?[calls get_execution_context]