order-loop-two-steps-carry.ts 509 B

1234567891011
  1. // A TWO-step loop whose body output feeds the next round: the `carry` edge closes a
  2. // cycle BETWEEN the two steps (writer -> editor -> writer) and neither gets a
  3. // self-arrow. Contrast control-flow-do-while-self-loop.ts, the single-step case.
  4. const writer = agent("writer");
  5. const editor = agent("editor");
  6. let notes = "none";
  7. for (let round = 0; round < 3; round++) {
  8. const draft = await writer.ask<string>(`write, notes: ${notes}`);
  9. notes = await editor.ask<string>(`edit ${draft}`);
  10. }
  11. return notes;