agent-array-indexed-selection.ts 448 B

12345678
  1. // Agents stored in an array, selected by a static vs a computed index on the ask
  2. // receiver. agents[0] is field-sensitive (singleton actor#1, exact); agents[i] with
  3. // a computed index widens the receiver to the whole array {actor#1, actor#2}.
  4. const agents = [agent("worker-a"), agent("worker-b")];
  5. const seed = await agents[0]!.ask<string>("seed");
  6. const i = seed.length % 2;
  7. const out = await agents[i]!.ask<string>(`use ${seed}`);
  8. return out;