lloyal-agents API Reference
    Preparing search index...

    Function initAgents

    • Bootstrap the agent infrastructure and register structured cleanup

      Creates BranchStore, Session, and an event channel, then sets all three Effection contexts (Ctx, Store, Events) in the caller's scope. Cleanup runs on scope exit (Ctrl-C, error, normal completion) via ensure().

      Context values are set in the caller's scope — visible to all subsequent operations. This is why initAgents uses ensure() rather than resource(): a resource creates a child scope where Ctx.set() would be invisible to sibling operations.

      The caller creates the SessionContext (model path, nCtx, KV types are harness-specific decisions) and passes it in.

      Type Parameters

      Parameters

      • ctx: SessionContext

        Session context created via createContext()

      • Optionalopts: { traceWriter?: TraceWriter }

      Returns Operation<AgentHandle<E>>

      Agent handle with session, store, and event channel

      main(function*() {
      const ctx = yield* call(() => createContext({
      modelPath, nCtx: 16384,
      nSeqMax: 4, typeK: 'q4_0', typeV: 'q4_0',
      }));

      const { session, events } = yield* initAgents(ctx);
      // Ctx, Store, Events are now set — generate(), diverge(),
      // useAgentPool() will find them automatically.
      // Cleanup runs on scope exit.
      });