Skip to content

AgentModelFactory

AgentModelFactory = (ctx) => AnyTextAdapter | Promise<AnyTextAdapter>

Defined in: packages/engine/src/lib/agent-session/agent-config.ts:35

Picks the text adapter for one Agent Run. Called once per run before the run starts, and the returned adapter serves every model turn of that run. For a per-turn model choice, return a delegating adapter that picks an inner adapter per call. A throw, a rejection, or a value without a chatStream method ends the run with an error before it starts. So does a factory still pending after the run’s maxElapsedMs, or after the default 120,000 ms when budgets come from a resolver. Its late result is discarded.

AgentRunContext

AnyTextAdapter | Promise<AnyTextAdapter>