iteration-fanout-reduce-no-initial.ts 542 B

1234567891011
  1. // reduce WITHOUT an initial value: at runtime the accumulator starts as parts[0]
  2. // (the glob result), so the checker ask's instructions carry world-read#1.
  3. // Expected: source -> world-read#1; world-read#1 -> fan-out#1;
  4. // world-read#1 -> ask#1 (MUST); fan-out#1 -> ask#1; sink edges from
  5. // world-read#1/fan-out#1 (the reduce result reaches the return).
  6. const parts = await files.glob("*.md");
  7. const first = parts.reduce((acc, _part) => {
  8. agent("checker").ask<string>(`check ${acc}`);
  9. return acc;
  10. });
  11. return first;