[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DWBHH82AZ4KMB3KWSC1943":3,"skill-same:01M6DWBHH82AZ4KMB3KWSC1943":92},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":68,"commitSha":69,"skillDirectory":70,"forksCount":71,"repositoryHtmlUrl":72,"repositoryHomepageUrl":73,"ownerHtmlUrl":74,"ownerBlogUrl":75,"ownerDescription":76,"updatedAt":77,"install":78,"resources":91},"01M6DWBHH82AZ4KMB3KWSC1943","ai-agent-design",null,"Designing production LLM agents: loop patterns, tool schemas, MCP, multi-agent setups, observability. Use when designing or debugging an agent.","Muvon\u002Foctomind-tap","Muvon","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F25336907?v=4","01M6DWA4KTRX4J73CW5CECKAD0","01M6DWA4QSWFGYE6WDMAMFF1WE",6,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FMuvon\u002Foctomind-tap\u002Fblob\u002Fmaster\u002Fskills\u002Fai-agent-design\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"agent design","ai agent design","ai agent","design","provider","for","context","multi-agent","with tools","tracing","google","write","plan","stack","react","architecture","agent framework","loop","MCP","OpenTelemetry","2026-11-10 10:12:30",false,"---\nname: ai-agent-design\ntitle: \"AI Agent Design: Loops, Tools, Schemas, Orchestration\"\ndescription: \"Designing production LLM agents: loop patterns, tool schemas, MCP, multi-agent setups, observability. Use when designing or debugging an agent.\"\nlicense: Apache-2.0\ncompatibility: \"Stack-agnostic. Production agent stacks typically need: LLM provider SDK (Anthropic \u002F OpenAI \u002F Google), an orchestration framework or hand-rolled loop, a tracing backend (Langfuse \u002F Phoenix \u002F OpenTelemetry collector), MCP servers or REST tools.\"\ndomains: ai\nrules:\n  - session(ai)\n  - content(agent)\n  - content(agents)\n  - content(tool use)\n  - content(function calling)\n  - content(MCP)\n  - content(orchestration)\n  - match(\\b(agent\\s+(loop|design|pattern|architecture))\\b)\n  - match(\\b(tool[\\s-]?(use|call|calling|schema))\\b)\n  - match(\\b(function[\\s-]?call(ing|s)?)\\b)\n  - match(\\b(ReAct|Reflexion|Plan-and-Execute|Tree[\\s-]?of[\\s-]?Thoughts|ToT)\\b)\n  - match(\\b(LangGraph|CrewAI|AutoGen)\\b)\n  - match(\\b(multi[\\s-]?agent)\\b)\n  - match(\\b(Model\\s+Context\\s+Protocol|MCP)\\b)\n  - match(\\b(Agent\\s+Skills)\\b)\n  - match(\\b(context\\s+engineering)\\b)\n  - semantic(design an LLM agent with tools)\n  - semantic(my agent is stuck in a loop)\n  - semantic(should we use multi-agent or single agent with tools)\n  - semantic(what is the best agent framework)\n  - semantic(write tool schemas for my agent)\n---\n\n## Overview\n\nA production LLM agent is a loop: model proposes an action (often a tool call), system executes it, result becomes the next observation, repeat until done. The interesting questions are: which loop pattern, what tools, what schemas, what stops infinite recursion, what's logged for debugging, what's the cost ceiling per task, and which OWASP risks are alive in this surface. This skill encodes the 2026 patterns with cited sources, and the cost \u002F risk numbers that decide architectural choices.\n\nUse this skill when designing a new agent, picking an orchestration framework, debugging a misbehaving agent, or hardening tool exposure. Skip it for single-shot LLM prompts that don't call tools — that's a prompt problem, not an agent problem.\n\n## Mental model\n\nThree forces shape every agent design:\n\n1. Loop structure — how the model reasons across steps. ReAct (interleaved thought-action-observation) is the foundation; Reflexion adds self-critique; Plan-and-Execute splits planning from execution; native function calling (OpenAI \u002F Anthropic tool use) is the production-grade structured variant.\n2. Tool surface — what the agent can do. The schema is the API; descriptions decide behavior; the privilege scope decides blast radius. Tool design is the highest-leverage engineering surface and the most-underserved craft.\n3. Failure containment — what stops the agent when things go wrong. Max iterations, action deduplication, error feedback, escalation ladders. Without these, an agent that hits an unhandled state burns money in a loop until someone notices.\n\nThe 2026 shift: \"prompt engineering\" → \"context engineering\" — curating the whole window (system prompt, tools, retrieved docs, memory, history, examples, output format) across many turns. See §9.\n\n## Instructions\n\n### 1. Agent loop patterns\n\n| Pattern | When to use | Source |\n|---|---|---|\n| ReAct (Thought → Action → Observation) | Default for tool-using agents | Yao et al., Princeton\u002FGoogle, Oct 2022, [arXiv:2210.03629](https:\u002F\u002Farxiv.org\u002Fabs\u002F2210.03629) |\n| Reflexion | Trial-and-error tasks where self-critique helps; more expensive | Shinn et al., [arXiv:2303.11366](https:\u002F\u002Farxiv.org\u002Fabs\u002F2303.11366) |\n| Tree-of-Thoughts (ToT) | Hard search problems where ReAct gets stuck; branches reasoning paths | Yao et al., [arXiv:2305.10601](https:\u002F\u002Farxiv.org\u002Fabs\u002F2305.10601) |\n| Plan-and-Execute | Cheaper than ReAct (fewer LLM calls per step); brittle when early steps surprise | LangGraph docs; practitioner pattern |\n| ReWOO (Reasoning WithOut Observation) | Reduce tokens by decoupling reasoning from tool execution | [arXiv:2305.18323](https:\u002F\u002Farxiv.org\u002Fabs\u002F2305.18323) |\n| Native tool use (OpenAI function calling \u002F Anthropic tool use) | Production-grade structured tool invocation; default for new builds | [OpenAI function calling](https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fguides\u002Ffunction-calling); [Anthropic define tools](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagents-and-tools\u002Ftool-use\u002Fdefine-tools) |\n\nBoth providers converge on JSON Schema tool inputs with a strict mode. Anthropic adds `input_examples`, tool search with deferred loading for large tool sets, and programmatic tool calling (the model orchestrates tools from code execution). The newest Claude models (Opus 5.5, Sonnet 5.5, Fable 5.1) reject forced `tool_choice` (`any` \u002F `tool`): use `auto` with a prompt instruction, `strict: true`, or structured outputs.\n\n### 2. Tool schema design\n\nThe most-underserved craft area in 2026. Bad tool schemas produce loops, wrong-tool calls, and ambiguous outcomes.\n\nBest practices (per [Anthropic define-tools docs](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagents-and-tools\u002Ftool-use\u002Fdefine-tools) and [Writing tools for agents](https:\u002F\u002Fwww.anthropic.com\u002Fengineering\u002Fwriting-tools-for-agents)):\n- Descriptions are the biggest lever: what the tool does, when to use it and when not, what each parameter means, caveats. Aim for 3–4+ sentences.\n- Consolidate related operations into fewer tools (an `action` parameter) and namespace by service (`github_list_prs`); no two tools should plausibly answer the same query.\n- Use `input_examples` or in-description examples for nested or format-sensitive inputs; explicit JSON Schema types; strict mode where available.\n- Return only high-signal fields with stable, semantic identifiers; bloated tool results waste context.\n- If a parameter asks why the call is made, ask for a short explanation, not step-by-step reasoning (the newest Claude models may decline reasoning-extraction requests).\n\nAnti-patterns: generic names (`get_data`), overlapping tools (`search_customers` vs `find_customer`), many optional fields (filled with hallucinated defaults), vague return shapes.\n\n### 3. Agent Skills (open standard, Dec 2025)\n\nAnthropic published Agent Skills as an open standard on Dec 18, 2025; the spec lives at [agentskills.io](https:\u002F\u002Fagentskills.io\u002Fspecification). A skill is a directory with `SKILL.md` (YAML frontmatter + instruction body) and optional scripts and references, loaded on demand so only the frontmatter costs context until it's needed. Use skills for portable expertise that should travel between agents and clients; verify which clients support the current spec before relying on it.\n\n### 4. Model Context Protocol (MCP)\n\nOpen protocol launched by Anthropic in Nov 2024, governed since Dec 2025 under the Linux Foundation's Agentic AI Foundation. Current spec revision: [2026-07-28](https:\u002F\u002Fmodelcontextprotocol.io\u002Fspecification\u002Flatest\u002Fchangelog), a partly breaking release:\n- Stateless: no `initialize` handshake and no `Mcp-Session-Id`; each request carries protocol version and capabilities in `_meta`; servers implement `server\u002Fdiscover`. Cross-call state uses server-minted handles passed as tool arguments.\n- Transports: stdio and Streamable HTTP (requests carry `Mcp-Method` \u002F `Mcp-Name` headers); HTTP+SSE is deprecated.\n- Multi Round-Trip Requests replace server-initiated sampling, elicitation, and roots requests; Roots, Sampling, and Logging are deprecated. Tasks moved to an official extension.\n- Auth: OAuth with Client ID Metadata Documents preferred over Dynamic Client Registration; clients validate `iss`.\n- `tools\u002Flist` should be deterministic (helps prompt-cache hits) and carries cache TTL hints.\n\nSecurity ([best practices](https:\u002F\u002Fmodelcontextprotocol.io\u002Fspecification\u002Flatest\u002Fbasic\u002Fsecurity_best_practices)): servers must not accept or pass through tokens not issued to them; proxies need per-client consent; state handles are never authentication; local servers need explicit install consent and sandboxing; request minimal scopes and step up.\n\nMCP vs REST: MCP when a tool will be reused across agents and clients (discovery, schemas, structured errors); REST when the tool is one-off or already a deployed service.\n\n### 5. Multi-agent orchestration\n\n| Framework | Strength | Trade-off |\n|---|---|---|\n| LangGraph | Stateful graph + conditional edges; most production-tested OSS option | Steeper learning curve; LangChain abstractions |\n| CrewAI | Role-based crews; lowest onboarding cost | Less control over execution |\n| AutoGen | Conversational group-chat patterns | Every turn re-reads the full history; expensive at volume |\n| Vendor agent SDKs (Claude Agent SDK, OpenAI Agents SDK, Google ADK) | Provider-tuned harness: tools, subagents, context management | Tied to one provider's features |\n\nCost trade-off: multi-agent is typically 2–4× single-agent for similar tasks; a 4-agent × 5-round debate is 20+ LLM calls minimum. Use it when sub-tasks are genuinely parallel, need isolated context windows, or need different tools; otherwise single agent + better tools + better context. Current frontier models delegate to subagents readily, so state when subagents are and aren't warranted.\n\nOrchestration patterns:\n- Orchestrator-worker: one planner agent dispatches to worker agents\n- Supervisor: hierarchical with a manager and specialist subordinates\n- Swarm: peer-to-peer with shared state\n- Sequential pipeline: agents in fixed order; cheapest multi-agent variant\n\n### 6. Error handling and infinite-loop prevention\n\nHard requirements for every production agent:\n\n- Hard max_turns \u002F max wall-time \u002F token budget — every agent. A stuck 50-turn run with rich context costs dollars on a frontier model; compute yours from the price book. Use provider budget controls where they exist (Anthropic task budgets, beta) on top of your own caps.\n- Action deduplication — hash `(tool_name, args)` across a run; flag a repeat as a likely loop.\n- Action-history comparison — detect oscillation (A → B → A → B …).\n- Exponential backoff on retries — 3–5 retries general; 5–7 for rate limits.\n- Error message as observation — when a tool fails, feed the error text back as the observation so the model can reason about recovery.\n- Escalation ladder — reflection prompt → alternative tool suggestion → context compression + restart → graceful termination with partial results.\n- Termination predicate — explicit \"done\" condition in the system prompt, plus a harness-side check. Unattended loops must not treat a text-only turn as completion: newer models end turns with progress reports, so keep a task checklist, nudge on open items, and stop after two or three automatic continuations ([Prompting Claude Opus 5.5](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fbuild-with-claude\u002Fprompt-engineering\u002Fprompting-claude-opus-5-5)).\n\nCommon root causes of stuck agents: missing max_turns, broken termination predicate, ambiguous tool schemas, oscillation between two near-equivalent actions.\n\n### 7. Observability\n\nOpenTelemetry GenAI semantic conventions — span names, tool-call attributes, agent spans, PII-safe content capture. They now live in their own repository and are still evolving, so pin the version you emit. MCP (2026-07-28) documents `traceparent` propagation in `_meta`, so traces can cross server boundaries.\n\n| Tool | Strength |\n|---|---|\n| Langfuse | ClickHouse backend, native OTLP endpoint (`\u002Fapi\u002Fpublic\u002Fotel`), strong multi-tenant; OSS |\n| Arize Phoenix | Local-first, notebook-friendly, zero external deps; OSS |\n| Helicone | Drop-in proxy when you cannot instrument code; OSS |\n| LangSmith | Deepest LangChain integration; paid, per-seat |\n\nPer-tool-call log — tool name, args (PII-safe), result, latency, token count, cost, error, parent span ID. Without these, debugging a multi-step failure is forensic guessing.\n\n### 8. OWASP risks and production failures\n\nMap every tool, retrieved-context source, memory store, and output sink to the OWASP Top 10 for LLM Applications (2026 edition; name the edition, since many reports still use 2025 IDs) and the Agentic Top 10 (ASI01 Agent Goal Hijack … ASI10 Rogue Agents, Dec 2025). Full tables and defenses live in the sibling prompt-injection-defense skill.\n\nAgentic failures to design against: Slack AI (Aug 2024, indirect injection exfiltrating private-channel data), EchoLeak (CVE-2025-32711, zero-click via email), GitHub Copilot RCE (CVE-2025-53773), ForcedLeak in Salesforce Agentforce (Sep 2025). In each, untrusted content reached an action surface. Design rule: no session should combine untrusted input, private data access, and external communication or state change without isolation or human confirmation (the \"lethal trifecta\").\n\n### 9. Context engineering (the discipline)\n\nPopularized in June 2025 (Tobi Lütke, Andrej Karpathy) as \"filling the context window with just the right information for the next step.\" It covers system prompt, tool definitions, retrieved docs, memory, history, examples, and output constraints; prompt engineering is a subset.\n\nPractical implications (Anthropic, [Effective context engineering for AI agents](https:\u002F\u002Fwww.anthropic.com\u002Fengineering\u002Feffective-context-engineering-for-ai-agents), Sep 2025):\n- Treat context as a finite budget; recall degrades as it grows (context rot), so the goal is the smallest high-signal set.\n- Retrieve just in time: give the agent lightweight identifiers (paths, queries, links) and tools to load data when needed instead of pre-loading everything.\n- Long-horizon work: compaction (summarize and restart), structured note-taking or memory files outside the window, and sub-agents with clean context windows that return condensed results. Server-side compaction and context editing exist on some APIs; on Claude models that enforce preserved thinking, keep histories append-only and let the server compact.\n- Keep the prefix cache-stable: deterministic tool order, static system prompt, volatile data last.\n- Untrusted retrieved content goes in clearly labeled tags (see the prompt-injection skill).\n\nCross-reference the cost \u002F FinOps skill for caching numbers.\n\n## Checklist\n\n- [ ] Loop pattern named (ReAct \u002F Reflexion \u002F Plan-and-Execute \u002F native function calling) with rationale\n- [ ] Tool descriptions say what, when, when not, and caveats; examples for complex inputs; strict mode where available\n- [ ] No overlapping tools; related operations consolidated and namespaced; tool results high-signal\n- [ ] Hard max_turns + max wall-time configured\n- [ ] Action deduplication + oscillation detection in place\n- [ ] Error feedback loop wired (tool errors become observations)\n- [ ] Termination predicate explicit; unattended harness doesn't treat a text-only turn as done\n- [ ] OpenTelemetry GenAI tracing enabled (Langfuse \u002F Phoenix \u002F Helicone \u002F LangSmith)\n- [ ] Per-tool-call logging with cost, latency, token count\n- [ ] OWASP LLM (edition stated) + Agentic Top 10 risks mapped per tool \u002F context source \u002F output sink; no unguarded lethal-trifecta sessions\n- [ ] Single-agent considered before multi-agent (cost rationale documented if multi-agent chosen)\n- [ ] Prefix cache-stable: static system prompt, deterministic tool order, cache breakpoints set\n- [ ] If using MCP: targets spec 2026-07-28, auth via Client ID Metadata Documents, no token passthrough, third-party servers pinned and reviewed\n\n## Composition \u002F References\n\nWithin-domain pairings:\n- Pairs with the sibling AI skill on RAG patterns (most agents use retrieval as a tool).\n- Pairs with the sibling AI skill on evals (every agent needs trajectory + tool-use accuracy eval).\n- Pairs with the sibling AI skill on cost optimization (multi-agent and tool calls are the dominant cost drivers).\n- Pairs with the sibling AI skill on prompt injection defense (every tool surface is an attack surface).\n\nPrimary sources:\n- [ReAct, arXiv:2210.03629](https:\u002F\u002Farxiv.org\u002Fabs\u002F2210.03629)\n- [Anthropic — Define tools](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagents-and-tools\u002Ftool-use\u002Fdefine-tools)\n- [Anthropic — Writing tools for agents](https:\u002F\u002Fwww.anthropic.com\u002Fengineering\u002Fwriting-tools-for-agents)\n- [Anthropic — Effective context engineering for AI agents](https:\u002F\u002Fwww.anthropic.com\u002Fengineering\u002Feffective-context-engineering-for-ai-agents)\n- [MCP specification 2026-07-28 changelog](https:\u002F\u002Fmodelcontextprotocol.io\u002Fspecification\u002Flatest\u002Fchangelog)\n- [MCP security best practices](https:\u002F\u002Fmodelcontextprotocol.io\u002Fspecification\u002Flatest\u002Fbasic\u002Fsecurity_best_practices)\n- [Agent Skills specification](https:\u002F\u002Fagentskills.io\u002Fspecification)\n- [Anthropic — Donating MCP and the Agentic AI Foundation](https:\u002F\u002Fwww.anthropic.com\u002Fnews\u002Fdonating-the-model-context-protocol-and-establishing-of-the-agentic-ai-foundation)\n- [OWASP Top 10 for Agentic Applications](https:\u002F\u002Fgenai.owasp.org\u002Fresource\u002Fowasp-top-10-for-agentic-applications-for-2026\u002F)\n- [OpenTelemetry GenAI semantic conventions](https:\u002F\u002Fopentelemetry.io\u002Fdocs\u002Fspecs\u002Fsemconv\u002Fgen-ai\u002F)\n- [Langfuse OpenTelemetry integration](https:\u002F\u002Flangfuse.com\u002Fintegrations\u002Fnative\u002Fopentelemetry)\n","## Overview\n\nA production LLM agent is a loop: model proposes an action (often a tool call), system executes it, result becomes the next observation, repeat until done. The interesting questions are: which loop pattern, what tools, what schemas, what stops infinite recursion, what's logged for debugging, what's the cost ceiling per task, and which OWASP risks are alive in this surface. This skill encodes the 2026 patterns with cited sources, and the cost \u002F risk numbers that decide architectural choices.\n\nUse this skill when designing a new agent, picking an orchestration framework, debugging a misbehaving agent, or hardening tool exposure. Skip it for single-shot LLM prompts that don't call tools — that's a prompt problem, not an agent problem.\n\n## Mental model\n\nThree forces shape every agent design:\n\n1. Loop structure — how the model reasons across steps. ReAct (interleaved thought-action-observation) is the foundation; Reflexion adds self-critique; Plan-and-Execute splits planning from execution; native function calling (OpenAI \u002F Anthropic tool use) is the production-grade structured variant.\n2. Tool surface — what the agent can do. The schema is the API; descriptions decide behavior; the privilege scope decides blast radius. Tool design is the highest-leverage engineering surface and the most-underserved craft.\n3. Failure containment — what stops the agent when things go wrong. Max iterations, action deduplication, error feedback, escalation ladders. Without these, an agent that hits an unhandled state burns money in a loop until someone notices.\n\nThe 2026 shift: \"prompt engineering\" → \"context engineering\" — curating the whole window (system prompt, tools, retrieved docs, memory, history, examples, output format) across many turns. See §9.\n\n## Instructions\n\n### 1. Agent loop patterns\n\n| Pattern | When to use | Source |\n|---|---|---|\n| ReAct (Thought → Action → Observation) | Default for tool-using agents | Yao et al., Princeton\u002FGoogle, Oct 2022, [arXiv:2210.03629](https:\u002F\u002Farxiv.org\u002Fabs\u002F2210.03629) |\n| Reflexion | Trial-and-error tasks where self-critique helps; more expensive | Shinn et al., [arXiv:2303.11366](https:\u002F\u002Farxiv.org\u002Fabs\u002F2303.11366) |\n| Tree-of-Thoughts (ToT) | Hard search problems where ReAct gets stuck; branches reasoning paths | Yao et al., [arXiv:2305.10601](https:\u002F\u002Farxiv.org\u002Fabs\u002F2305.10601) |\n| Plan-and-Execute | Cheaper than ReAct (fewer LLM calls per step); brittle when early steps surprise | LangGraph docs; practitioner pattern |\n| ReWOO (Reasoning WithOut Observation) | Reduce tokens by decoupling reasoning from tool execution | [arXiv:2305.18323](https:\u002F\u002Farxiv.org\u002Fabs\u002F2305.18323) |\n| Native tool use (OpenAI function calling \u002F Anthropic tool use) | Production-grade structured tool invocation; default for new builds | [OpenAI function calling](https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fguides\u002Ffunction-calling); [Anthropic define tools](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagents-and-tools\u002Ftool-use\u002Fdefine-tools) |\n\nBoth providers converge on JSON Schema tool inputs with a strict mode. Anthropic adds `input_examples`, tool search with deferred loading for large tool sets, and programmatic tool calling (the model orchestrates tools from code execution). The newest Claude models (Opus 5.5, Sonnet 5.5, Fable 5.1) reject forced `tool_choice` (`any` \u002F `tool`): use `auto` with a prompt instruction, `strict: true`, or structured outputs.\n\n### 2. Tool schema design\n\nThe most-underserved craft area in 2026. Bad tool schemas produce loops, wrong-tool calls, and ambiguous outcomes.\n\nBest practices (per [Anthropic define-tools docs](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagents-and-tools\u002Ftool-use\u002Fdefine-tools) and [Writing tools for agents](https:\u002F\u002Fwww.anthropic.com\u002Fengineering\u002Fwriting-tools-for-agents)):\n- Descriptions are the biggest lever: what the tool does, when to use it and when not, what each parameter means, caveats. Aim for 3–4+ sentences.\n- Consolidate related operations into fewer tools (an `action` parameter) and namespace by service (`github_list_prs`); no two tools should plausibly answer the same query.\n- Use `input_examples` or in-description examples for nested or format-sensitive inputs; explicit JSON Schema types; strict mode where available.\n- Return only high-signal fields with stable, semantic identifiers; bloated tool results waste context.\n- If a parameter asks why the call is made, ask for a short explanation, not step-by-step reasoning (the newest Claude models may decline reasoning-extraction requests).\n\nAnti-patterns: generic names (`get_data`), overlapping tools (`search_customers` vs `find_customer`), many optional fields (filled with hallucinated defaults), vague return shapes.\n\n### 3. Agent Skills (open standard, Dec 2025)\n\nAnthropic published Agent Skills as an open standard on Dec 18, 2025; the spec lives at [agentskills.io](https:\u002F\u002Fagentskills.io\u002Fspecification). A skill is a directory with `SKILL.md` (YAML frontmatter + instruction body) and optional scripts and references, loaded on demand so only the frontmatter costs context until it's needed. Use skills for portable expertise that should travel between agents and clients; verify which clients support the current spec before relying on it.\n\n### 4. Model Context Protocol (MCP)\n\nOpen protocol launched by Anthropic in Nov 2024, governed since Dec 2025 under the Linux Foundation's Agentic AI Foundation. Current spec revision: [2026-07-28](https:\u002F\u002Fmodelcontextprotocol.io\u002Fspecification\u002Flatest\u002Fchangelog), a partly breaking release:\n- Stateless: no `initialize` handshake and no `Mcp-Session-Id`; each request carries protocol version and capabilities in `_meta`; servers implement `server\u002Fdiscover`. Cross-call state uses server-minted handles passed as tool arguments.\n- Transports: stdio and Streamable HTTP (requests carry `Mcp-Method` \u002F `Mcp-Name` headers); HTTP+SSE is deprecated.\n- Multi Round-Trip Requests replace server-initiated sampling, elicitation, and roots requests; Roots, Sampling, and Logging are deprecated. Tasks moved to an official extension.\n- Auth: OAuth with Client ID Metadata Documents preferred over Dynamic Client Registration; clients validate `iss`.\n- `tools\u002Flist` should be deterministic (helps prompt-cache hits) and carries cache TTL hints.\n\nSecurity ([best practices](https:\u002F\u002Fmodelcontextprotocol.io\u002Fspecification\u002Flatest\u002Fbasic\u002Fsecurity_best_practices)): servers must not accept or pass through tokens not issued to them; proxies need per-client consent; state handles are never authentication; local servers need explicit install consent and sandboxing; request minimal scopes and step up.\n\nMCP vs REST: MCP when a tool will be reused across agents and clients (discovery, schemas, structured errors); REST when the tool is one-off or already a deployed service.\n\n### 5. Multi-agent orchestration\n\n| Framework | Strength | Trade-off |\n|---|---|---|\n| LangGraph | Stateful graph + conditional edges; most production-tested OSS option | Steeper learning curve; LangChain abstractions |\n| CrewAI | Role-based crews; lowest onboarding cost | Less control over execution |\n| AutoGen | Conversational group-chat patterns | Every turn re-reads the full history; expensive at volume |\n| Vendor agent SDKs (Claude Agent SDK, OpenAI Agents SDK, Google ADK) | Provider-tuned harness: tools, subagents, context management | Tied to one provider's features |\n\nCost trade-off: multi-agent is typically 2–4× single-agent for similar tasks; a 4-agent × 5-round debate is 20+ LLM calls minimum. Use it when sub-tasks are genuinely parallel, need isolated context windows, or need different tools; otherwise single agent + better tools + better context. Current frontier models delegate to subagents readily, so state when subagents are and aren't warranted.\n\nOrchestration patterns:\n- Orchestrator-worker: one planner agent dispatches to worker agents\n- Supervisor: hierarchical with a manager and specialist subordinates\n- Swarm: peer-to-peer with shared state\n- Sequential pipeline: agents in fixed order; cheapest multi-agent variant\n\n### 6. Error handling and infinite-loop prevention\n\nHard requirements for every production agent:\n\n- Hard max_turns \u002F max wall-time \u002F token budget — every agent. A stuck 50-turn run with rich context costs dollars on a frontier model; compute yours from the price book. Use provider budget controls where they exist (Anthropic task budgets, beta) on top of your own caps.\n- Action deduplication — hash `(tool_name, args)` across a run; flag a repeat as a likely loop.\n- Action-history comparison — detect oscillation (A → B → A → B …).\n- Exponential backoff on retries — 3–5 retries general; 5–7 for rate limits.\n- Error message as observation — when a tool fails, feed the error text back as the observation so the model can reason about recovery.\n- Escalation ladder — reflection prompt → alternative tool suggestion → context compression + restart → graceful termination with partial results.\n- Termination predicate — explicit \"done\" condition in the system prompt, plus a harness-side check. Unattended loops must not treat a text-only turn as completion: newer models end turns with progress reports, so keep a task checklist, nudge on open items, and stop after two or three automatic continuations ([Prompting Claude Opus 5.5](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fbuild-with-claude\u002Fprompt-engineering\u002Fprompting-claude-opus-5-5)).\n\nCommon root causes of stuck agents: missing max_turns, broken termination predicate, ambiguous tool schemas, oscillation between two near-equivalent actions.\n\n### 7. Observability\n\nOpenTelemetry GenAI semantic conventions — span names, tool-call attributes, agent spans, PII-safe content capture. They now live in their own repository and are still evolving, so pin the version you emit. MCP (2026-07-28) documents `traceparent` propagation in `_meta`, so traces can cross server boundaries.\n\n| Tool | Strength |\n|---|---|\n| Langfuse | ClickHouse backend, native OTLP endpoint (`\u002Fapi\u002Fpublic\u002Fotel`), strong multi-tenant; OSS |\n| Arize Phoenix | Local-first, notebook-friendly, zero external deps; OSS |\n| Helicone | Drop-in proxy when you cannot instrument code; OSS |\n| LangSmith | Deepest LangChain integration; paid, per-seat |\n\nPer-tool-call log — tool name, args (PII-safe), result, latency, token count, cost, error, parent span ID. Without these, debugging a multi-step failure is forensic guessing.\n\n### 8. OWASP risks and production failures\n\nMap every tool, retrieved-context source, memory store, and output sink to the OWASP Top 10 for LLM Applications (2026 edition; name the edition, since many reports still use 2025 IDs) and the Agentic Top 10 (ASI01 Agent Goal Hijack … ASI10 Rogue Agents, Dec 2025). Full tables and defenses live in the sibling prompt-injection-defense skill.\n\nAgentic failures to design against: Slack AI (Aug 2024, indirect injection exfiltrating private-channel data), EchoLeak (CVE-2025-32711, zero-click via email), GitHub Copilot RCE (CVE-2025-53773), ForcedLeak in Salesforce Agentforce (Sep 2025). In each, untrusted content reached an action surface. Design rule: no session should combine untrusted input, private data access, and external communication or state change without isolation or human confirmation (the \"lethal trifecta\").\n\n### 9. Context engineering (the discipline)\n\nPopularized in June 2025 (Tobi Lütke, Andrej Karpathy) as \"filling the context window with just the right information for the next step.\" It covers system prompt, tool definitions, retrieved docs, memory, history, examples, and output constraints; prompt engineering is a subset.\n\nPractical implications (Anthropic, [Effective context engineering for AI agents](https:\u002F\u002Fwww.anthropic.com\u002Fengineering\u002Feffective-context-engineering-for-ai-agents), Sep 2025):\n- Treat context as a finite budget; recall degrades as it grows (context rot), so the goal is the smallest high-signal set.\n- Retrieve just in time: give the agent lightweight identifiers (paths, queries, links) and tools to load data when needed instead of pre-loading everything.\n- Long-horizon work: compaction (summarize and restart), structured note-taking or memory files outside the window, and sub-agents with clean context windows that return condensed results. Server-side compaction and context editing exist on some APIs; on Claude models that enforce preserved thinking, keep histories append-only and let the server compact.\n- Keep the prefix cache-stable: deterministic tool order, static system prompt, volatile data last.\n- Untrusted retrieved content goes in clearly labeled tags (see the prompt-injection skill).\n\nCross-reference the cost \u002F FinOps skill for caching numbers.\n\n## Checklist\n\n- [ ] Loop pattern named (ReAct \u002F Reflexion \u002F Plan-and-Execute \u002F native function calling) with rationale\n- [ ] Tool descriptions say what, when, when not, and caveats; examples for complex inputs; strict mode where available\n- [ ] No overlapping tools; related operations consolidated and namespaced; tool results high-signal\n- [ ] Hard max_turns + max wall-time configured\n- [ ] Action deduplication + oscillation detection in place\n- [ ] Error feedback loop wired (tool errors become observations)\n- [ ] Termination predicate explicit; unattended harness doesn't treat a text-only turn as done\n- [ ] OpenTelemetry GenAI tracing enabled (Langfuse \u002F Phoenix \u002F Helicone \u002F LangSmith)\n- [ ] Per-tool-call logging with cost, latency, token count\n- [ ] OWASP LLM (edition stated) + Agentic Top 10 risks mapped per tool \u002F context source \u002F output sink; no unguarded lethal-trifecta sessions\n- [ ] Single-agent considered before multi-agent (cost rationale documented if multi-agent chosen)\n- [ ] Prefix cache-stable: static system prompt, deterministic tool order, cache breakpoints set\n- [ ] If using MCP: targets spec 2026-07-28, auth via Client ID Metadata Documents, no token passthrough, third-party servers pinned and reviewed\n\n## Composition \u002F References\n\nWithin-domain pairings:\n- Pairs with the sibling AI skill on RAG patterns (most agents use retrieval as a tool).\n- Pairs with the sibling AI skill on evals (every agent needs trajectory + tool-use accuracy eval).\n- Pairs with the sibling AI skill on cost optimization (multi-agent and tool calls are the dominant cost drivers).\n- Pairs with the sibling AI skill on prompt injection defense (every tool surface is an attack surface).\n\nPrimary sources:\n- [ReAct, arXiv:2210.03629](https:\u002F\u002Farxiv.org\u002Fabs\u002F2210.03629)\n- [Anthropic — Define tools](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagents-and-tools\u002Ftool-use\u002Fdefine-tools)\n- [Anthropic — Writing tools for agents](https:\u002F\u002Fwww.anthropic.com\u002Fengineering\u002Fwriting-tools-for-agents)\n- [Anthropic — Effective context engineering for AI agents](https:\u002F\u002Fwww.anthropic.com\u002Fengineering\u002Feffective-context-engineering-for-ai-agents)\n- [MCP specification 2026-07-28 changelog](https:\u002F\u002Fmodelcontextprotocol.io\u002Fspecification\u002Flatest\u002Fchangelog)\n- [MCP security best practices](https:\u002F\u002Fmodelcontextprotocol.io\u002Fspecification\u002Flatest\u002Fbasic\u002Fsecurity_best_practices)\n- [Agent Skills specification](https:\u002F\u002Fagentskills.io\u002Fspecification)\n- [Anthropic — Donating MCP and the Agentic AI Foundation](https:\u002F\u002Fwww.anthropic.com\u002Fnews\u002Fdonating-the-model-context-protocol-and-establishing-of-the-agentic-ai-foundation)\n- [OWASP Top 10 for Agentic Applications](https:\u002F\u002Fgenai.owasp.org\u002Fresource\u002Fowasp-top-10-for-agentic-applications-for-2026\u002F)\n- [OpenTelemetry GenAI semantic conventions](https:\u002F\u002Fopentelemetry.io\u002Fdocs\u002Fspecs\u002Fsemconv\u002Fgen-ai\u002F)\n- [Langfuse OpenTelemetry integration](https:\u002F\u002Flangfuse.com\u002Fintegrations\u002Fnative\u002Fopentelemetry)\n",{"name":5,"rules":43,"title":65,"domains":66,"license":14,"description":7,"compatibility":67},[44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64],"session(ai)","content(agent)","content(agents)","content(tool use)","content(function calling)","content(MCP)","content(orchestration)","match(\\b(agent\\s+(loop|design|pattern|architecture))\\b)","match(\\b(tool[\\s-]?(use|call|calling|schema))\\b)","match(\\b(function[\\s-]?call(ing|s)?)\\b)","match(\\b(ReAct|Reflexion|Plan-and-Execute|Tree[\\s-]?of[\\s-]?Thoughts|ToT)\\b)","match(\\b(LangGraph|CrewAI|AutoGen)\\b)","match(\\b(multi[\\s-]?agent)\\b)","match(\\b(Model\\s+Context\\s+Protocol|MCP)\\b)","match(\\b(Agent\\s+Skills)\\b)","match(\\b(context\\s+engineering)\\b)","semantic(design an LLM agent with tools)","semantic(my agent is stuck in a loop)","semantic(should we use multi-agent or single agent with tools)","semantic(what is the best agent framework)","semantic(write tool schemas for my agent)","AI Agent Design: Loops, Tools, Schemas, Orchestration","ai","Stack-agnostic. Production agent stacks typically need: LLM provider SDK (Anthropic \u002F OpenAI \u002F Google), an orchestration framework or hand-rolled loop, a tracing backend (Langfuse \u002F Phoenix \u002F OpenTelemetry collector), MCP servers or REST tools.","master","e9e4a19559669b1627b1ac5ed3f77b8e36cfad95","skills\u002Fai-agent-design",0,"https:\u002F\u002Fgithub.com\u002FMuvon\u002Foctomind-tap","https:\u002F\u002Foctomind.run\u002Ftap\u002F","https:\u002F\u002Fgithub.com\u002FMuvon","https:\u002F\u002Fmuvon.io","We bring ideas to life","2026-11-14 13:21:16",{"source":8,"skillName":5,"commands":79,"prompt":89,"zipAvailable":90},[80,83,86],{"tool":81,"command":82},"npx","npx skills add Muvon\u002Foctomind-tap --skill ai-agent-design",{"tool":84,"command":85},"bunx","bunx skills add Muvon\u002Foctomind-tap --skill ai-agent-design",{"tool":87,"command":88},"pnpm","pnpm dlx skills add Muvon\u002Foctomind-tap --skill ai-agent-design","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMuvon\u002Foctomind-tap\u002Fblob\u002Fmaster\u002Fskills\u002Fai-agent-design\u002FSKILL.md",true,[],[93,120,144,164,185,209],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":38},"01M70SFC5CTHRKA9B97N1ARVZ2","seo-content-refresh","Finds decaying pages, picks update, merge, redirect or remove, and briefs each refresh. Use to prioritize existing content and judge whether it helped.","https:\u002F\u002Fgithub.com\u002FMuvon\u002Foctomind-tap\u002Fblob\u002Fmaster\u002Fskills\u002Fseo-content-refresh\u002FSKILL.md",[],[100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119],"seo content refresh","seo","seo content","content refresh","refresh","content","posts","remove","web search","performance","search","traffic","access","drop","websearch","revamp","merge","diagnosis","update","decay",{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":38},"01M70SBWQCHGH7HGS51Y0GTKKW","marketing-review-program","Plans how to ask real customers for honest public reviews: site choice, invitation copy, incentive and disclosure rules. Use to start a review program.","https:\u002F\u002Fgithub.com\u002FMuvon\u002Foctomind-tap\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketing-review-program\u002FSKILL.md",[],[127,128,129,130,131,132,108,110,133,134,135,136,137,138,30,139,140,141,142,143],"program","review","marketing review program","marketing","reviews","get","campaign","choice","how to","only","generated","ask","product","generate","customer","how","request",{"skillNo":145,"name":146,"nameZh":6,"description":147,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":148,"categories":149,"keywords":150,"publishedAt":38},"01M70SBB65Z2FC71Q7DEAXGJBG","geo-source-actions","Turns AI citation findings into ranked per-source actions for Reddit threads, listicles, review sites and videos. Records only. Use after a GEO audit.","https:\u002F\u002Fgithub.com\u002FMuvon\u002Foctomind-tap\u002Fblob\u002Fmaster\u002Fskills\u002Fgeo-source-actions\u002FSKILL.md",[],[151,152,153,154,155,132,108,110,156,157,136,114,128,158,159,160,139,161,162,163],"actions","geo source actions","source","geo","sources","copilot","domains","llms","threads","youtube","audit","action","data",{"skillNo":165,"name":166,"nameZh":6,"description":167,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":168,"categories":169,"keywords":170,"publishedAt":38},"01M70S99D3Y6GF097GTXWBXHPW","commerce-ai-readiness","Audits product feeds, markup and live pages for AI shopping assistants, then lists exact fixes. Use to make a store catalog readable to AI shoppers.","https:\u002F\u002Fgithub.com\u002FMuvon\u002Foctomind-tap\u002Fblob\u002Fmaster\u002Fskills\u002Fcommerce-ai-readiness\u002FSKILL.md",[],[171,172,173,174,175,176,177,178,179,180,110,181,156,136,112,182,183,139,161,184],"ai readiness","commerce ai readiness","commerce","readiness","feeds","ready","show","shopping","discover","checkout","up","ecommerce","documentation","recommend",{"skillNo":186,"name":187,"nameZh":6,"description":188,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":189,"categories":190,"keywords":191,"publishedAt":38},"01M6DWSX45J42KTK6XASKJRGPA","tap-model-training","Train, evaluate and publish the octomind-embed model behind capability auto-activation. Use when capability triggers or skill semantic() phrases change.","https:\u002F\u002Fgithub.com\u002FMuvon\u002Foctomind-tap\u002Fblob\u002Fmaster\u002Fskills\u002Ftap-model-training\u002FSKILL.md",[],[192,193,194,195,196,181,197,198,199,200,201,202,203,204,205,142,206,207,208,118],"model","training","tap","tap model training","scope","eval","uv","auto","dataset","activate","api","capabilities","publish","change","embedding","re","when",{"skillNo":210,"name":211,"nameZh":6,"description":212,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":213,"categories":214,"keywords":215,"publishedAt":38},"01M6DWSQB7NSW53Z86XM81R1W1","tap-deps-authoring","Write dep scripts for the octomind-tap registry: header comments, platform.sh, mcp vs dep types, npx\u002Fuvx pattern. Use when editing deps\u002F\u003Corg>\u002F\u003Ctool>.sh.","https:\u002F\u002Fgithub.com\u002FMuvon\u002Foctomind-tap\u002Fblob\u002Fmaster\u002Fskills\u002Ftap-deps-authoring\u002FSKILL.md",[],[216,194,217,218,219,36,220,221,222,223,224,225,226,227,228,229,208,29,230,23],"deps","tap deps authoring","authoring","DEP","run","scripts","pattern","install","registry","platform","repo","editing","tool","types","org"]