Chapter 3: Errand: Breaking complex workflows into units
This introduction frames Errand as a pattern for decomposing complex agent workflows into small intelligent pipelines that control context, improve maintainability, and enable parallel execution.
After this chapter you will be able to
- Workflow decomposition with errands. Explain how the Errand pattern separates complexity from a larger agent into small, intelligent subroutines or pipelines that can be called as tools or placed in preset processes. Describe an errand as distinct from an ordinary code routine because its AI-driven execution is less predictable and more costly.
- Context and complexity limits. Describe why a single reason-and-act loop handling a large investigation can fail: its accumulated files and contents can exceed a model's effective context window, its instructions become complex and distraction-prone, and sequential processing becomes too slow. Relate these limits to the need to split work into smaller units.
- Model limitations and decomposition. Explain why serious agent design cannot simply give a model a broad task and let it solve everything autonomously. Describe how limits in perceptive-window size, reasoning, tool selection, and safe experimentation motivate decomposition into simpler, more manageable pieces.
- Errands in component hierarchies. Describe the hierarchy created when an agent is decomposed into flow-controlling and action-performing components. State that flow-controlling components choose or delegate to other components, while errands are leaf action-performing routines with unidirectional information flow and no direct effect on agent state.
- Errand workflow structure. Describe an errand as a grouping of one or a few intelligent entities (IEs) and procedures arranged sequentially or as parallel work followed by sequential processing. Explain that early IE calls usually perform the main intelligent operation, while later steps reconcile results and prepare the final output.
- Errand design characteristics. Explain the defining characteristics of errands: unifunctionality, unidirectionality, discarding of intermediate results, functional purity, and simplicity. State that these traits make an errand a narrow, independent, maintainable component with a largely predictable runtime.
- Benefits of errand decomposition. Explain how decomposing agentic logic into separate, unifunctional errands improves capability, robustness, and reliability. Describe how focused errands let models handle separate tasks, support adding functionality through new errands, and operate within their perceptive windows without disregarding much context.
- Context repetition overhead. Describe the main cost of decomposing one agentic workflow into separate errands: shared context must be repeated across the model calls made by different errands. State that this repeated context creates added overhead and can increase cost.
- Errand as intelligent subroutine. Explain that an Errand abstracts an independent intelligent operation away from the larger process or agentic workflow in which it appears. Describe errands as common building blocks in enterprise agentic systems and AI-powered software.
- Common Errand applications. Describe the four typical Errand uses: formatting, classification and tagging, assessment and judging, and information extraction. State that these uses can combine model calls with code to enforce output guidelines, assign categories, produce pass/fail verdicts, or pull needed information from rich inputs.
- Persona errand structure. Describe how a persona errand uses an IE with a prespecified system instruction and accepts the user or task instruction as its payload. Explain that the system instruction establishes the errand’s agentic characterization, including its goals, style, approach, and usually how completion is marked.
- Persona errand tradeoffs. Explain why persona errands are useful when the exact task is unknown at design time but desired outcomes, guidelines, or available atomic functionality are known. Distinguish their increased robustness for user requests from their reduced workflow control and prompt-injection safety and security risk.
- Reflection errand purpose. Explain that a reflection errand asks a model to review an earlier intelligent element’s task assignment and transcript or result, rather than perform the original operation. Describe how this added review helps reduce errors or hallucinations in autonomous workflows whose later steps depend on earlier model outputs.
- Reflection outcome integration. Describe the possible outputs of a reflection errand: a pass/fail decision, feedback for a correction or next attempt, or a confidence score that travels with the result. Explain that the reflection must be connected back into the workflow, either directly into the original operation’s conversation or through patterns such as Resampler, Voter, or Refiner that decide the next action.
- Effective perceptive window limits. Explain what an effective perceptive window is and why exceeding it harms an information element’s ability to operate well. Describe how oversized inputs or accumulated interaction and refinement history can exceed the window needed for later workflow operations.
- Compaction errand transformation. Describe a compaction errand as an errand that takes near-limit information and returns a filtered, summarized, or distilled version suitable for future operations. Give the section's examples of relevant-image or video-frame filtering for vision and summarization or context embedding for language models.
- Compaction timing and codesign. Explain why compaction normally occurs just before the perceptive-window limit is reached and why downstream agent components may need to be codesigned for compacted results. Describe how a reason-and-act agent expecting detailed history can be confused if it instead receives only a summary and its most recent action.
- Structured extraction errand. Describe a structured extraction errand as an errand that asks a compatible AI model or endpoint to convert unstructured information into structured output.
- Controlled generation constraints. Explain how controlled generation constrains a model's output to a formal grammar or higher-level formatting specification, so downstream code can parse the result reliably.
- Drafting and editing separation. Explain why editing errands are kept separate from agentic drafting, including requirement disentanglement and more efficient processing.
- Chainable attribute edits. Describe how decorator-style editing errands can be reused independently or chained into a pipeline, with each errand typically targeting one cleanly disentangled attribute of candidate output.
- Speaker stance errand flow. Describe the speaker stance identification errand as a sequence that selects transcript passages from the named speaker, sends them through a model call, uses a second reasoning-enhanced model call to classify stance, and extracts the resulting classification label.
- Call summarization errand flow. Describe the call summarization errand as a multimodal workflow: a call recording is transcribed, the transcript is summarized by an LM, and the summary is extracted as the final output.
What it builds on
- The report-writing errand (chapter 2) · The earlier report-writing errand provides an example of an errand within an agent workflow.
- Runtime and orchestration (chapter 2) · The idea that agent systems have runtime and orchestration components.
- Agent Flow Diagrams (chapter 2) · The use of agent-flow components and their connections in an Agent Flow Diagram.
Section by section
Introduction
This introduction frames Errand as a pattern for decomposing complex agent workflows into small intelligent pipelines that control context, improve maintainability, and enable parallel execution.
- Workflow decomposition with errands: Explain how the Errand pattern separates complexity from a larger agent into small, intelligent subroutines or pipelines that can be called as tools or placed in preset processes. Describe an errand as distinct from an ordinary code routine because its AI-driven execution is less predictable and more costly.
Why it matters: Errands provide a reusable way to give an agent focused capabilities without putting every responsibility into one workflow. - Context and complexity limits: Describe why a single reason-and-act loop handling a large investigation can fail: its accumulated files and contents can exceed a model's effective context window, its instructions become complex and distraction-prone, and sequential processing becomes too slow. Relate these limits to the need to split work into smaller units.
Why it matters: Recognizing these failure modes helps you identify when one monolithic agent workflow should be decomposed. - Narrow parallel file pipelines: Describe the introductory file-investigation example as separate, start-to-finish pipelines for individual file actions: load one file, invoke a model to extract relevant information, invoke it again to assess relevance to the missing-person search, and retain only relevant output. Explain that independent errands can run in parallel and be dispatched by an orchestrator or called by a reason-and-act loop.
Why it matters: The example shows how focused errands reduce per-task context while making independent work faster and easier to fix.
Key terms: Errand pattern, errands, intelligent subroutine, preset processes, reason-and-act loop, effective perceptive window, maximum context length, hallucinate, linear pipeline, parallelization
3.1 The pain point: Limits on context length
This section explains why agent tasks must be decomposed into a hierarchy of controllable components and defines errands as the leaf routines in that hierarchy.
- Model limitations and decomposition: Explain why serious agent design cannot simply give a model a broad task and let it solve everything autonomously. Describe how limits in perceptive-window size, reasoning, tool selection, and safe experimentation motivate decomposition into simpler, more manageable pieces.
Why it matters: Breaking work into manageable pieces gives developers more control over model behavior. - Errands in component hierarchies: Describe the hierarchy created when an agent is decomposed into flow-controlling and action-performing components. State that flow-controlling components choose or delegate to other components, while errands are leaf action-performing routines with unidirectional information flow and no direct effect on agent state.
Why it matters: This distinction identifies the bounded role an errand plays inside a larger agent workflow.
Key terms: perceptive window, decomposition, target task, flow-controlling components, action-performing components, hierarchy of components, leaf, errands, unidirectional information flow
3.2 How the Errand pattern works
This section defines the Errand pattern as a small, self-contained workflow that combines intelligent entities and procedures to perform one narrow task and return only a final result.
- Errand workflow structure: Describe an errand as a grouping of one or a few intelligent entities (IEs) and procedures arranged sequentially or as parallel work followed by sequential processing. Explain that early IE calls usually perform the main intelligent operation, while later steps reconcile results and prepare the final output.
Why it matters: Recognizing this flow helps you break a larger agent workflow into understandable, independently usable components. - Errand design characteristics: Explain the defining characteristics of errands: unifunctionality, unidirectionality, discarding of intermediate results, functional purity, and simplicity. State that these traits make an errand a narrow, independent, maintainable component with a largely predictable runtime.
Why it matters: These constraints are what keep errands from becoming another complex, stateful agent workflow. - Language-model result extraction: Describe the typical language-model errand interaction: an LM or VLM IE is prompted to reason and then output an answer, and a procedure can extract the final result from a designated output region with a regular expression. State that result delimiters may include tags such as <result>...</result> or \boxed{...}, and the preferred encapsulation should be checked in the model's release details.
Why it matters: Reliable extraction lets a later procedure use the model's intended final answer instead of treating all generated text as the result. - Parallel vision information fusion: Describe how a computer-vision errand can run specialized vision IEs in parallel to extract different details, then use a deterministic procedure to combine them into structured information, an aggregate object, or a language-model narrative. Use the example of segmentation or object detection combined with depth perception and distance estimation.
Why it matters: This shows that Errand is not limited to text models and can coordinate complementary perception components. - Generic Errand implementation: Describe the sketch of a generic Errand class: it invokes multiple IEs to gather intermediate results about an input, then passes those intermediates to a procedure that produces the final output. Relate this implementation process to writing a new function in code.
Why it matters: The implementation sketch turns the pattern from a design idea into a reusable component structure.
Key terms: Errand, intelligent entity, IE, procedure, parallel-then-sequential arrangement, unifunctionality, unidirectionality, discarding of intermediate results, functional purity, side effects
3.2.1 Tradeoffs
This subsection weighs Errand decomposition’s gains in capability, robustness, and reliability against its added context-sharing cost, including caching as a mitigation.
- Benefits of errand decomposition: Explain how decomposing agentic logic into separate, unifunctional errands improves capability, robustness, and reliability. Describe how focused errands let models handle separate tasks, support adding functionality through new errands, and operate within their perceptive windows without disregarding much context.
Why it matters: These benefits explain why breaking a workflow into errands can produce more capable and dependable agents. - Context repetition overhead: Describe the main cost of decomposing one agentic workflow into separate errands: shared context must be repeated across the model calls made by different errands. State that this repeated context creates added overhead and can increase cost.
Why it matters: The context cost is the key tradeoff to evaluate before turning a single workflow into many errands. - Input caching mitigation: Describe how model input caching can reduce or eliminate the overhead of repeated shared context. Explain the language-model example in which a prompt is divided into instructions and payload, with the instructions precomputed and cached through a model provider interface.
Why it matters: Caching lets an Errand design retain focused steps while reducing the cost of repeated prompt content.
Key terms: decomposition, agentic logic, errands, unifunctional focus, perceptive windows, capability, overhead, shared context, model calls, decomposing
3.2.2 When and where to use Errand
This section positions Errand as an intelligent subroutine and identifies common enterprise uses for it in AI-powered workflows.
- Errand as intelligent subroutine: Explain that an Errand abstracts an independent intelligent operation away from the larger process or agentic workflow in which it appears. Describe errands as common building blocks in enterprise agentic systems and AI-powered software.
Why it matters: Seeing an errand as a self-contained intelligent subroutine helps you isolate a focused operation from the workflow that uses it. - Common Errand applications: Describe the four typical Errand uses: formatting, classification and tagging, assessment and judging, and information extraction. State that these uses can combine model calls with code to enforce output guidelines, assign categories, produce pass/fail verdicts, or pull needed information from rich inputs.
Why it matters: These application types help you recognize when a focused model-and-code operation should be factored out as an Errand. - Examples of Errand deployment: State examples of where the common Errand uses apply, such as structuring free-form text, sentiment analysis or document annotation, checking report inclusion or professional tone, and filling forms or extracting a final mathematical answer from a reasoning trace.
Why it matters: Concrete examples make it easier to spot Errand opportunities in real AI products.
Key terms: Errand pattern, independent intelligent operation, intelligent subroutines, agentic workflow, formatting, classification and tagging, assessment and judging, information extraction, controlled generation, binary pass/fail verdict
3.3 Errand pattern variants
3.3.1 Persona errands
This subsection presents persona errands, which use a fixed system instruction to guide an errand whose specific task arrives later as payload.
- Persona errand structure: Describe how a persona errand uses an IE with a prespecified system instruction and accepts the user or task instruction as its payload. Explain that the system instruction establishes the errand’s agentic characterization, including its goals, style, approach, and usually how completion is marked.
Why it matters: This structure lets an errand handle tasks supplied at runtime while keeping its intended behavior consistent. - Persona errand tradeoffs: Explain why persona errands are useful when the exact task is unknown at design time but desired outcomes, guidelines, or available atomic functionality are known. Distinguish their increased robustness for user requests from their reduced workflow control and prompt-injection safety and security risk.
Why it matters: Choosing this variant means balancing flexible, robust task handling against the control and security risks of allowing later instructions.
Key terms: persona errand, IE, system instruction, payload, agentic characterization, post-training, developer instructions, prompt injection, workflow control, safety and security
3.3.2 Reflection errands
Reflection errands have a model review an earlier intelligent element’s task and result so the workflow can detect or correct hallucinations instead of accepting outputs unchecked.
- Reflection errand purpose: Explain that a reflection errand asks a model to review an earlier intelligent element’s task assignment and transcript or result, rather than perform the original operation. Describe how this added review helps reduce errors or hallucinations in autonomous workflows whose later steps depend on earlier model outputs.
Why it matters: Reflection provides a deliberate check before an unreliable model result can influence the rest of an agent workflow. - Reflection outcome integration: Describe the possible outputs of a reflection errand: a pass/fail decision, feedback for a correction or next attempt, or a confidence score that travels with the result. Explain that the reflection must be connected back into the workflow, either directly into the original operation’s conversation or through patterns such as Resampler, Voter, or Refiner that decide the next action.
Why it matters: A review only improves agent quality when its verdict or feedback actually changes how the workflow proceeds.
Key terms: reflection errand, intelligent element, hallucinate, agency, pass/fail, feedback, confidence score, Resampler, Voter, Refiner
3.3.3 Compaction errands
Compaction errands keep an agent operating within an information element’s effective perceptive window by reducing near-limit information into a usable condensed representation.
- Effective perceptive window limits: Explain what an effective perceptive window is and why exceeding it harms an information element’s ability to operate well. Describe how oversized inputs or accumulated interaction and refinement history can exceed the window needed for later workflow operations.
Why it matters: An agent must manage information size before later model operations lose quality. - Compaction errand transformation: Describe a compaction errand as an errand that takes near-limit information and returns a filtered, summarized, or distilled version suitable for future operations. Give the section's examples of relevant-image or video-frame filtering for vision and summarization or context embedding for language models.
Why it matters: Compaction preserves the useful parts of growing context so the workflow can continue without overwhelming its next information element. - Compaction timing and codesign: Explain why compaction normally occurs just before the perceptive-window limit is reached and why downstream agent components may need to be codesigned for compacted results. Describe how a reason-and-act agent expecting detailed history can be confused if it instead receives only a summary and its most recent action.
Why it matters: A summary is only useful if the receiving agent is prepared to work from it before context overload degrades performance.
Key terms: effective perceptive window, information elements, IEs, context length, compaction errand, filtered, summarized, distilled, context embedding, codesigned
3.3.4 Structured extraction errands
This section introduces structured extraction errands, which use controlled generation to turn unstructured inputs into machine-parseable formats such as JSON while keeping that constrained task separate from general reasoning.
- Structured extraction errand: Describe a structured extraction errand as an errand that asks a compatible AI model or endpoint to convert unstructured information into structured output.
Why it matters: Structured extraction makes model output usable by software that expects a defined, parseable format. - Controlled generation constraints: Explain how controlled generation constrains a model's output to a formal grammar or higher-level formatting specification, so downstream code can parse the result reliably.
Why it matters: Strict output control addresses the last-mile failures that occur when stochastic model responses must satisfy a software interface. - Extraction-reasoning separation: Justify keeping structured extraction separate from other intelligent processing because controlled-generation constraints can be too restrictive for the unrestrained thinking or reasoning of generalist models.
Why it matters: Separating the constrained formatting step preserves a place for general model reasoning while producing output that meets strict interface requirements.
Key terms: structured extraction errand, unstructured information, structured output, compatible AI model, AI model endpoint, controlled generation, formal grammar, formatting specification, JSON/YAML/CSV grammars, JSON/XML schemas
3.3.5 Editing errands
This section explains editing errands as focused, reusable post-drafting steps that improve output through disentangled and chainable edits.
- Drafting and editing separation: Explain why editing errands are kept separate from agentic drafting, including requirement disentanglement and more efficient processing.
Why it matters: Separating production from revision gives an agent more precise control over quality and constraints. - Editing model efficiency: Describe why editing errands can use cheaper or less powerful models than drafting and may use model architectures specialized for editing, such as diffusion models.
Why it matters: Choosing a model suited to revision can lower cost and avoid regenerating an entire output. - Chainable attribute edits: Describe how decorator-style editing errands can be reused independently or chained into a pipeline, with each errand typically targeting one cleanly disentangled attribute of candidate output.
Why it matters: Small independent edits can be combined into a controlled pipeline without tying each component to one workflow.
Key terms: editing errands, agentic drafting, requirement disentanglement, processing efficiency, editing, autoregressive models, diffusion models, decorator-style chaining, candidate output, editing pipeline
3.4 Applying the Errand pattern: Use-case examples
This section introduces specialized Errand examples that extend common variants and supply multimodal information to an agent’s core logic.
- Specialized errand examples: Describe why the following examples focus on specialized errands beyond the common Errand types already discussed, and identify their relevance to real-world user-facing agents.
Why it matters: Specialized errands show how the pattern can address needs that common variants do not fully cover. - Multimodal information handoff: Explain that specialized errands may work across multiple modalities to provide an agent’s core logic with the information it needs to serve the user.
Why it matters: Errands can prepare needed information for the core agent logic even when that information comes in different modalities.
Key terms: errands, specialized errands, user-facing agents, multiple modalities, core logic, information
3.4.1 Speaker stance identification errand
This subsection illustrates an Errand that classifies a named speaker’s stance from a conversation transcript through staged model calls and label extraction.
- Speaker stance errand flow: Describe the speaker stance identification errand as a sequence that selects transcript passages from the named speaker, sends them through a model call, uses a second reasoning-enhanced model call to classify stance, and extracts the resulting classification label.
Why it matters: This example shows how an Errand breaks stance classification into focused, manageable workflow units.
Key terms: speaker stance identification errand, stance classification, transcript, classification label, AFD
3.4.2 Call summarization errand
This subsection illustrates a multimodal Errand that transcribes a voice call, summarizes its transcript, and procedurally extracts the summary from the model's reasoning trace.
- Call summarization errand flow: Describe the call summarization errand as a multimodal workflow: a call recording is transcribed, the transcript is summarized by an LM, and the summary is extracted as the final output.
Why it matters: This shows how an Errand can divide a multimodal task into clear processing units with a usable final result.
Key terms: multimodal errand, voice call summarization, speech-to-text model, LM, procedural extraction, summarization reasoning trace
3.5 Summary
This summary defines the Errand pattern as a small, one-way intelligent subroutine and recaps how its modular properties make complex agent workflows more reliable and maintainable.
Where this is used later
- How the Guardrail pattern works (chapter 4) · The assessment example uses an Errand as the assessment IE.
- How the Resampler pattern works (chapter 5) · Resampler can use a reflection outcome when deciding whether and how to make another attempt.
- When and where to use Resampler (chapter 5) · Reflection errands as a related way to iteratively improve or analyze work.
- When and where to use DPR (chapter 8) · Compaction errands, which can help construct global context.
Concepts explained in this chapter
- ErrandErrand is an agent design pattern that groups one or a few intelligent elements and procedures into a simple sequential or parallel-then-sequential operation with a final output.
- decompositionThe division of a complex task or workflow into smaller, focused units.
- context windowA context window is the maximum amount of input information a language model can consider in a single invocation.
- intelligent elementAn agent component that uses AI to assess information or perform a focused function.
- model-to-code interfaceA code–AI interface is a boundary where program code exchanges model outputs that must conform to machine-readable expectations.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
