RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Eruo Fredoline
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /Courses
  5. /Introduction to AI Agents
  6. /Ch. 2
Introduction to AI Agents

02. Agent Architecture

Chapter 2 of 16 · 15 min
KEY INSIGHT

Separating the orchestrator, tool layer, and memory plane makes it possible to swap each component independently and test them in isolation.

Agent architecture determines how the reasoning loop, tool layer, memory, and planning modules fit together. Most production systems separate these concerns cleanly so each part can be tested and replaced independently.

The control layer

At the top lies the orchestrator, sometimes called the "agent controller" or "executor." Its job is to manage the loop, route tool results back to the model, and decide when to stop. Frameworks vary in how much control they hand to the model versus how much is hard-coded.

In simple agents, the model controls everything. In more complex systems, the orchestrator enforces rules: maximum tool calls per turn, timeouts, cost budgets, and early termination conditions.

Tool abstraction

Tools are wrappers around functions that accept typed inputs and return string outputs. Each tool needs a name, a description, and a JSON schema for its arguments. The description is critical—it is the only thing the model uses to decide whether to call the tool.

from typing import Literal

class Tool:
    def __init__(self, name: str, description: str, input_schema: dict):
        self.name = name
        self.payload = description
        self.input_schema = input_schema
    
    def invoke(self, **kwargs) -> str:
        raise NotImplementedError

class CalculatorTool(Tool):
    def __init__(self):
        super().__init__(
            name="calculator",
            description="Evaluate a mathematical expression. Input must be a valid Python expression string.",
            input_schema={
                "type": "object",
                "properties": {
                    "expression": {
                        "type": "string",
                        "description": "A Python mathematic expression like '2**0.5' or '(14 + 8) / 3'"
                    }
                },
                "required": ["expression"]
            }
        )
    
    def invoke(self, expression: str) -> str:
        try:
            result = eval(expression, {"__builtins__": {}}, {})
            return str(result)
        except Exception as e:
            return f"Error: {e}"

Memory layer

Agents need to remember what they have done. Short-term memory holds the current conversation thread. Long-term memory can persist across sessions or store intermediate findings. Memory formats vary from simple message lists to structured vector databases.

Planning layer

Advanced agents include a planning module that breaks high-level goals into subgoals before entering the action loop. This module runs separately from the main reasoning loop.

EXERCISE

Implement a tool registration system where new tools can be added by appending to a dictionary. Write a test that verifies a newly added tool appears in the agent's available tool list.

← Chapter 1
What is an AI Agent?
Chapter 3 →
ReAct Pattern