{
  "id": 12071039,
  "title": "The Four Components of an AI Agent, in One Small TypeScript File",
  "url": "https://urgent.news/2026/10/05/the-four-components-of-an-ai-agent-in-one-small-typescript-file",
  "topic": "ai",
  "section": "AI",
  "published": "2026-10-05T04:25:20.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/zahidhasantonmoy/the-four-components-of-an-ai-agent-in-one-small-typescript-file-d1h"
  },
  "original_language": "en",
  "account": "The four components of an AI agent are the brain, memory, tools, and action loop. The brain is the language model that decides the next step, while memory holds the conversation history and stored facts. Tools allow the agent to interact with the outside world, and the action loop runs the model, executes tools, and returns results.\n\nThe brain is the only model in an AI agent. It receives the system prompt, conversation, tool list, and tool results, and returns text or a request to call a tool. Memory consists of two layers: short-term memory, which is the message history sent with every call, and long-term memory, which is anything written to storage and read back in a later run.\n\nTools are ordinary functions with a description, name, when to use them, and a JSON Schema for inputs. The model never sees the code, only the description, so it should be written like API documentation for a reader who can't ask questions. The action loop sends memory to the brain, and a tool request runs the tool, appends the result to memory, and repeats the loop. Exits include a final answer, a step cap, unrecoverable failures, and human approval.",
  "summary": "Most explanations of AI agents stop at “a model with tools”. That is true, but it doesn't help when your agent forgets a preference, calls the wrong function or loops forever. To debug any of those, you need to know which part is misbehaving. This post continues my series on building agents. The previous one covered LLMs versus agents . The four components of an AI agent An AI agent has four…",
  "key_points": [
    "The brain is the language model deciding the next step in an AI agent",
    "Memory holds conversation history and stored facts in two layers",
    "Tools are ordinary functions with descriptions for outside world interaction"
  ],
  "editors_take": "This breakdown of an AI agent's components clarifies the distinct roles of each part, showing how they work together to enable the agent to interact with its environment and produce results.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}