@mastra/core
Version:
33 lines • 1.78 kB
TypeScript
import type { WorkflowRunState } from '../../workflows/types.js';
/**
* Steps that read an earlier step's result directly (`getStepResultAsync`) instead
* of receiving it as input, keyed by reader step id. Workflow-specific, so the
* workflow that owns the steps declares them.
*/
export type StepResultReads = Readonly<Record<string, readonly string[]>>;
/**
* `pruneSnapshot` hook for the internal agent workflows. Reduces a persisted
* run snapshot to what resume actually reads: the suspended step's
* `suspendPayload` (one live `__streamState` copy) plus engine routing state.
* Copy-on-write — never mutates the snapshot it is given.
*
* On the default engine, persisted step results are read back only by a
* crash-restart: live execution keeps its in-memory `stepResults`
* authoritative. `pruneRunningHistory` therefore keeps exactly what a restart
* reads (`getRestartReads`), including the declared `stepResultReads`.
*
* `retainRunningHistory` disables that strip. It predates `stepResultReads`:
* the **evented** engine reads persisted step results during normal execution
* (not just on restart), so it originally retained every terminal step to be
* safe. Declared `stepResultReads` already keep the only same-iteration reads,
* so this is needed only by callers that read undeclared results back.
* Retaining all terminal history copied every completed step and ballooned
* evented snapshots into a heap OOM (COR-1431).
*/
export declare function pruneAgentLoopSnapshot({ snapshot, workflowStatus, retainRunningHistory, stepResultReads, }: {
snapshot: WorkflowRunState;
workflowStatus?: string;
retainRunningHistory?: boolean;
stepResultReads?: StepResultReads;
}): WorkflowRunState;
//# sourceMappingURL=prune-snapshot.d.ts.map