import type { AgentMiddleware } from '../create-agent.js'; /** Options for `modelCallLimit()`. Set `run`, `thread`, or both. */ export interface ModelCallLimitOptions { /** Model calls in one run: from a user message to the answer, a resumed approval included. */ run?: number; /** * Model calls over a thread's whole life, every run on it included. Counted in the agent's store * when it has one, so every process shares the count and it survives a restart; otherwise in this * process. A budget, not a lock: two runs on one thread at the same moment may each pass it once. */ thread?: number; /** * What happens at a limit: `end` answers with `message` and stops with `stopReason: 'stopped'`, * without calling the model; `error` fails the run with a `ModelCallLimitError`. Defaults to `end`. */ onLimit?: 'end' | 'error'; /** The answer a run ends with under `end`. Defaults to a sentence naming the limit. */ message?: string; } /** Thrown by `modelCallLimit()` under `onLimit: 'error'`. */ export declare class ModelCallLimitError extends Error { /** Which limit was reached. */ readonly scope: 'run' | 'thread'; /** The limit. */ readonly limit: number; /** Always `MODEL_CALL_LIMIT`. */ readonly code = "MODEL_CALL_LIMIT"; constructor( /** Which limit was reached. */ scope: 'run' | 'thread', /** The limit. */ limit: number); } /** * Caps the model calls of a run, of a thread, or both. * * `maxIterations` stops one run that keeps calling tools; this is a budget an application sets per * run and per conversation, so a thread a user keeps coming back to cannot spend without bound. The * run count is read from the transcript, so it survives a restart. A run that reaches a limit ends * with an answer rather than an error, unless you ask for one. */ export declare function modelCallLimit(options: ModelCallLimitOptions): AgentMiddleware;