Skip to content

Templates

Templates allow dynamic content in workflow directives, conditions, and other fields. Use template variables to access execution context, step results, and workflow parameters.

Template variables use double curly braces:

{{variableName}}

Variables are resolved at runtime from the execution context.

{{executionId}} - Current execution ID
{{workflowId}} - Workflow being executed
{{currentNodeId}} - Current node ID

Variables set during execution:

{{projectName}} - Custom variable
{{results}} - Previous step output
{{count}} - Numeric variable

Access previous step results:

{{input}} - Last step's input
{{nodeStates.nodeId.result}} - Specific node's result

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.

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"

{{#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.

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}}

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}}

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}}

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}}
{
"directive": "Implement the {{featureName}} feature in {{projectName}}",
"completionCondition": "Feature {{featureName}} is implemented and tested"
}
{
"transitions": [
{ "condition": "{{testsPassed}} === true", "target": "deploy" },
{ "condition": "{{retryCount}} < 3", "target": "fix-and-retry" },
{ "target": "escalate" }
]
}
{
"type": "loop",
"directive": "Iteration {{iterationCount}}: Improve the solution",
"loopCondition": "{{qualityScore}} < 8 && {{iterationCount}} < 5"
}

Help agents understand expected format:

{
"inputSchema": {
"type": "object",
"properties": {
"implementation": {
"type": "string",
"description": "Code for {{featureName}} in {{language}}"
}
}
}
}

To output literal curly braces, use double escaping:

\\{{notAVariable}} - Outputs: {{notAVariable}}
  1. Descriptive Names - Use clear variable names
  2. Default Values - Provide fallbacks for optional variables
  3. Type Consistency - Keep variable types consistent across usage
  4. Documentation - Document custom variables in workflow description

Check variable values in execution context:

Agent: What are the current context variables?
[calls get_execution_context]