compound-assign-loop.ts 431 B

12345678910
  1. // Realistic idiom: accumulate a report string across a loop of asks with `+=`, then
  2. // summarize. The worker artifacts must reach the summarizer through the accumulator.
  3. const inputs = ["a.ts", "b.ts", "c.ts"];
  4. let report = "";
  5. for (const f of inputs) {
  6. const r = await agent("worker").ask<string>(`analyze ${f}`);
  7. report += r;
  8. }
  9. const summary = await agent("summarizer").ask<string>(`Summarize:\n${report}`);
  10. return summary;