6 Action: How your agent acts is where strategy meets consequences
This chapter explains that an agent’s action is not the tool call itself, but a bounded, verifiable change in the external world. A successful execution signal, a green test, or a “done” message may show that a function ran, but they do not prove the intended business effect occurred. The chapter uses examples like mapping, payroll, code repair, and deployment to show why state-changing work needs richer evidence, such as receipts, version checks, and task-specific acceptance signals, especially when prompt injection, stale state, or duplicate execution can quietly distort outcomes.
To close the gap between intent and accepted effect, the chapter introduces an action contract: the system should define the intended effect, execution boundary, current state basis, execution rule, commit identity, and acceptance evidence. It then presents four patterns for controlling action. Prompt Chaining breaks a known workflow into checked stages with named artifacts and gates. Tool Dispatch narrows a large capability catalog to an eligible set before the model selects a tool and the runtime admits it. Plan-and-Execute preserves dependencies, partial progress, and recovery state across interruptions. The Guardrail Sandwich surrounds risky effects with trusted pre-checks and post-checks so the agent cannot declare its own work complete.
Across all four patterns, the central design principle is the same: the system must verify the real effect, not just the story the model tells about it. The chapter shows how to build these controls in code, how to keep retries from repeating the same blind spot, and how to prevent unsafe fallbacks or hidden bypass paths. It also shows that the patterns compose around the task’s actual failure terrain rather than as a fixed stack, and it closes by testing the boundary with failure injections so teams can measure whether the action layer truly contains risk, preserves evidence, and supports safe recovery.
An Action crosses from a proposal to an external effect. Tool status is execution evidence; task-specific acceptance evidence determines whether the effect is complete.
Prompt Chaining moves named artifacts through a fixed sequence. A failed gate returns evidence to the producing stage or stops the chain; it does not contaminate the next stage.
Tool Dispatch narrows the catalog to an eligible surface before model selection. Runtime admission then checks the selected call against current authority, parameter provenance, and state freshness.
Plan-and-Execute persists a versioned goal, dependency graph, step state, attempts, and evidence. Recovery verifies uncertain effects and changes only the pending affected subgraph.
The Guardrail Sandwich is sequential in time but hierarchical in trust. Protected preconditions and independent postconditions surround a lower-trust execution boundary.
A cross-repository schema change composes Action patterns at different seams: the plan holds dependencies, chains verify local artifacts, dispatch narrows each capability surface, and guardrails surround publication effects.
Summary
- Action is a bounded and verifiable change in the external world, not the presence of a tool call or a green process status.
- An action contract connects the intended effect, execution boundary, state basis, commit identity, and task-specific acceptance evidence.
- Prompt Chaining protects a known sequence by passing named artifacts through intermediate gates. More prompts without checked seams add cost, not control.
- Tool Dispatch computes an eligible capability surface before model selection, then rechecks the exact call's authority, provenance, and freshness. Discovery and schema conformance do not grant permission or prove facts.
- Plan-and-Execute is justified when interruption makes a restart unsafe. It persists dependencies, partial progress, uncertain effects, and evidence; local replanning must not rewrite accepted work or the shared goal.
- The Guardrail Sandwich places lower-trust execution between protected preconditions and independent postconditions. Containment limits reach, but only task-specific evidence can accept the effect.
- Compose patterns at the seams exposed by the task's failure terrain. A chain, dispatcher, plan, and guardrail are choices, not four mandatory layers.
Designing AI Agents ebook for free