Guide

自主设计模式

一个GoF形式的自主设计模式目录 — 用于构建自主AI代理的命名、可重用的形状:代理循环、工具使用、规划、反思、多代理协调和安全护栏。

自主设计模式命名了一种软件的重复形状,其中LLM不仅生成文本,还决定接下来要做什么:选择工具、修订计划、移交给同事、请求批准、停止。"自主"是指在自我指导下朝着目标行动的属性;该目录中的模式为该属性提供了一个合理的结构。没有命名的模式,每个代理都是一次性的;有了它们,代理变得可比较、可组合和可审查。

该目录以Christopher Alexander(1977)和Gang of Four(1994)的方法分解自主设计模式:意图、上下文、问题、力量、因此、解决方案、后果(好处 + 负担)、约束(代理不允许违反的严格禁令)和相关[] — 与其他模式的类型边缘。约束插槽是自主时代的新增内容;它是模式在存在一个几乎可以说服自己放弃任何事情的生成器时保持其形状的方式。

下面的选择侧重于"自主"框架:代理如何推理(ReAct、计划与执行、反思),它如何对世界采取行动(工具使用、增强LLM、移交),多个代理如何协调(监督者、协调者-工作者、子代理隔离),以及系统如何保持可治理(步骤预算、决策日志、代理作为裁判)。打开下面的相关指南以获取相邻的角度 — 架构、多代理、RAG、安全。

Field-tested patterns to start with

  • ReActInterleave a single thought, a single tool call, and a single observation per step so the agent reasons over fresh evidence.
  • Plan-and-ExecutePlan all the steps once with a strong model, then execute each step with a cheaper model under the plan.
  • ReflectionHave the model review its own output and produce a revised version in one or more passes.
  • Tool UseLet the LLM produce typed calls against an external toolkit instead of producing free-form text the surrounding system has to parse.
  • Augmented LLMBuild the foundational agent block as an LLM augmented with retrieval, tools, and memory that the model actively chooses to use, rather than a bare-model call.
  • SupervisorPlace a coordinating agent above a set of specialised agents and route work to them.
  • Orchestrator-WorkersAn orchestrator dynamically breaks a task into subtasks at runtime and delegates each to a worker LLM, then synthesises results.
  • Subagent IsolationRun subagents in isolated workspaces so their writes do not collide and parallelism is safe.
  • HandoffTransfer the active conversation from one agent to another, carrying context across the switch.
  • Decision LogPersist the agent's reasoning trace alongside its actions so post-hoc review can explain why.
  • Step BudgetCap the number of tool calls or loop iterations the agent is allowed within a single request.
  • Agent-as-a-JudgeEvaluate an agent's full trajectory (steps, tool calls, intermediate states) by another agent rather than scoring only the final output.

Recommended reading

Or open the full contents for all 562 patterns in 14 books.

Related guides

  • AI Agents PatternsAI agents patterns: named, reusable shapes for building AI agents that reason, use tools, coordinate, and stay safe — single-agent loops an…
  • AI Agents Patterns CatalogThe AI agents patterns catalog: a complete, GoF-formal pattern language for AI agents across reasoning, planning, tool use, retrieval, memo…
  • LLM Agent Design PatternsA GoF-formal catalog of LLM agent design patterns: ReAct, tool use, plan-and-execute, reflection, step budget, and more. Each pattern decom…
  • Agentic AI Design PatternsAgentic AI design patterns for systems already in production — what to ship, what to observe, what to budget, what to gate. Augmented LLM,…
  • AI Agent Design PatternsHow to build an AI agent: the named shapes you reach for during design and implementation — reasoning (ReAct, plan-and-execute, reflection)…
  • Agent Design PatternsAgent design patterns treat the agent loop as a software-engineering primitive: an observe→reason→act cycle wrapped in tools, memory, super…
  • Agentic PatternsA complete pattern language for agentic systems, organised in Alexander-style books across reasoning, planning, tool use, retrieval, verifi…
  • Agentic AI ArchitectureHow to structure agentic AI: the architectural patterns that hold an LLM-powered system together. Supervisor, orchestrator-workers, augment…
  • RAG Agent PatternsPatterns for building retrieval-augmented generation agents: naive RAG, agentic RAG, hybrid search, cross-encoder reranking, contextual ret…
  • Multi-Agent PatternsPatterns for coordinating multiple LLM agents: supervisor, orchestrator-workers, handoff, debate, hierarchical agents, swarm, role assignme…
  • AI Agent Safety PatternsSafety patterns for LLM agents: step budget, kill switch, constitutional charter, approval queue, sandbox isolation, input/output guardrail…

About this catalog

The Agent Patterns Catalog is an open, GoF-formal reference of 562 design patterns for building LLM agents. Each pattern is decomposed in the manner of Christopher Alexander (1977) and the Gang of Four (1994). Source of truth at github.com/agentpatternscatalog/patterns — CC BY 4.0.

Open the contents