order-dynamic-promise-await.ts 601 B

1234567891011
  1. // `await` of a dynamically-selected promise: the awaited expression is a ternary over
  2. // two pending asks and issues nothing, so the barrier widens over BOTH. Over-ordering
  3. // is the honest direction — it understates parallelism, never invents it. Both widened
  4. // edges into the trailing step carry `maybe`.
  5. const topic = "which side";
  6. const left = agent("left").ask<string>("L");
  7. const right = agent("right").ask<string>("R");
  8. const pick = topic.length > 3 ? left : right;
  9. const chosen = await pick;
  10. const summary = await agent("summarizer").ask<string>("wrap up");
  11. return `${chosen} ${summary}`;