An agent that reads many files, reasons over every finding, and decides what to inspect next can overwhelm a model’s usable context. Decompose that workflow instead: let orchestration choose the next action, and give narrow, independently testable operations to errands. section 3.0 section 3.1
An errand is an intelligent subroutine with one defined job. It groups one or a few intelligent elements with procedures in a sequential or parallel-then-sequential flow. Early elements do the intelligent work; later elements reconcile or extract a final result. The errand returns that result without directly changing the agent’s broader state. section 3.2 section 3.1
Keep the boundary narrow:
- Give each errand one function or a narrow class of functions. Process inputs forward toward an output rather than running an open-ended reasoning loop. section 3.2
- Return the final output, not the intermediate reasoning or extracted data. This keeps the agent’s working context smaller. section 3.2
- Avoid direct side effects on agent state. Small, independent operations are easier to test, maintain, and run in parallel. section 3.2 section 3.0
- Budget for repeated context across model calls. Separating tasks can improve reliability, but it can increase cost; caching shared prompt instructions may reduce that overhead. section 3.2.1
Listing 3.1 errand.py: Sketch implementation of a generic Errand class.
import asyncio
from typing import Any
from utils import IE, E, Client, LMCall, FunctionCall
import re
import json
class Errand(IE[[str], str]):
def __init__(
self,
intelligent_elements: list[IE[[str], Any]],
procedure: E[[list[Any]], str],
):
self.intelligent_elements = intelligent_elements
self.procedure = procedure
async def __call__(self, input: str) -> str:
ie_tasks = [
ie(input) for ie in self.intelligent_elements
]
ie_results: list[Any] = await asyncio.gather(
*ie_tasks
)
procedure_result: str = await self.procedure(
ie_results
)
return procedure_result
The generic implementation runs intelligent elements concurrently on the input, gathers their results, passes them to a procedure, and returns only the procedure’s output. section 3.2
Classify a speaker’s stance
Given a conversation transcript and a speaker’s name, one model call extracts that speaker’s passages. Another classifies the stance; a procedure finds and returns the label. The passages and classification reasoning remain intermediate results. section 3.4.1
Use errands for formatting, tagging, pass/fail assessment, or information extraction. A report-writing errand, for example, takes analysts’ results and earlier feedback, then prompts a model to produce a report. Its simple control flow does not guarantee good writing: prompt and model choice still matter. Errands do not call tools or contain iterative reasoning loops; leave those responsibilities to other parts of the agent. section 3.2.2 section 2.5
