Dive

Reference

Conditions and bodies

The conditions exit, route and filter test, and the step lists route, map and reduce run.

- id: digest
  tool_name: route
  input:
    if:
      value: '{{commits.count}}'
      op: gt
      to: 10
    then:
      tool_name: builtin__infer
      input:
        instruction: 'Group these commits into three themes: {{commits.commits}}'
    else:
      tool_name: builtin__reshape
      input:
        shape:
          commits: '{{commits.commits}}'

Conditions

exit, route and filter each test one condition. A step takes exactly one of three kinds: a comparison, infer or decide.

StepComparison keyWhen the condition holds
exitwhenThe plan ends
routeifthen runs, otherwise else
filterwhereThe item is kept, tested once per item

Comparison

value, op and to compare two values without a model call. value is usually a template.

opHolds when value…
eq / neequals / doesn't equal to
gt / gte / lt / lteis greater / at least / less / at most to; both must be numbers
empty / not_emptyis or isn't null, "", [] or {}; no to
containsis a string containing the string to, or a list containing to

infer

infer is a yes/no question for a chat model, with the data in the question as templates. It runs on the judge model role, and model picks another. The model returns a verdict and a reason. On filter, it asks once per item, and concurrency sets how many at once.

decide

decide asks a decision model, which returns a probability instead of a verdict. It needs a decider role on a decision-model provider.

FieldWhat it holds
questionWhat to decide
stateThe data to decide on
criteriaWhat true and false mean
min_confidenceThe probability needed, 0 to 1; default 0.5
modelThe decision model role; default decider
optionsOn route only: case name to meaning, 2 to 255 entries. The model picks one, and its branch under cases runs

infer refuses a decision model, and decide refuses a chat model.

Bodies

A body is the steps a control step runs: then, else and cases on route, and do on map and reduce. It's one tool call or a list of steps.

Inside a body, steps read these values as well as the plan's inputs and earlier results:

ValueWhere
{{item}}The current item, in map, reduce and a filter condition
{{index}}The item's position, in map and reduce
{{accumulator}}The value so far, in reduce

Templates in a body render only when it runs: route renders the branch it takes, and map renders its body once per item.

What a body can contain

StepIn a body
Tools, plans and agentsYes
exitYes, and it ends the whole plan
agent, ask, filter, routeYes
map, reduceNo. Call a plan that iterates instead