lloyal-agents API Reference
    Preparing search index...

    Function diverge

    • Multi-branch perplexity selection as an Effection operation

      Forks N branches from a parent (or a fresh root), generates to EOG via batched BranchStore.commit, then selects the lowest-perplexity attempt. Loser branches are pruned; the caller receives the best branch still alive.

      When opts.parent is provided, the parent branch is NOT pruned — it's owned by the calling scope. Only the forked attempt branches (losers) are pruned. The caller owns the winning branch's lifecycle, typically via Session.promote.

      Cleanup is structured: each forked branch registers an ensure() callback that prunes it on scope exit. Winners are marked disposed-safe (already pruned or ownership transferred) before the ensure fires.

      Parameters

      • opts: DivergeOptions

        Diverge options specifying parent or prompt, attempt count, and sampling parameters

      Returns Operation<DivergeResult>

      Result containing the best branch, all attempt outputs, and aggregate statistics

      const verified = yield* diverge({
      prompt: verifyPrompt,
      attempts: 3,
      params: { temperature: 0.7 },
      });
      // verified.best is the lowest-perplexity branch, still alive
      yield* call(() => session.promote(verified.best));