liveBook · Manning

NextStepDecision

As explained in Build a Multi-Agent System (from Scratch)

NextStepDecision is a framework data structure whose kind and content represent either the instruction for the next sub-step or the overall task result.

NextStepDecision is a structured data object used by an agent’s task handler to choose how processing continues. It represents either an instruction for another sub-step or the result of the completed task. section 4.2.1

In the task-processing flow:

  • The handler uses the previous sub-step result and the execution history to request a NextStepDecision from the backbone LLM. section 4.2.3
  • The decision’s kind determines whether the handler returns a new TaskStep or the final TaskResult. section 4.2.1 section 4.2.3

Implement NextStepDecision as a Pydantic BaseModel for use as structured output inside TaskHandler.get_next_step(). section 4.2.2

A one-step Hailstone task

An agent calls a Hailstone tool with 5, receives 16, and reports that the task is complete. In the processing flow, the decision can represent the overall result rather than another step instruction. section 4.2.3 section 4.2.1

Figure 4.8 UML class diagrams for TaskStep, TaskStepResult, NextStepDecision, and TaskHandler

The class diagram places NextStepDecision alongside the task-step and task-handler types that use it. section 4.2.2

How Build a Multi-Agent System (from Scratch) covers it

How deep it goes
Defines a Pydantic model and traces its structured-output use through the handler, without detailing the full model schema.
Examples
Uses an agent’s Hailstone sequence task, tool call, and single-step completion as a processing example.
What you can do after
Build it from scratch as a Pydantic model and use it to select a next step or final task result.
How it connects
Connects TaskStep and TaskResult through TaskHandler.get_next_step() and structured output.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Multi-Agent System (from Scratch). The section links point to the parts of the book it draws on.