惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
The Register - Security
The Register - Security
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The GitHub Blog
The GitHub Blog
博客园 - 司徒正美
罗磊的独立博客
U
Unit 42
S
SegmentFault 最新的问题
Y
Y Combinator Blog
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
J
Java Code Geeks
Schneier on Security
Schneier on Security
Know Your Adversary
Know Your Adversary
C
Check Point Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Simon Willison's Weblog
Simon Willison's Weblog
V
Vulnerabilities – Threatpost
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志
The Hacker News
The Hacker News
博客园 - 叶小钗
C
Cybersecurity and Infrastructure Security Agency CISA
Spread Privacy
Spread Privacy
L
LINUX DO - 热门话题
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Latest news
Latest news
L
Lohrmann on Cybersecurity
A
About on SuperTechFans
L
LangChain Blog
Stack Overflow Blog
Stack Overflow Blog
S
Securelist
A
Arctic Wolf
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Threatpost
Scott Helme
Scott Helme
博客园 - 聂微东
博客园 - 【当耐特】
T
Tenable Blog
I
Intezer
D
DataBreaches.Net
B
Blog RSS Feed
Security Latest
Security Latest
C
Cisco Blogs
T
Tor Project blog
N
Netflix TechBlog - Medium

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Agentic Design Patterns: The Shapes Every Coding Agent Reuses
Hussam Ahmed · 2026-06-16 · via DEV Community

Hussam Ahmed

This is an adapted excerpt from a guide in my AI Knowledge Hub. The full interactive version is linked at the end.

Agentic design patterns are named control structures for arranging LLM calls and tools. This post gives you the decision rule for picking one, the exact shape of each pattern, and the cost each adds — so you can match a task to the minimum structure that solves it. Everything here is model-agnostic and grounded in Anthropic's Building Effective Agents and the Claude Agent SDK.

Workflow vs. agent: the split that decides everything

Anthropic divides all agentic systems into two categories, and the split decides every downstream tradeoff:

Category Definition Control lives in Use when
Workflow LLMs and tools orchestrated through predefined code paths Your code You can pre-map the decision tree; want accuracy, control, lower cost
Agent LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks The model Open-ended task where you can't predict the number of steps

Every pattern composes one unit: the augmented LLM — an LLM enhanced with retrieval, tools, and memory. It generates its own search queries, selects tools, and decides what to retain. If a single augmented LLM call solves the task, stop — no pattern required.

The escalation rule is the whole game: find "the simplest solution possible, and only increasing complexity when needed" — which "might mean not building agentic systems at all." Agentic systems trade latency and cost for better task performance, so only escalate when a specific failure mode forces it.

The agent loop: gather → act → verify → repeat

For open-ended tasks, every agent runs the same four-beat loop:

  • Gather context — read files, run agentic search (grep / find / tail to pull relevant slices instead of whole files), or delegate to subagents with isolated context windows.
  • Take action — execute via tools: bash, code generation, file edits, MCP servers.
  • Verify work — check the result before declaring done, using ground truth from the environment (tool results, test output).
  • Repeat — a failed verification loops back to "take action."

Without ground-truth feedback at each step, the model guesses and compounds errors. Verification is the beat that makes this an agent rather than a script. Here it is wired up with the Claude Agent SDK:

# pip install claude-agent-sdk
# TS equivalent: npm i @anthropic-ai/claude-agent-sdk
import anyio
from claude_agent_sdk import query, ClaudeAgentOptions

async def main() -> None:
    options = ClaudeAgentOptions(
        # Make "verify" deterministic: a rule that either passes or fails.
        allowed_tools=["Read", "Edit", "Bash", "Grep"],
        system_prompt=(
            "Fix the failing test in tests/. After every edit, run "
            "'pytest -q' and only stop when it passes. Do not edit or delete "
            "tests to make them pass."
        ),
    )
    async for message in query(
        prompt="The auth test is red after the password-reset change. Make it green.",
        options=options,
    ):
        print(message)  # gather -> act -> (pytest = verify) -> repeat until green

anyio.run(main)

Three ways to verify, best first

Method How it verifies When to use it Cost / caveat
Rules-based (linters, types, tests) A defined rule passes or fails; the agent is told which rule failed and why Anything expressible as a deterministic check — "the best form of feedback" Cheap and fast; needs the rule to exist
Visual feedback Screenshots / renders the model inspects Layout, styling, responsiveness — things a test cannot assert Needs a render step and a vision-capable model
LLM-as-judge A separate model scores against fuzzy criteria Only when no rule or render can capture the criterion Heavy latency tradeoffs for marginal gains — last resort

The four workflow patterns

Pattern Shape When it wins Example
Prompt chaining Sequence of steps; each LLM call processes the previous output; optional programmatic gates between steps Task can be "easily and cleanly decomposed into fixed subtasks" Outline → gate-check outline meets brief → write doc
Routing A classifier (LLM or classical) sorts input, then sends it to a specialized handler "Distinct categories that are better handled separately, and where classification can be handled accurately" Support desk: general / refund / tech → different flows; easy→cheap model, hard→frontier model
Parallelization — sectioning "Breaking a task into independent subtasks run in parallel" Subtasks parallelizable for speed One model answers while another screens for inappropriate content
Parallelization — voting "Running the same task multiple times to get diverse outputs" Multiple attempts needed for higher-confidence results Several prompts review code for vulns; vote with a threshold

Parallelization vs. orchestrator–workers

Both fan work across multiple LLM calls. The distinction is who draws the subtasks:

  • Parallelization runs pre-defined subtasks — you decided the branches in code before the model ran.
  • Orchestrator–workers is model-driven: a central LLM "dynamically breaks down tasks, delegates them to worker LLMs, and synthesizes their results," and "the subtasks aren't pre-defined, but determined by the orchestrator based on the specific input."

Use orchestrator–workers for "complex tasks where you can't predict the subtasks needed" — Anthropic's example is "coding products that make complex changes to multiple files each time." If subtasks are fixed, hardcode and parallelize; if they vary per input, let the orchestrator decide.

Mind the token cost. In Anthropic's research system, a Claude Opus 4 lead with Claude Sonnet 4 subagents outperformed single-agent Opus 4 by 90.2% on their internal research eval — but "agents typically use about 4× more tokens than chat interactions, and multi-agent systems use about 15× more tokens" than chats. Multi-agent only pays off for valuable, parallelizable, breadth-first work exceeding one context window. The scaling rule from the lead prompt: simple fact-finding = 1 agent with 3–10 tool calls; direct comparisons = 2–4 subagents with 10–15 calls each; complex research = more than 10 subagents.

Evaluator–optimizer (reflection)

"One LLM call generates a response while another provides evaluation and feedback in a loop." The broader literature calls this reflection — the same shape under a different name.

It is "particularly effective when we have clear evaluation criteria, and when iterative refinement provides measurable value." Two signals it fits: a human articulating feedback demonstrably improves the output, and the LLM can produce that critique itself. With fuzzy criteria you get an expensive loop that polishes nothing — prefer deterministic verification first.

Plan-and-execute vs. ReAct: when the model thinks

Plan-and-execute: a planner generates a full multi-step plan up front; executor(s) carry out each step (often smaller, cheaper models); a replanning step decides whether to finish or generate a follow-up plan. Three wins: speed (intermediate steps skip the big model), cost (the large model is only called for re-planning steps), and quality (the planner must explicitly think through all the steps). Footgun: no replanning means a wrong initial plan executes faithfully to a wrong answer.

ReAct: the LLM only plans for one sub-problem at a time — think → act → observe, one tool call per turn, adapting continuously. It wins on simple, dynamic tasks solvable in a few tool calls where each next step depends on the last observation.

For long-running work, Anthropic's harness operationalizes plan/execute/review as a planner / generator / evaluator structure with durable artifacts that survive a context reset: an initializer agent writes an init.sh script, a claude-progress.txt file, and an initial git commit; a coding agent makes incremental progress against a feature list (JSON) of 200+ granular, testable features marked passing/failing; and it verifies as an engineer would, marking a feature done only when it actually works. One hard rule: never let an agent delete its own tests — "it is unacceptable to remove or edit tests because this could lead to missing or buggy functionality." Treat the test suite as immutable ground truth.

The decision table

Read top to bottom; stop at the first row that fits.

If the task… Use Because
is solved by one augmented LLM call No pattern Simplest solution first; patterns add latency and cost
splits into fixed, clean sequential steps Prompt chaining Each easier subtask raises accuracy; gates catch drift
has distinct input categories handled best separately Routing Specialized prompts per class; cheap model for easy inputs
splits into fixed independent subtasks, or needs many attempts Parallelization (section / vote) Run them at once for speed, or vote for confidence
has subtasks you cannot predict until you see the input Orchestrator–workers The model decides the subtasks at runtime
has a clear pass/fail check and improves with iteration Evaluator–optimizer A critique loop measurably refines the output
is open-ended with no predictable number of steps Agent (loop / plan-execute) You can't hardcode the path; the model needs ground-truth feedback

Patterns compose, and frameworks can hide them. A real coding agent might route a request, hand hard ones to an orchestrator that fans work to workers each running a gather → act → verify loop with rules-based checks. Layer only as far as the task demands. Frameworks "make it easy to get started" but "often create extra layers of abstraction that can obscure the underlying prompts and responses, making them harder to debug" — start with raw API calls and understand the shape before a framework hides it.


This is an adapted excerpt. The full interactive version — including a pattern explorer that animates how control and data flow through each shape, a live fan-out visualizer with a token meter, and a quiz on matching tasks to patterns — lives at the canonical URL: hussamahmed.com/ai/foundations/agentic-design-patterns. It is part of a larger, fact-checked hub on Claude Code, Codex, Gemini CLI, IDE agents, and the first principles beneath them.