order-control-guarded-ask.ts 376 B

12345678
  1. // `if (result) …` guarding a later ask: a `control` edge from the tested step into the
  2. // guarded one, and the guarded step's certainty drops to `maybe`.
  3. const triage = await agent("triage").ask<{ escalate: boolean }>("triage this");
  4. if (triage.escalate) {
  5. const senior = await agent("senior").ask<string>("handle escalation");
  6. return senior;
  7. }
  8. return "no escalation";