chapter six

6 Action: How your agent acts is where strategy meets consequences

 

This chapter covers

  • Diagnosing the action gap between agent decisions and real-world execution
  • Composing multi-step workflows with Prompt Chaining and Unix-pipe-style gates
  • Building a Tool Dispatch capability bus that scales via MCP and semantic routing
  • Separating strategy from tactics with Plan-and-Execute and the Planner-Worker split
  • Preventing irreversible damage through the Guardrail Sandwich safety hierarchy
"Do one thing and do it well."

— Doug McIlroy, Unix philosophy

The agent was perfect. It diagnosed the memory leak in twelve seconds: a connection pool that grew without bound because the close() call was inside a try block that caught and swallowed the TimeoutError. The reasoning trace was flawless. Then it applied the fix.

It moved the close() call to a finally block, which was correct. But it also "cleaned up" the file while it was there—removing an import it judged unused, renaming a variable it found misleading, and reformatting a docstring. The linter ran green. The type checker passed. Then the integration tests exploded: the "unused" import was loaded at runtime by a plugin framework, the "misleading" variable was referenced by name in a YAML configuration file, and the "reformatted" docstring broke a documentation generator that parsed it with regex.

6.1 What is action? Bridging the gap between deciding and doing

6.1.1 The action gap

6.1.2 Three levels of action complexity

6.1.3 The agentic loop as system design paradigm

6.1.4 The action patterns at a glance

6.1.5 Testing and observing action

6.2 Pattern: Prompt Chaining

6.2.1 The Unix pipe for LLM steps

6.2.2 Building it

6.2.3 In production: Claude Code's implicit prompt chains

6.2.4 When it breaks

6.3 Pattern: Tool dispatch

6.3.1 The capability bus

6.3.2 Building it

6.3.3 The MCP integration pattern

6.3.4 In Production: Claude Code's tool architecture

6.3.5 When it breaks

6.4 Pattern: Plan-and-Execute

6.4.1 Separating strategy from tactics

6.4.2 Building it

6.4.3 In Production: How coding agents plan

6.4.4 When it breaks

6.5 Pattern: Guardrail Sandwich

6.5.1 Three layers of safety

6.5.2 Building it

6.5.3 In Production: Claude Code's permission model

6.5.4 When it breaks