NylorunDocsBeta
Get startedBuildRunDeployReferenceMore

Step

Run agents, tools and flows in order, and reshape data between them.

.step() runs one agent, tool, flow agent or flow(). Steps run in order, and each step receives the previous step's output unless its input function computes something else.

import { Agent } from "@nylorun/agents";

export const report = Agent({ id: "report" })
  .step(researcher)
  .step(analyst, {
    input: ({ results }) => `Summarize: ${results.researcher.findings}`,
  })
  .step(publish, {
    input: ({ input }) => ({ summary: input.summary }),
  });

Values and results

  • input is what this step would receive: the previous step's output.
  • results holds earlier steps' outputs in this sequence, keyed by step id.
  • flowInput is the flow agent's own input.

A step's id is the agent's id or the tool's name. Set id when the same agent appears more than once, or when you want a stable result key:

.step(writer)
.step(editor)
.step(writer, { id: "final-writer", input: ({ results }) => results.editor })

The step with its own id runs in its own session (final-writer), with the same definition. Where there is no options object, .withId("final-writer") does the same.

A flow agent's output is its last stage's output. Runtime checkpoints every stage, so a resumed flow does not repeat completed work.

See the shipped chain example, then learn how to route with Switch.

On this page