Skip to content
OpenAgentSkill
Browsing is open · Catalog captured 2026-11-21 · Automatic updates and account services are paused.
Design & UI

agent-architecture-design

Guides designing the control loop, state/memory model, and tool boundaries for an LLM-driven agent. Use when a user asks to "design an agent architecture," choose between a ReAct loop / plan-and-execute / finite-state agent, decide on single-agent vs multi-agent decomposition, define how an agent should manage state and memory across turns, or review whether an existing agent's control flow is safe to run unattended.

selvarajmurugesan90 · Static checks on file

Installation

Read the source and dependencies before running a command. Copying does not install or execute anything.

npx skills add selvarajmurugesan90/ops-engineering-skills --skill agent-architecture-design

About this skill


name: agent-architecture-design description: > Guides designing the control loop, state/memory model, and tool boundaries for an LLM-driven agent. Use when a user asks to "design an agent architecture," choose between a ReAct loop / plan-and-execute / finite-state agent, decide on single-agent vs multi-agent decomposition, define how an agent should manage state and memory across turns, or review whether an existing agent's control flow is safe to run unattended. license: Apache-2.0 compatibility: "Claude Code, GitHub Copilot, OpenAI Codex, Cursor, Gemini CLI" metadata: domain: ai-agent maturity: stable

Agent Architecture Design

Purpose

An "agent" is a loop: an LLM repeatedly observes state, decides on an action (call a tool, ask the user, or finish), and updates state based on the result, until some termination condition is met. Getting this loop's shape wrong is the single biggest source of production incidents in agentic systems — not model quality. Agents that loop forever, that accumulate unbounded context, that hold too many high-privilege tools in one prompt, or that have no checkpoint for a human to intervene, fail in ways that are expensive, hard to debug, and sometimes destructive. This skill defines a small set of proven architecture patterns (ReAct-style loop, plan-and-execute, finite-state/graph) and the state, memory, and control-flow decisions that make an agent safe and debuggable to operate, independent of which model or vendor SDK is driving it.

When to use

  • Starting a new agent project and deciding "should this be one prompt with tools, a ReAct loop, or a directed graph of steps?"
  • An existing agent occasionally loops, stalls, or takes an unexpected destructive action, and you need to redesign its control flow.
  • Deciding whether a task needs one agent with many tools or several narrower agents (see multi-agent-orchestration).
  • Designing how an agent's memory persists across sessions (vs. what lives only in the current context window).
  • Code review of an agent's main loop before it is given write access to production systems (files, cloud APIs, payment systems, ticketing).
  • Adding a human-in-the-loop approval checkpoint to an agent that currently runs fully autonomously.

Prerequisites & environment

  • Working knowledge of an LLM API that supports structured tool/function calling (the concept is portable across Anthropic, OpenAI, Google, and open models — exact request/response shapes differ by vendor).
  • A chosen orchestration surface: a raw API loop you write yourself, or a framework/runtime (e.g. an agent SDK, LangGraph-style graph runtime, or a CLI agent host like Claude Code). This skill is framework-agnostic; adapt the patterns to whichever runtime you use.
  • Access to the tools/APIs the agent will call, ideally in a sandboxed or staging environment before granting production credentials.
  • A way to capture traces/logs of each loop iteration (even a structured log file is enough to start).

Step-by-step guidance

  1. Write down the termination condition before writing any prompt. Every agent loop needs an explicit "done" signal: a tool call that means completion, a structured final-answer format, or a supervisor check. If you cannot state in one sentence how the loop knows to stop, do not start building.

  2. Pick a control-flow pattern that matches the task's shape:

    • ReAct-style loop (reason → act → observe, repeat): best for open-ended tasks where the next step genuinely depends on the last tool result (debugging, research, exploratory coding).
    • Plan-and-execute: the model first emits a multi-step plan, then a (possibly separate, cheaper) executor runs each step; best when steps are largely independent and you want a reviewable plan before any action runs.
    • Finite-state / graph: fixed set of named states and explicit transitions (e.g. triage → gather_info → draft → approve → send); best for compliance-sensitive or repeatable business processes where you want to reason about which states can reach which other states.
  3. Bound the loop explicitly. Set a hard maximum iteration count and a wall-clock timeout, independent of the model's own judgment about when it's done. Fail closed (stop and surface an error) rather than fail open (silently keep going or silently give up and claim success).

    MAX_ITERATIONS = 12
    TIMEOUT_SECONDS = 180
    
    def run_agent_loop(task, tools):
        start = time.monotonic()
        for i in range(MAX_ITERATIONS):
            if time.monotonic() - start > TIMEOUT_SECONDS:
                return AgentResult(status="timeout", partial=state.transcript)
            response = llm.call(messages=state.messages, tools=tools)
            if response.stop_reason == "end_turn":
                return AgentResult(status="done", output=response.text)
            if response.stop_reason == "tool_use":
                for call in response.tool_calls:
                    result = dispatch_tool(call, allowlist=tools)  # see agent-tool-use-patterns
                    state.messages.append(tool_result_message(call, result))
        return AgentResult(status="max_iterations_exceeded", partial=state.transcript)
    
  4. Design the state/memory model as two tiers. Keep a small working state (current task, plan, last N tool results) that lives in the context window, and a separate persisted memory (a database, vector store, or file) for anything that must survive across sessions or is too large to keep in-context. Never treat the raw conversation transcript as your only memory store — it grows unbounded and degrades reasoning quality long before it hits a hard token limit.

  5. Define tool boundaries per agent, not per task. List every tool the agent can call and classify each as read-only, reversible-write, o

Read the complete source ↗