AI Agent · Architecture

Agent Runtime Architecture: The Reasoning Loop

Given a single natural-language request, how does an Agent get it done? Sitting on a runtime foundation, it runs a closed loop — Think → Act → Observe → Adjust — calling resources and tools on demand until the task is complete. Redrawn as vector art below, zoom in as far as you like without any loss.

🔁 Closed-loop iteration🧰 On-demand resources🧠 Model called every turn📦 State accumulates
👤 User 💬 Natural-language request e.g. “Analyze last week’s ad-campaign data and suggest optimizations” ⚙️ Agent Runtime (Harness) — Runtime Environment (does not reason) 🗄️StateManagement 🧠MemoryManagement 🧩ContextAggregation 📊BudgetManagement 🔄LoopController ♻️Retry& Recovery 🔧ToolDispatcher Handles: state · context aggregation · loop control · tool dispatch · error handling · resources · budget Global runtime spans the whole Agent lifecycle Runtime Context (State) spans the whole loop updated every turn 💬 Conversation 🗂️ Long-term mem. 👤 User info 📁 Files · Data 🔧 Tool results 🔣 Variables 🔎 RAG retrieval 📝 Scratchpad Updated & accumulated 🔄 Reasoning Loop (Core Control Flow: Closed-Loop Iteration) until the task is done or an exit condition is met 🧠 Think · Understand problem· Analyze situation· Recall info· Spot key points· Form approach 📋 (Optional) Plan · Make a plan· Break down tasks· Choose strategy· Decide next step merged into Think in some paradigms ⚡ Act · Pick the resource(Skill / Workflow/ Tool)· Execute 👁️ Observe · Receive results· Analyze feedback· Assess progress· Done?· Adjust? Each Act calls resources on demand ↓ 🧰 Callable Resources (called laterally, not a linear pipeline) 🛠️ Skills (Capabilities) packaged skills · solve specific problems Write code Data analysis Write PRD SEO optimization Ad optimization Contract review 🔀 Workflow (Process) multi-step process · for complex tasks Read data Clean data Analyze data Build charts Generate report Check & verify Export results 🧰 Tools / MCP external services · via API or MCP 🐙 GitHub 💬 Slack 🌐 Browser 🗃️ SQL Database 🎨 Figma 📔 Notion 📂 Local filesystem 📧 Email · Calendar 🧩 Assemble this turn’s model input (dynamically aggregated Context) System Promptrole Instructionstask Memoryrecall Historydialogue Tool Schematools Observationsresults Retrieved DocsRAG ++++++ ↓ produces this turn’s Model Context (input) 🧠 Foundation Model GPT · Claude · Gemini · Llama … called repeatedly inside the loop understanding · reasoning · planning · generation ✅ Output: Final Answer task complete — return the final result 🔧 Output: Tool Call needs a tool — return call instructions & params 🔧 Tool-Call Flow (executed by the Runtime) Model decides to call Dispatcher runs the tool Returns Observation 👁️ Observation (Feedback) = the implementation of the Observe step above writes tool results / feedback back to Runtime Context — updating state / memory / history as the next turn’s input Legend Control Flow Data Flow Key Concepts Closed-Loop Iteration Think→Act→Observe cycle converges until done On-Demand Resources Skills/Workflow/Tools picked at each Act step Context Throughout Runtime Context builds up, aggregated into input Model Called In-Loop Foundation Model runs every turn, drives next step Tool-Result Feedback Observation flows back to Context, drives next turn Core Principles ✓ On-demand resources ✓ State accumulates ✓ Model called often ✓ Forms a closed loop 💡 This is NOT a top-down pipeline — it is a continuously iterating intelligent loop. The Agent completes complex tasks through constant thinking, acting, observing, and adjusting.

Vector graphic · zoom in without any loss · redrawn from the “Agent Runtime / Reasoning Loop” diagram  ·  中文版 (Chinese)