API Reference
Step Types
Type definitions for all step variants in Noetic's discriminated union.
The Step type is a discriminated union over the kind field:
type Step<I = unknown, O = unknown> =
| StepRun<I, O>
| StepLLM<I, O>
| StepTool<I, O>
| StepBranch<I, O>
| StepFork<I, O>
| StepSpawn<I, O>
| StepLoop<I, O>;
| Field | Type | Required | Description |
|---|
kind | 'run' | yes | Discriminant |
id | string | yes | Step identifier |
execute | (input: I, ctx: Context) => Promise<O> | yes | Async function to execute |
retry | RetryPolicy | no | Retry configuration |
| Field | Type | Required | Description |
|---|
kind | 'llm' | yes | Discriminant |
id | string | yes | Step identifier |
model | string | yes | Model identifier |
system | string | no | System prompt |
tools | Tool[] | no | Available tools |
output | ZodType<O> | no | Structured output schema |
params | ModelParams | no | Sampling parameters |
| Field | Type | Required | Description |
|---|
kind | 'tool' | yes | Discriminant |
id | string | yes | Step identifier |
tool | Tool<ZodType<I>, ZodType<O>> | yes | Tool definition |
args | Partial<I> | no | Preset arguments |
| Field | Type | Required | Description |
|---|
kind | 'branch' | yes | Discriminant |
id | string | yes | Step identifier |
route | (input: I, ctx: Context) => Step<I, O> | null | yes | Routing function (null skips) |
Fork has three mode variants, each a separate interface.
| Field | Type | Required | Description |
|---|
kind | 'fork' | yes | Discriminant |
id | string | yes | Step identifier |
mode | 'race' | yes | First completion wins |
paths | (input: I, ctx: Context) => Step<I, O>[] | yes | Path factory |
concurrency | number | no | Max parallel paths |
| Field | Type | Required | Description |
|---|
kind | 'fork' | yes | Discriminant |
id | string | yes | Step identifier |
mode | 'all' | yes | Wait for all paths |
paths | (input: I, ctx: Context) => Step<I, O>[] | yes | Path factory |
merge | (results: O[], ctx: Context) => O | yes | Merge function |
concurrency | number | no | Max parallel paths |
| Field | Type | Required | Description |
|---|
kind | 'fork' | yes | Discriminant |
id | string | yes | Step identifier |
mode | 'settle' | yes | Wait for all, include errors |
paths | (input: I, ctx: Context) => Step<I, O>[] | yes | Path factory |
merge | (results: SettleResult<O>[], ctx: Context) => O | yes | Merge function |
concurrency | number | no | Max parallel paths |
| Field | Type | Required | Description |
|---|
kind | 'spawn' | yes | Discriminant |
id | string | yes | Step identifier |
child | Step<I, O> | yes | Child step to execute |
memory | MemoryLayer[] | no | Spawn-local memory layers |
timeout | number | no | Timeout in milliseconds |
| Field | Type | Required | Description |
|---|
kind | 'loop' | yes | Discriminant |
id | string | yes | Step identifier |
body | Step<I, O> | yes | Loop body step |
until | Until | yes | Termination predicate |
maxIterations | number | no | Safety limit on iterations |
maxHistorySize | number | no | Max history items to retain |
inbox | Channel<string> | no | Channel for external messages that prevent loop from stopping |
parkTimeout | number | no | Milliseconds to wait on inbox before stopping (0 = non-blocking) |
prepareNext | (output: O, verdict: Verdict, ctx: Context) => I | no | Transform output to next input |
onError | (error: NoeticError, ctx: Context) => 'retry' | 'skip' | 'abort' | no | Error handler |
| Field | Type | Description |
|---|
stepId | string | Step that produced this result |
status | 'fulfilled' | 'rejected' | Outcome |
value | O | Present if fulfilled |
error | NoeticError | Present if rejected |
| Field | Type | Description |
|---|
maxAttempts | number | Maximum retry attempts |
backoff | 'fixed' | 'linear' | 'exponential' | Backoff strategy |
initialDelay | number | Initial delay in milliseconds |
maxDelay | number | Maximum delay cap (optional) |
| Field | Type | Description |
|---|
temperature | number | Sampling temperature (optional) |
topP | number | Nucleus sampling (optional) |
maxTokens | number | Max response tokens (optional) |
stopSequences | string[] | Stop sequences (optional) |
| Field | Type | Description |
|---|
name | string | Tool name |
description | string | Tool description for the LLM |
input | ZodType | Input schema |
output | ZodType | Output schema |
execute | (args: I, ctx: Context) => Promise<O> | Execution function |
needsApproval | boolean | Whether the tool requires human approval (optional) |
type ExecuteStepFn = <I, O>(step: Step<I, O>, input: I, ctx: Context) => Promise<O>;