NOETIC
Framework
API Reference

Step Types

Type definitions for all step variants in Noetic's discriminated union.

Step Union

The Step type is a discriminated union over the kind field:

import type {
  Step,
  StepConditional,
  StepInParallel,
  StepCallModel,
  StepLoop,
  StepWithContext,
  StepRunCode,
  StepSpawn,
  StepInvokeTool,
} from '@noetic-tools/core';

type _AssertShape<TContext, I, O> =
  | StepRunCode<TContext, I, O>
  | StepCallModel<TContext, I, O>
  | StepInvokeTool<TContext, I, O>
  | StepConditional<TContext, I, O>
  | StepInParallel<TContext, I, O>
  | StepSpawn<TContext, I, O>
  | StepWithContext<TContext, I, O>
  | StepLoop<TContext, I, O>;

type _AssertSubset<TContext, I, O> = _AssertShape<TContext, I, O> extends Step<TContext, I, O>
  ? true
  : false;

The exported Step union additionally includes StepSchedule for fixed-interval scheduling.

StepRunCode

StepRunCode<TContext, I, O>

FieldTypeRequiredDescription
kind'runCode'yesDiscriminant
idstringyesStep identifier
execute(input: I, ctx: Context<TContext>) => Promise<O>yesAsync function to execute
retryRetryPolicynoRetry configuration

StepCallModel

StepCallModel<TContext, I, O>

FieldTypeRequiredDescription
kind'callModel'yesDiscriminant
idstringyesStep identifier
modelstringyesModel identifier
instructionsstringnoSystem prompt / instructions for the model
toolsTool[]noAllowed tool subset (undefined = all, [] = none)
outputStandardSchemaV1<unknown, O> | OutputCodec<O>noStructured output schema (any Standard Schema v1; Zod is the default) or a streaming codec
outputJsonSchemaRecord<string, unknown>noExplicit JSON Schema override/fallback for non-Zod output. Conversion order is Zod → StandardJSONSchemaV1 → this field; validation-only schemas require it
paramsModelParamsnoSampling parameters
emitboolean | ((eventType, data) => boolean)noControls framework event emission for this step. Defaults to true. Pass false to suppress all framework events, or a filter function to allow specific events through.

StepInvokeTool

StepInvokeTool<TContext, I, O>

FieldTypeRequiredDescription
kind'invokeTool'yesDiscriminant
idstringyesStep identifier
toolTool<StandardSchemaV1<unknown, I>, StandardSchemaV1<unknown, O>>yesTool definition
argsPartial<I>noPreset arguments

StepConditional

StepConditional<TContext, I, O>

FieldTypeRequiredDescription
kind'conditional'yesDiscriminant
idstringyesStep identifier
route(input: I, ctx: Context<TContext>) => Step<TContext, I, O> | nullyesRouting function (null skips)

StepInParallel

inParallel has three mode variants, each a separate interface.

StepInParallelRace

StepInParallelRace<TContext, I, O>

FieldTypeRequiredDescription
kind'inParallel'yesDiscriminant
idstringyesStep identifier
mode'race'yesFirst completion wins
paths(input: I, ctx: Context<TContext>) => Step<TContext, I, O>[]yesPath factory
concurrencynumbernoMax parallel paths

StepInParallelAll

StepInParallelAll<TContext, I, O>

FieldTypeRequiredDescription
kind'inParallel'yesDiscriminant
idstringyesStep identifier
mode'all'yesWait for all paths
paths(input: I, ctx: Context<TContext>) => Step<TContext, I, O>[]yesPath factory
merge(results: O[], ctx: Context<TContext>) => OyesMerge function
concurrencynumbernoMax parallel paths

StepInParallelSettle

StepInParallelSettle<TContext, I, O>

FieldTypeRequiredDescription
kind'inParallel'yesDiscriminant
idstringyesStep identifier
mode'settle'yesWait for all, include errors
paths(input: I, ctx: Context<TContext>) => Step<TContext, I, O>[]yesPath factory
merge(results: SettleResult<O>[], ctx: Context<TContext>) => OyesMerge function
concurrencynumbernoMax parallel paths

StepWithContext

StepWithContext<TContext, I, O>

FieldTypeRequiredDescription
kind'withContext'yesDiscriminant
idstringyesStep identifier
childStep<TContext, I, O>yesChild step to execute with the provided layers
contextContextConfig | ContextLayer[]yesContext layers available to all descendant steps

StepSpawn

StepSpawn<TContext, I, O>

FieldTypeRequiredDescription
kind'spawn'yesDiscriminant
idstringyesStep identifier
childStep<TContext, I, O>yesChild step to execute
contextContextConfig | ContextLayer[]noSpawn-local context layers
timeoutnumbernoTimeout in milliseconds

StepLoop

StepLoop<TContext, I, O>

FieldTypeRequiredDescription
kind'loop'yesDiscriminant
idstringyesStep identifier
stepsReadonlyArray<Step<TContext, I, O>>yesLoop body steps
untilUntilyesTermination predicate
maxIterationsnumbernoSafety limit on iterations
maxHistorySizenumbernoMax history items to retain
inboxChannel<string>noChannel for external messages that prevent loop from stopping
parkTimeoutnumbernoMilliseconds to wait on inbox before stopping (0 = non-blocking)
prepareNext(output: O, verdict: Verdict, ctx: Context<TContext>) => InoTransform output to next input
onError(error: NoeticError, ctx: Context<TContext>) => 'retry' | 'skip' | 'abort'noError handler

StepSchedule

StepSchedule<TContext, I, O>

A step that runs a body step on a fixed-interval schedule, optionally woken sooner by a wake channel. Runs forever until the executing context is cancelled. The operator output is voidschedule does not accumulate iteration outputs.

FieldTypeRequiredDescription
kind'schedule'yesDiscriminant
idstringyesStep identifier
stepStep<TContext, I, O>yesBody step executed on each iteration
intervalnumberyesPark duration between iterations in milliseconds. Must be >= 0.
inboxChannel<unknown>noChannel that wakes the parking interval when any value arrives
onError'continue' | 'fail'noBehavior when step throws. Defaults to 'continue' (record the error and keep parking).
jitternumbernoRandom jitter applied to the park duration in milliseconds. Must be >= 0. Defaults to 0.

Supporting Types

SettleResult

FieldTypeDescription
stepIdstringStep that produced this result
status'fulfilled' | 'rejected'Outcome
valueOPresent if fulfilled
errorNoeticErrorPresent if rejected

RetryPolicy

FieldTypeDescription
maxAttemptsnumberMaximum retry attempts
backoff'fixed' | 'linear' | 'exponential'Backoff strategy
initialDelaynumberInitial delay in milliseconds
maxDelaynumberMaximum delay cap (optional)

ModelParams

FieldTypeDescription
temperaturenumberSampling temperature (optional)
topPnumberNucleus sampling (optional)
maxTokensnumberMax response tokens (optional)
stopSequencesstring[]Stop sequences (optional)

Tool

FieldTypeDescription
namestringTool name (used by the LLM for selection).
descriptionstringTool description shown to the LLM.
inputStandardSchemaV1<I>Schema validating tool input arguments (any Standard Schema v1; Zod is the default).
outputStandardSchemaV1<O>Schema validating tool return value.
inputJsonSchemaRecord<string, unknown>Explicit JSON Schema override/fallback for non-Zod input. Conversion order is Zod → StandardJSONSchemaV1 → this field; validation-only schemas require it.
eventStandardSchemaV1Optional schema validating streaming events yielded during execution.
itemSchemasItemSchemaExtensionsOptional item schemas for tool-call/result extensions contributed by this tool. toolResults schemas are owner-scoped: they validate only this tool's own result items and never reject a sibling tool's results. Schemas are pure shape validators (gates, not normalizers) — the original item is returned on match, and Zod transforms/defaults are unsupported.
decorateResultItem(params) => ItemDecorate the harness-created tool-result item before it is appended/emitted. The decorated item must satisfy this tool's own itemSchemas.toolResults (when declared) — including for error outputs such as malformed-arguments results — or the round fails with NoeticError kind item_schema_mismatch.
execute(args: InferSchemaOutput<I>, toolCtx: ToolExecutionContext) => Promise<InferSchemaOutput<O>> | AsyncGenerator<unknown, InferSchemaOutput<O>>Async function (or generator) that performs the tool's work. InferSchemaOutput is z.output for Zod schemas and StandardSchemaV1.InferOutput otherwise.
needsApprovalbooleanOptional. When true, execution pauses for human approval before running.
contextToolContextDeclarationOptional. Declares tool-owned state the runtime materializes into a ContextLayer.

ExecuteStepFn

declare const executeStepShape: <TContext, I, O>(
  step: Step<TContext, I, O>,
  input: I,
  ctx: Context<TContext>,
) => Promise<O>;

On this page