UNPKG

@mastra/core

Version:
56 lines • 2.66 kB
/** * Shared helper for the per-iteration LLM execution step in both the * non-durable `loop/workflows/agentic-execution/llm-execution-step.ts` and * the durable `agent/durable/workflows/steps/llm-execution.ts`. * * Returns the args that get forwarded to `messageList.get.all.aiV5.llmPrompt` * / `aiV6.llmPrompt`. Resolves the model's `supportedUrls` (which AI SDK * providers may expose as a `PromiseLike`) before handing it back, so callers * can `await` once and forget. * * Keeping this in a single source of truth fixes the parity bug where the * durable step previously did not forward `supportedUrls`, which caused * provider-native URLs (e.g. Vertex `gs://`, Mistral PDF URLs) to be * downloaded and base64-inlined instead of passed through as references. * See https://github.com/mastra-ai/mastra/issues/12152. */ export interface BuildLlmPromptArgsInput { /** * The resolved AI SDK language model the request is about to be sent to. * Only `supportedUrls` and `provider` are read; other fields are ignored. */ model: { supportedUrls?: Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>; provider?: string; } | null | undefined; /** * Optional retry count for downloading remote assets the model can't natively * fetch. Defaults to the underlying `MessageList` default (3) when omitted. */ downloadRetries?: number; /** * Optional concurrency for downloading remote assets. Defaults to the * underlying `MessageList` default (10) when omitted. */ downloadConcurrency?: number; /** * Replace user attachments that fail to download with a text placeholder * instead of failing the prompt. Set on the last-resort retry after error * processors and fallback models could not recover the download failure. */ skipUnavailableAttachments?: boolean; } export interface BuildLlmPromptArgsResult { supportedUrls: Record<string, RegExp[]> | undefined; downloadRetries: number | undefined; downloadConcurrency: number | undefined; /** * The provider the prompt is being built for, so conversion can tell stored * provider-executed tool results produced by *this* provider apart from ones * produced by a different provider earlier in the same thread. */ targetProvider: string | undefined; skipUnavailableAttachments: boolean | undefined; } export declare function buildLlmPromptArgs({ model, downloadRetries, downloadConcurrency, skipUnavailableAttachments, }: BuildLlmPromptArgsInput): Promise<BuildLlmPromptArgsResult>; //# sourceMappingURL=build-llm-prompt-args.d.ts.map