Dive

Reference

Template language

The template syntax that moves data between steps, and where agents, plans and tools use it.

A template is a string with {{...}} tags that Dive fills from data before a step, tool or agent runs. Templates only move data. They never call a model, and they have no logic beyond iterating over lists.

Where templates are used

FileFieldsWhat a template can reference
Plan fileStep input strings, exit messages, finish.output, and finish.solver fieldsinput and the ids of earlier steps
Tool fileexec args, prompt messages, reshape shapes and decision stateinput
Agent filesystem_promptsession.date, session.user and rules.*

Inside a map or reduce body, item and index reference the current element, and reduce adds accumulator. A filter gate gets item and index too.

Variables

A variable is a dotted path from a root. Number segments index into arrays, and length as the last segment counts the items in an array or the characters in a string.

{{input.team}}
{{fetch_issues.values.0.id}}
{{fetch_issues.values.length}}

A word segment on a list of entries that carry a name, such as a result's files, picks the entry with that name: {{shot.files.snapshot.ref}} reads the same entry as {{shot.files.0.ref}} when snapshot is listed first. Entries marked many: true, the files a pattern collected, come back as a list: {{pages.files.pages}}, and {{pages.files.pages.0.ref}} for one.

A step that declares files also has the root files in its own input: {{files.<name>.path}} and {{files.<name>.dir}}. See Files a step writes.

Spaces inside the braces are ignored. A step id can't be input, item, index, accumulator or length, and in a plan where a step declares files, no step can be named files.

A route step's result is read through the route's own id: {{triage.branch}} names the branch that ran and {{triage.result}} holds what it returned. Steps inside a branch are visible only to later steps in the same branch.

Typed values

When a string is exactly one tag, the tag's value keeps its JSON type. When a tag sits in other text, the result is a string, and objects and arrays are written as JSON.

input:
  limit: "{{input.max}}"
  ids: "{{fetch_issues.ids}}"
  query: "team {{fetch_teams.values.0.name}}"

With max set to 50 and ids to [1, 2, 3], limit is the number 50, ids is the array [1, 2, 3], and query is the string "team Core".

A null value written into text renders as nothing.

Sections

A section renders its body once for each item in a list, once for an object or any other value, and not at all for a missing, null, false or empty value.

{{#fetch_issues.values}}
{{@index}}. {{title}} ({{state}})
{{/fetch_issues.values}}
  • Inside a section, a tag without a root, such as {{title}}, reads from the current item, then from enclosing sections. If no item has the key, it renders as nothing.

  • {{@index}} is the item's position, starting at 0. {{@first}} and {{@last}} are booleans you can use as sections.

  • An inverted section, {{^path}}...{{/path}}, renders only when the section would not:

    {{^fetch_issues.values}}No open issues.{{/fetch_issues.values}}
  • A section path that doesn't resolve counts as empty rather than an error, so {{^fetch.optional}} works as a fallback. A section over a step that doesn't exist is still an error.

Errors

A variable that doesn't resolve stops the step with one of three errors:

ErrorCauseExample
MissingStepThe root isn't input or an earlier step.{{E7.values}} when there is no step E7
BadPathThe data exists but has no such key or can't be indexed. The message lists the keys that do exist.{{fetch.values.0.idd}}
EmptyDataThe path is valid but the data ran out: an empty list, an index past the end, or null.{{fetch.values.0.id}} when values is []

dive plan validate catches references to steps that don't exist or haven't run yet before the plan runs. To learn how a plan responds to each error, see Handle failures.

Not supported

Templates have no conditionals, functions, partials, comments or inheritance, and using that syntax is a parse error. Put any computation in a step, such as a reshape tool or an infer gate.

On this page