Overview

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.
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.
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.
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.
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.
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.
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.

FAQ

What is the main idea of “action” in an AI agent?Action is the point where reasoning becomes an interaction with the external world. A tool call is only the mechanism; true action is the bounded, verifiable effect that happens outside the model.
Why isn’t a successful tool call the same as task completion?A tool call can succeed technically while the real task still fails. For example, a payment API may return success, but the payment could still be duplicated, stale, or unverified. Completion requires task-specific acceptance evidence.
What is the “action gap”?The action gap is the distance between what the model proposes and what is actually accepted as complete. It includes risks like wrong tools, stale state, repeated side effects, and confusing a narrow return value with true business success.
What information should an action contract include?An action contract should include the intended effect, execution boundary, state basis, execution rule, commit identity, and acceptance evidence. These fields help connect a proposal to the effect it is allowed to make.
When should Prompt Chaining be used?Use Prompt Chaining when the workflow has a stable order and each stage can produce a narrow artifact that must pass a gate before the next stage begins. It works best for fixed sequences with clear intermediate checks.
What is the purpose of an intermediate gate in Prompt Chaining?An intermediate gate checks whether the artifact from one stage is valid enough for the next stage to use. It can verify structure, provenance, facts, and acceptance, and it prevents bad artifacts from propagating downstream.
When is Tool Dispatch the right pattern?Tool Dispatch is the right pattern when an agent has many possible capabilities or sensitive parameters and the runtime needs to narrow the eligible set before selection. It separates discovery, eligibility, selection, admission, and execution.
Why does Plan-and-Execute need persistent state?Plan-and-Execute needs persistent state because long-running work may pause, branch, fail, or resume later. The plan must remember dependencies, partial progress, attempts, and acceptance evidence so recovery can happen safely.
What makes the Guardrail Sandwich different from ordinary execution?The Guardrail Sandwich wraps execution with trusted pre-checks and post-checks. The pre-check decides whether the action may start, the runner executes under constraints, and the post-check verifies the real external effect using authoritative evidence.
How should the four Action patterns be combined?They should be combined based on the task’s terrain, not as a fixed stack. A workflow may use Plan-and-Execute for durable coordination, Prompt Chaining for local stages, Tool Dispatch for safe capability routing, and a Guardrail Sandwich around risky effects.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Designing AI Agents Designing AI Agents ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Designing AI Agents Designing AI Agents ebook for free