Skip to content
Français

LoopTaskOptions

import type { LoopTaskOptions } from "@elie-laloum/outpost";
  • maxRoundsRequired
    number
    Positive safe integer limiting logical rounds across resumes. Replaying an interrupted phase uses its existing round but consumes another workflow attempt.
  • attemptRequired
    (context: LoopTaskContext, feedback: string | undefined) => T | Promise<T>
    Produce the candidate output from the phase context and previous rejected check feedback; feedback is undefined in round one. Persisted outputs must be lossless JSON or undefined.
  • checkRequired
    (context: LoopTaskContext, result: T) => LoopCheckResult | Promise<LoopCheckResult>
    Accept the candidate with done: true or request another round with done: false and text feedback. May invoke a reviewer agent; report its usage through the context. Exceptions fail the task.
  • cacheOptional
    TaskCacheOptions | undefined
    Opt-in cache for the accepted loop result; a hit skips every round and records no rounds.
  • keyRequired
    string
    Stable node key used by dependencies, checkpoints and loop events.
  • afterOptional
    readonly Task<unknown>[] | undefined
    Dependencies that must succeed before the first round; their outputs are available through context.value.
  • conditionOptional
    ((context: TaskContext) => boolean | Promise<boolean>) | undefined
    Predicate evaluated before the loop starts or resumes; false skips the task and its dependents.
  • timeoutMsOptional
    number | undefined
    Cooperative deadline for one round execution, including attempt and check; renewed when an interrupted phase resumes.
export interface LoopTaskOptions<T> extends Pick<
  TaskOptions<T>,
  "key" | "after" | "condition" | "timeoutMs" | "cache"
> {
  readonly maxRounds: number;
  readonly attempt: (
    context: LoopTaskContext,
    feedback: string | undefined,
  ) => T | Promise<T>;
  readonly check: (
    context: LoopTaskContext,
    result: T,
  ) => LoopCheckResult | Promise<LoopCheckResult>;
}