/** * Agent loop that works with AgentMessage throughout. * Transforms to Message[] only at the LLM call boundary. */ import { EventStream } from "../ai/index.js"; import type { AgentContext, AgentEvent, AgentLoopConfig, AgentMessage, AgentTool, AgentToolCall, StreamFn } from "./types.js"; export type AgentEventSink = (event: AgentEvent) => Promise | void; /** * Start an agent loop with a new prompt message. * The prompt is added to the context and events are emitted for it. */ export declare function agentLoop(prompts: AgentMessage[], context: AgentContext, config: AgentLoopConfig, signal?: AbortSignal, streamFn?: StreamFn): EventStream; /** * Continue an agent loop from the current context without adding a new message. * Used for retries - context already has user message or tool results. * * **Important:** The last message in context must convert to a `user` or `toolResult` message * via `convertToLlm`. If it doesn't, the LLM provider will reject the request. * This cannot be validated here since `convertToLlm` is only called once per turn. */ export declare function agentLoopContinue(context: AgentContext, config: AgentLoopConfig, signal?: AbortSignal, streamFn?: StreamFn): EventStream; export declare function runAgentLoop(prompts: AgentMessage[], context: AgentContext, config: AgentLoopConfig, emit: AgentEventSink, signal?: AbortSignal, streamFn?: StreamFn): Promise; export declare function runAgentLoopContinue(context: AgentContext, config: AgentLoopConfig, emit: AgentEventSink, signal?: AbortSignal, streamFn?: StreamFn): Promise; /** * Detects whether a tool call is missing any required parameter, indicating the * provider truncated the response before the tool arguments were fully emitted. * Used together with `stopReason === "length"` to short-circuit tool validation * when a streamed tool call is incomplete (which would otherwise throw * `Validation failed ... You provided: {}`). */ export declare function hasMissingRequiredArguments(tool: AgentTool, toolCall: AgentToolCall): boolean; //# sourceMappingURL=agent-loop.d.ts.map