depends_on orders questions into stages, ask_if asks a question only when an earlier answer matches, and alone reads a question on its own. This page is for developers building question sets with follow-ups.
Everything here happens inside one decision run and one model call. You do not chain requests yourself.
The three fields
They work the same on
noul, choice and score questions.
A worked example
This set extends the ticket triage from the decision runs guide with two follow-ups:sales_leadis asked only whenbucketcomes backother.lead_valueis asked only whensales_leadcomes backyes.
triage-followups.json
bucket comes back billing, as it does for this ticket, neither follow-up is asked. An abridged, illustrative decision part of the response, without draws, read, model, label_mass and answered_within_labels:
Stages and depends_on
A stage holds every question whose depends_on questions are all in earlier stages. Questions with no dependencies form the first stage. Within a stage, questions follow question_order, or sorted ids when you leave it out. The live response reports the schedule that ran in decision.stages.
In the example, sales_lead depends on bucket, so it moves to the second stage, and lead_value depends on sales_lead, so it moves to the third.
- Forward references are allowed. A question may depend on one that appears later in
questionsor inquestion_order. The schedule comes from the dependencies, not from the order you wrote them in. - No cycles. If
adepends onbandbdepends ona, directly or through other questions, the set is refused with400 invalid_decision_questions:the questions depend on each other in a cycle. - No self-references. A question cannot name itself in
depends_onorask_if. - Only questions in the set. Every
depends_onentry must be another question id in the same run.
Gating with ask_if
ask_if maps a question id to the answer names that trigger this question:
A question set is refused with
400 invalid_decision_questions before anything is charged when:
Note that a
noul answers yes and no, not true and false. The true and false keys belong only to a noul question’s own criteria.
The skipped answer
When anask_if condition is not met, the question’s answer is:
Skips cascade. In the example,
sales_lead was skipped, so lead_value, which asks only when sales_lead is yes, is skipped too, and its because has no answered: there was no answer to compare.
Handle skipped answers in code
Every answer carriestype, so check it before you read type-specific fields. A skipped answer has no probability, choice or score.
Reading a question alone
By default, the questions in one stage are read jointly. Set "alone": true on a question to read it on its own rather than jointly with the rest of its stage.
Limits that apply
Conditional fields do not change the run’s other limits:- 1 to 64 questions per run, skipped ones included.
- The
instructions,questions,drawsandthink_tokenstogether must fit in 32 KiB. question_order, when you send it, must still name every question, including the ones that may be skipped.- The whole decision is one model call, whatever the number of stages.
Related
- Decision questions - question types, stages and answer shapes in one place.
- Decision runs - every request field, the full response and the costs.
- invalid_decision_questions - every reason a question set is refused.
- Playground - build a question set in the console and read the answers.
- Limits - every per-request limit in one table.