emission-graph-join-shorthand-wrapped-element.ts 897 B

1234567891011121314151617
  1. // Root cause 8: an async map callback wraps its awaited ask in a SHORTHAND object literal
  2. // (`return { critique }`) before the Promise.all join. The wrap dropped the critic ask's
  3. // label (shorthand resolved an empty property slot), so the ask had ZERO outgoing edges:
  4. // nothing reached the join, the downstream aggregator, or the sink. With the fix the field
  5. // aliases the local's value, so the label flows through the join relay as usual.
  6. // Expected: fan-out#1 -> ask#1(critic), ask#1 -> join#1, join#1 -> ask#2(final),
  7. // ask#1 -> ask#2 (additive relay), ask#2 -> sink.
  8. const xs = ["a", "b"];
  9. const outs = await Promise.all(
  10. xs.map(async (x) => {
  11. const critic = agent(`critic-${x}`);
  12. const critique = await critic.ask<string>(`judge ${x}`);
  13. return { critique };
  14. }),
  15. );
  16. const parts = outs.map((o) => o.critique);
  17. return agent("final").ask<string>(`use ${parts.join(",")}`);