AI Agents
AI Agent Patterns
Runnable, measured demos for the AI agents articles: tool design, workflows versus agents, multi-agent systems, memory, planning, state and workflows, human-in-the-loop, and failure modes.
Runnable examples for the AI Agents articles on snehalagrawal.com: tools, agent loops, state, memory, planning, human-in-the-loop, and failure modes.
| Demo | Article | What it shows |
|---|---|---|
01-tool-design |
#23 Tools, Function Calling, and the Foundation of AI Agents | The same agent with three toolsets: how the shape of a tool changes what the model does next |
02-agentic-workflows |
#24 Agentic Workflows: When Should an LLM Control the Flow? | The same assistant as a fixed workflow, an agent, and a hybrid: who should decide the steps |
03-multi-agent |
#25 Single-Agent vs Multi-Agent Systems: What Does Another Agent Add? | The same assistant as one agent, a manager with two specialist agents, and an agent with a reviewer: what a second agent adds and what it costs |
04-agent-memory |
#26 Memory in AI Agents: What Does an Agent Actually Need to Remember? | The same assistant with no memory, transcripts, summaries, or structured notes of earlier conversations: what to carry forward, what to look up, and what happens when memory is stale |
05-planning |
#27 Planning, Reasoning, and Execution in AI Agents: Who Decides the Steps, and When? | The same assistant with a fixed workflow, a step-by-step loop, a plan written up front, and a plan revised after every result: where planning fails, where reasoning over the right results fails, and what replanning costs |
06-state-and-workflows |
#28 Building AI Agents With State and Workflows | The same refund assistant as an agent loop whose task progress lives only in its message list and as a state machine whose case record is owned by code: wrong refunds, retries, and recovery after a crash |
07-human-in-the-loop |
#29 Human-in-the-Loop AI Agents: When Should an Agent Stop and Ask? | The same assistant with a refund tool that pauses for a reviewer: hard checks in code, approval tiers and roles, expiry, a re-check before execution, execution once, an audit trail, and what the agent tells the customer while it waits and after each decision |
08-failure-modes |
#30 Why AI Agents Fail: Common Failure Modes and Design Patterns | No model calls: the recorded decisions of 01–07 replayed through guards at each failure boundary (argument provenance, repeats, budgets, a refund policy in code, typed handoffs, reply checks): what each guard would have stopped, what correct work it would have stopped too, and which failures pass every guard |
Each demo has its own README with setup, how to run it, expected output, and limitations. All data is synthetic.
Linting
Python is checked with Ruff from the repository root:
pip install -r requirements-dev.txt
ruff check .
From the repository's README on GitHub, synced Nov 24, 2026.