Branch

Pick one subtree out of several, with a no-match outcome and a confidence floor.

LIVE DEMO →which chart answers the question

Branch asks a Choice question and renders the matching child. It is the right primitive when the options are unordered and exactly one should win.

<Branch
  ask="Which view best answers the question in `data.question`?"
  data={{ question }}
  minConfidence={0.5}
  onResolved={(cost) => console.log(cost.shareUsd)}
>
  <Option k="line" when="The question is about a trend across many time periods.">
    <LineChart />
  </Option>
  <Option k="table" when="The question needs exact per-row numbers.">
    <Table />
  </Option>
  <Option fallback>
    <Table />
  </Option>
</Branch>

Props

proptypewhat it does
askstringThe question. Backticked paths scope which state it receives.
dataJsonLocal state for this judgment, read as data.*.
minConfidencenumberBelow this, the fallback renders instead of the winner.
pendingReactNodeRendered while resolving. Defaults to the fallback.
onVerdict(v) => voidThe selected key, confidence, distribution, and why.
pickChannel[]Narrow which state channels it receives. Default: all of them.
onResolved(cost) => voidWhat the request that answered this Branch cost.
idstringA readable id for the Inspector. Does not affect fixtures.

How it becomes a question

your codethe question object
ask="…"instructions
<Option k="line" when="…">criteria.line
(automatic)criteria.__none__
data={{ … }}state.data.<id>
minConfidence, fallbacknever sent — applied to the answer in code

When the fallback renders

  • Confidence is below minConfidence — the model reports it is not sure, so do not act on a guess.
  • The model picked the no-match option, meaning none of your options fit the state.
  • The judgment failed outright. The failure is recorded and visible in the Inspector rather than swallowed.

Low confidence on a Choice often means no option is a clear winner, not that the model is broken. Several acceptable alternatives spread probability too — a harmless preference does not need a high floor.