Chains and Steps are used to create multi-step prompts that can interact with the AI model in stages.
<step>
tag. The engine pauses after each step, waits for the model’s response, and adds it as an assistant message before continuing.
<step>
tag:
as
attribute. This allows you to reuse the response in later steps or logic blocks.
raw
attribute:
role
, content
, and other metadata provided by the model.
The content
attribute will always be defined as an array of content objects, which can include text, images, tool calls and any other types of content returned by the LLM.
isolated
attribute to prevent a step from inheriting context from previous steps. This can reduce unnecessary costs or confusion for the model.
maxSteps
attribute on the main configuration section. This can help prevent infinite loops or excessive processing in long chains when creating complex workflows with steps within loops.
Chain
class. The chain evaluates the prompt step-by-step, waiting for the model’s response at each step.
To run a step, execute the step
method of the chain instance. The first time step
is called, it should not include any arguments. Subsequent calls must always pass the model response message from the previous step.
raw
attribute to inspect full responses for debugging.