@mastra/core
Version:
32 lines • 1.86 kB
TypeScript
import type { MessageList } from '../../agent/message-list/index.js';
/** Tool call id to the ids of the background tasks behind it whose final outcome is in the conversation. */
export type BackgroundOutcomes = Map<string, Set<string>>;
/**
* Records which background tasks already have their final outcome (result or failure) in the run's
* response messages. Take it before building the prompt: an outcome that lands while the prompt is
* built or processed may be missing from what the model receives, so it must not count.
*
* Reads the persisted response view because a memory save drains the unsaved one. Tasks in older
* thread history belong to the turns that ran them and are skipped.
*
* @param messageList - The run's message list.
* @returns The outcomes by tool call id. Empty when no background task has finished.
*/
export declare function snapshotBackgroundOutcomes(messageList: MessageList): BackgroundOutcomes;
type PromptLike = ReadonlyArray<{
content: unknown;
}>;
/**
* Lists the background tasks from `outcomes` whose results the model receives. An `untilIdle`
* stream reads this to skip its follow-up request for a task the model has already seen. A request
* processor may have dropped or replaced a result, so a result counts only when `prompt` still
* carries it as `builtPrompt` did.
*
* @param outcomes - Snapshot taken by {@link snapshotBackgroundOutcomes} before the prompt was built.
* @param builtPrompt - The prompt built from the message list, before request processors ran.
* @param prompt - The prompt sent to the model, after request processors ran.
* @returns The task ids, without duplicates.
*/
export declare function backgroundOutcomesInPrompt(outcomes: BackgroundOutcomes, builtPrompt: PromptLike, prompt: PromptLike): string[];
export {};
//# sourceMappingURL=background-outcomes.d.ts.map