callback-multi-target-dispatch.ts 547 B

123456789
  1. // Callback invocation family: an indirect dispatch that may reach EITHER of two script
  2. // functions. The oracle records both as callee applications, so the call inlines as one
  3. // exhaustive `choice` with a `branch > call` arm per target: exactly one runs, each `maybe`.
  4. const seed = await agent("seed").ask<string>("seed");
  5. const fast = (s: string) => agent("fast").ask<string>(`fast ${s}`);
  6. const slow = (s: string) => agent("slow").ask<string>(`slow ${s}`);
  7. const pick = seed.length > 3 ? fast : slow;
  8. const out = await pick(seed);
  9. return out;