Skip to chapter
Peanut learns to agentRead with page turns →

Chapter 05 of 12 · Aishwarya Ashok

Planning and collaboration

Peanut plans the work and calls for help

Break the job into useful steps, inspect what happened, and decide when to stop. Extra agents can take on bounded work when their contribution justifies the coordination.

Task decomposition

Breaking a larger task into smaller pieces that can be assigned, executed, and checked.

Peanut cuts a host-dinner ticket into smaller tickets for shopping, cooking, and setting the table.
“Host dinner” becomes three jobs someone can begin.Peanut is the agent breaking a goal into subtasks. The tickets keep each smaller job connected to the dinner it is meant to produce.

For a dinner, shopping produces what cooking needs, while setting the table can happen independently. Decomposition exposes those smaller jobs and their dependencies.

Give each subtask a useful output and keep its relationship to the larger goal visible. Otherwise, an agent can complete every item on its list and still leave part of the actual job undone.

Planning

Choosing actions and their dependencies to work toward a goal under stated constraints.

Peanut stands on a stream bank, sketching a proposed route across stepping stones before starting the crossing.
A route is useful before stepping into the stream.Peanut is the agent planning its next work. The sketched route is a proposal that can change when the crossing reveals new information.

A code-change plan might identify the files to inspect, the edit to make, and the checks to run. It provides a starting sequence that can be revised when investigation reveals something new. Plan enough to guide the next work, with room to respond to what the tools find.

ReAct

An approach that interleaves model reasoning, actions, and observations while solving a task.

Peanut tests a dark lamp’s bulb, observes that the bulb works in a tester, then checks the lamp’s unplugged power cable.
The bulb works. Check the plug next.Peanut is the agent. The successful bulb test supplies an observation that changes what it checks next.

ReAct interleaves reasoning, action, and observation. An action gathers information that helps the model decide what to try next, instead of planning every move without feedback. The original method explicitly combines reasoning text with actions. It is one approach to structuring an agent, rather than a label for every system that uses a loop.

Source & further reading

Technical reference: ReAct paper ↗

Plan-and-execute

An agent pattern that creates a plan and then executes its steps, with replanning when needed.

Peanut posts a shelf plan, discovers an uneven wall while measuring, and revises the mounting plan to include wedge spacers.
The wall is crooked. The plan needs a pencil mark.Peanut is carrying out a plan and reporting a surprise. The revised drawing represents the planning stage adjusting the remaining work.

Planning and execution can be separate stages. A planner proposes the work, an executor carries it out, and progress or problems feed back into revisions. Those stages may use different components or models. The practical question is how the executor reports a surprise and who is responsible for changing the remaining steps.

Reflection

A model-based review of an attempt or result used to guide a possible revision.

Peanut compares a leaning cake with a straight reference, marks the middle layer, then levels the cake and compares it again.
That middle layer explains the lean.Peanut is the agent reviewing its attempt. The marked layer is a specific critique; the final comparison checks whether the correction helped.

A model can review an attempt and propose a correction before trying again. Reflection is useful when the review identifies a specific problem the next attempt can address. Give it evidence such as a failed test or a mismatch with the requirement. The critique itself can be mistaken, so assess whether the revision actually improves the result.

Stopping condition

A rule or event that ends a run or a stage of execution.

Peanut sets down an orange polishing cloth beside a finished stool and completed agreed-work checklist, leaving optional polish untouched.
The checklist is complete. The mountain of optional polish remains.Peanut is the agent ending the run after the agreed checks pass. The unused polish represents work outside that stopping condition.

Define completion before the agent starts, and give the runtime clear limits on continued execution. A successful check, deadline, step limit, cancellation, or unrecoverable error can end a run. The final status should say which occurred. Reaching the time limit and completing the task are different outcomes that deserve different messages.

Multi-agent orchestration

Coordinating multiple agents, their responsibilities, and the information they exchange to complete work.

An orchestrator peanut sends a page to a drafter, a checker reviews that page, and the printer processes the checked version.
The draft, the check, and the print job need to meet in the right order.The print job depends on the draft and its check. The orchestrator represents the component coordinating those dependencies.

Multiple agents introduce a coordination problem as well as extra capacity. Someone must assign work, supply context, track dependencies, and combine the results. Separate agents can be useful when tasks benefit from distinct expertise or independent investigation. That benefit has to justify the communication overhead and the work of reconciling their outputs.

Supervisor agent

An agent that assigns, coordinates, or reviews work performed by other agents.

A supervisor peanut points out roof and gutter inspection areas, while two inspector peanuts return their checklists to a supervisor.
Two roof inspections return to one desk.The supervisor assigns bounded inspections and reviews their results. The role remains a model-driven participant whose judgments need evidence.

A supervisor agent decides what to assign and what to do with the responses. It can request more work, compare findings, or assemble a final result. Give it explicit review criteria and access to the relevant evidence. The supervisor is another model-driven participant, so the title alone adds no assurance that its judgment is sound.

Subagent

An agent invoked to handle a bounded part of another agent's larger task.

One peanut checks a cart wheel against a wheel-inspection card while another works on a separate wheel at the larger repair bench.
The assignment is the wheels. The whole cart belongs to a larger job.The wheel assignment is one bounded part of the broader cart repair; the caller integrates its result.

A subagent takes responsibility for a bounded part of another agent's task. It may receive specialized instructions, tools, or its own context. Specify what information travels with the assignment and what should come back. The parent can then evaluate the result and use it in the broader workflow.

Delegation

Assigning a task to another agent or worker with the context, constraints, and expected output needed to perform it.

Peanut hands a helper an orange folder containing a task sheet, stool drawing, and matching measurements.
Hand over the measurements with the job.The assignment travels with the measurements and expected result, so the recipient can act without guessing the missing context.

“Inspect this” leaves quite a lot for the recipient to guess. A useful delegation includes the goal, relevant context, constraints, and expected output. It also identifies what counts as finished. The caller remains responsible for integrating the returned work, including resolving gaps or contradictions with other parts of the task.

Handoff

Transferring control or responsibility to another participant, along with the context needed to continue.

An outgoing peanut passes a notebook and points to an unfinished bridge joint; the incoming peanut reads the notebook and works at that joint.
The next shift needs to know about that unfinished joint.The notebook carries context while responsibility for continuing the work moves to the incoming participant.

A handoff transfers responsibility for continuing the work. In an agent application, it may move a conversation and selected state to a specialist. Decide what control transfers, what context is carried, and where any later response should go. Delegation usually returns a subtask result to a caller; a handoff emphasizes who takes over next.

Parallel execution

Executing multiple pieces of work concurrently where their dependencies permit it.

Three peanuts inspect separate parcels under a shared clock.
Three independent parcels, one stretch of the clock.The parcels stand for independent tasks that can overlap in time. Dependencies and shared resources can still require coordination.

Three independent searches can run during the same period instead of waiting in a queue behind one another. That may shorten the task, even when total resource usage stays the same or rises.

Dependencies decide what must wait. Shared files and records also need coordination so concurrent workers do not overwrite one another’s changes.