Chain
Run workflow steps in order and reshape data between them.
Chain runs a non-empty list of agents, tools, or nested workflows in order.
Each step receives the preceding step's output unless a slot supplies an
input function.
import { Chain } from "@nylorun/agents/define";
export const report = Chain({
id: "report",
steps: [
researcher,
{
run: analyst,
input: ({ results }) =>
`Summarize: ${results.researcher.findings}`,
},
{
run: publish,
input: ({ value }) => ({ summary: value.summary }),
},
],
});Values and results
valueis the immediately preceding step's output.resultscontains earlier outputs keyed by step id.inputis the original workflow input.
A direct step keeps its runnable id. Set id on a slot when the same runnable
appears more than once or when you want a stable result key:
{
id: "final-review",
run: reviewer,
input: ({ value, input, results }) => ({ value, input, results }),
}The chain output is the final step's output. Step ids must be unique among siblings. Runtime checkpoints every node boundary, so a resumed chain does not repeat completed effects.
See the shipped chain example,
then learn how to route with Switch.