# What is an AI Agent? The Simple Mental Model & Architecture Guide

A chatbot answers questions in a single turn. An AI agent does real-world work in an autonomous loop.

## The Agent Formula

```
Model + Instructions + Memory + Tools = Autonomous Agent
```

## Chatbots vs. AI Agents

- **Chatbots**: Single-turn (Prompt In → Text Out), static training weights, resets after session, read-only.
- **AI Agents**: Multi-step loop (Goal In → Autonomous Action Loop), live API & database queries, persistent file memory (`MEMORY.md`), executes real-world actions.

## An Agent is a Directory: The 7 Primitives

1. **Instructions (`AGENTS.md` / `instructions.md`)**: The agent's identity, operating constraints, and boundary conditions.
2. **Brain / Model (`agent.ts`)**: Foundation reasoning model (Claude 3.7, GPT-4o, Gemini 2.5).
3. **Reusable Skills (`skills/`)**: On-demand Markdown playbooks loaded only when relevant.
4. **Persistent Memory (`MEMORY.md`)**: Persistent state logs that survive context compaction and restarts.
5. **Tools & MCP (`tools/`)**: Executable functions and Model Context Protocol servers enabling real-world actions.
6. **Channels & Cron Schedules**: Where the agent runs (Slack, Web, CLI, webhooks, or recurring cron jobs).
7. **Human-in-the-Loop (`HITL`)**: Approval gates for sensitive actions (MitID contract signing, payments, destructive writes).

## The 4-Step Execution Loop

1. **Ingest Context**: Loads instructions, active goal, and persistent memory.
2. **Plan & Select Tool**: Model evaluates missing data and emits structured function calls.
3. **Execute & Observe**: Runtime executes external API / database / MCP tool safely.
4. **Persist State & Loop**: Model inspects return payload, updates `MEMORY.md`, and loops until done.
## WebMCP: In-Browser Tools vs. Fragile Actuation

When agents interact with web applications without public REST APIs:
- **DOM Actuation (Playwright, Puppeteer)**: Simulates mouse clicks and keystrokes on raw HTML. Brittle against UI redesigns, high token latency, and risky with raw credentials.
- **WebMCP (W3C / Chrome Proposed Standard)**: Websites declare callable agent tools directly within the browser runtime via:
  1. **Declarative HTML Forms**: `<form toolname="cvr_search">` and `<input toolparam="cvr_query">` with zero JS overhead.
  2. **Imperative JavaScript**: `window.modelContext.registerTool({...})` with strict JSON Schema parameter validation.
- **Danish Infrastructure & MitID**: Runs directly inside the user's authenticated, origin-isolated browser session. Agents assist human workflows without storing or bypassing MitID credentials.

## Connecting Agents to Danish Digital Infrastructure

- **MitID & Human-in-the-Loop**: Safe execution using verified signing APIs (Penneo, MitID Erhverv IdM).
- **Official Open Data**: Querying open public registers (DAWA, Klimadatastyrelsen, Folketinget ODA, Energinet).
- **Business & Finance Automation**: Connecting to cloud accounting (Visma Dinero, e-conomic, Billy).

---
Source: [AgentAccess Guide](https://agentaccess.dk/what-is-an-agent)