computed-index.ts 468 B

123456789
  1. // Computed (dynamic) index access is THE widening rule: reading `items[i]` with a
  2. // non-literal index reads the whole container inexactly. Expected: source -> ask#1
  3. // exact, ask#1 -> ask#2 INEXACT (the computed index widened the flow), ask#2 -> sink.
  4. const seed = await agent("seed").ask<string>("seed");
  5. const items = [seed, "literal"];
  6. const i = seed.length % 2;
  7. const picked = items[i];
  8. const out = await agent("out").ask<string>(`chose ${picked}`);
  9. return out;