# From chatbot to a team of agents

> An agent is a language model in a loop: it plans, uses tools, checks results – and keeps going until the goal is reached. Here we take apart how **sub-agents, skills, MCP servers** and a **knowledge graph as memory** work together – and what the model actually “sees” along the way.

- URL: https://www.deepblue-ai.cloud/en/understanding-agents/
- Also available: [de](https://www.deepblue-ai.cloud/de/agenten-verstehen/index.html.md)

## The agent loop

An LLM on its own answers exactly once. An agent works in a loop – until the task is done or it gets stuck.

1. **Gather context**: What do I already know? What's missing? Conversation history, memories and documents are read.
2. **Plan**: Which step gets me closer? Which tool, which sub-agent, which skill?
3. **Act**: Call a tool – for example via an MCP server –, run code, search, or delegate.
4. **Check**: Does the result fit? Is something missing? Then back to step 1 – otherwise answer.

## Who's on the team?

Modern agent systems consist of a handful of clearly separated building blocks. Tell them apart and you'll understand 90 % of product announcements.

- **LLM**: The reasoning engine. Reads the context, writes text – and decides which tool comes next.
- **Orchestrator agent**: The project lead. Breaks the task down, hands work to sub-agents, assembles the results and answers.
- **Sub-agents**: Specialists with their **own context window**, own prompt and own tools. They work in isolation and only return a distilled result – keeping the main context lean.
- **Skills**: Packaged know-how as a folder: a **SKILL.md** with instructions, plus scripts and templates. Up front the agent only knows name and description – the rest is loaded when needed.
- **MCP servers**: The standard socket into existing systems: knowledge graph, CRM, files, tickets. A server describes its tools – any MCP-capable agent can use them.
- **Knowledge graph**: Long-term memory: entities and relationships instead of loose text snippets. The agent reads from it – and writes new insights back.

## Agent, sub-agent, skill, MCP – who does what?

| | What is it? | Own context? | When in the context? | Example |
|---|---|---|---|---|
| **Agent** (orchestrator) | a loop of model + tools | yes – the main context | always | “Answer the user's question” |
| **Sub-agent** | a delegated agent with its own task | yes – separate from the main context | only its result comes back | “Researcher: search the knowledge graph” |
| **Skill** | instructions + scripts (know-how) | no – gets loaded into a context | name/description always, content on demand | “Data analysis: how I build a comparison table” |
| **MCP server** | interface to a system | no – provides tools and data | tool descriptions always, results when called | “knowledge-graph: search, add_memory” |

Rule of thumb: **MCP gives the agent hands, skills give it recipes, sub-agents give it focus.** The three complement each other: a skill can describe *how* to use an MCP tool well – and a sub-agent can use skills and MCP tools without cluttering the orchestrator's context.

## How the agent talks to existing systems

The **Model Context Protocol (MCP)** is an open standard, originally introduced by Anthropic and now developed across vendors. The idea: instead of bolting every system onto every agent individually, you build **one MCP server** – and every MCP-capable agent can use it.

An MCP server wraps a system and offers three things:

- **Tools** – functions the model can call (`kg_search`, `crm_find_requests`, `create_ticket`)
- **Resources** – readable data such as documents or records
- **Prompts** – ready-made templates for typical tasks

Technically it's JSON-RPC: at start-up the agent lists the available tools (`tools/list`). Their descriptions end up in its context – which is why many connected servers cost tokens before any work is done. When it needs a tool, it sends a call:

```json
{
  "jsonrpc": "2.0", "id": 7, "method": "tools/call",
  "params": { "name": "kg_search", "arguments": { "entity": "Project Atlas", "depth": 2 } }
}
```

The result comes back as text or structured data – and becomes part of the context. More details: [MCP explained](https://www.deepblue-ai.cloud/en/mcp-erklaert/).

## Searching with a plan – and with memory

Classic RAG fetches text snippets once and answers. **Agentic RAG** lets the agent decide *where* and *how often* to search – and with a **knowledge graph as long-term memory** it gets smarter with every request.

### Classic RAG

- Question → search once → answer
- Always the same source (usually a vector database)
- No check whether the hits are good enough
- Forgets everything after answering

### Agentic RAG + knowledge graph

- The agent plans: which sources do I need for what?
- Combines knowledge graph, web and existing systems via MCP
- Checks the hits and searches again when something's missing
- Writes lessons learned back into the graph – memory for next time

Why a graph? Relationships like *Project Atlas → uses → handwriting search → requested by → customer B* can be queried and extended precisely. Vector search stays strong for fuzzy similarity – combining both (often called **GraphRAG**) usually works best in practice.

## One run, step by step

One question, two sub-agents, one skill, three MCP servers and a memory. Play the run or step through it – below, the orchestrator's context grows as it goes.

*Interactive demo: [Agent run: sub-agents, skill, MCP & memory](https://www.deepblue-ai.cloud/en/ai-lab/#lab-agent-flow)*

One question, one orchestrator, two sub-agents, one skill and three MCP servers – including a knowledge graph as long-term memory. Play it or step through it.

**Is Project Atlas still worth it? Compare my notes with the current market and give me a recommendation with numbers.**

Steps:

1. **Question** – You ask: “Is Project Atlas still worth it? Compare my notes with the current market and give me a recommendation with numbers.” The question is appended to the context.
2. **Plan** – The orchestrator reads its context – including a memory from earlier conversations (“Markus likes tables”) – and breaks the task down: ① internal knowledge, ② market data, ③ analysis.
3. **Delegate** – A job for the **researcher** sub-agent: “Find everything about Project Atlas.” It starts with its **own, fresh context** – just its prompt, the task and its tools.
4. **MCP · tools/call** – The researcher queries the knowledge graph through its MCP server: entities, relationships and notes around Project Atlas.
5. **Result** – Back come 14 entities and 6 notes – decisions, people, linked technologies. All of it lands in the **researcher's** context, not in the main context.
6. **MCP · tools/call** – A second MCP server connects an **existing system**: from the CRM the researcher fetches the customer requests about the project.
7. **Distillate** – The researcher summarises and returns only **~900 tokens** – instead of 19,000. Its working context is thrown away.
8. **Delegate** – The **web scout** gets the second job: “Current market figures for digital note-taking apps and pens, with sources.” (In practice often in parallel with the researcher.)
9. **Web search** – The web scout searches, opens pages, discards what's useless – in its own context.
10. **Distillate** – Back come five key figures with sources (~1,200 tokens).
11. **Load skill** – For the analysis the orchestrator loads the **data analysis** skill. Until now it only knew its name and description – now the full SKILL.md enters the context (*progressive disclosure*).
12. **Analyse** – The orchestrator follows the instructions: normalises the numbers, builds the comparison table, checks for contradictions between notes and market.
13. **Answer** – You get a table, three key figures and a clear recommendation – with sources.
14. **MCP · memory** – Finally the agent writes **lessons learned** into the knowledge graph: “Markus wants numbers as a table”, “market source X was current and reliable”. Next time they'll already be in the context.

## What the model actually sees

In the end, every request to an LLM is one single, long text: the **context**. Build it yourself – and see why sub-agents, skills and memory are above all one thing: tools to keep that context clean.

*Interactive demo: [Building the context window](https://www.deepblue-ai.cloud/en/ai-lab/#lab-context-window)*

This is what a request to the model really looks like – block by block. Switch parts on and off, change the window size and see what happens when it no longer fits.

Parts:

- **System prompt** (~1500 tokens): Ground rules from the operator: role, tone, safety rules, today's date. Always comes first.
- **Agent configuration & sub-agents** (~2200 tokens): How the agent should work – and which sub-agents exist. For each sub-agent only name, purpose and allowed tools appear here; its own prompt lives in its own context.
- **Skill index** (~400 tokens): For every installed skill only name + description (~50–100 tokens each). That way the agent knows what it could do – without loading everything.
- **Tool definitions (incl. MCP servers)** (~3000 tokens): JSON schemas of all tools. Every connected MCP server brings its tools along – many servers mean many tokens before any work is done.
- **Memories from the knowledge graph** (~600 tokens): Facts from long-term memory that match the request – for example lessons learned from earlier conversations.
- **Conversation history** (~700/turn tokens): Every previous message in this session – questions, answers, tool calls and their results. Grows with every turn.
- **Current question** (~80 tokens): The user's new message.
- **Loaded skill (SKILL.md)** (~2400 tokens): Only when the agent decides it needs the skill does it read the full instructions – typically as the result of a tool call. Further files of the skill (scripts, templates) follow only when needed.
- **Retrieval results (KG + web)** (~2100 tokens): What the researcher and the web scout found. With sub-agents only the distillate arrives; without them all raw data lands in the main context.
- **Reserved for the answer** (~2000 tokens): The answer has to fit into the window too: input + output must not exceed the context limit.

## Three things to remember

- **Context is scarce**: Everything the model should know has to be in the context – and it has a limit. Good agent architecture is mostly context management.
- **Standards beat one-offs**: One MCP server per system, usable by any agent. Skills as folders you can share and version.
- **Memory makes it better**: An agent that writes lessons learned into a knowledge graph doesn't have to work out the same question twice.

## More about agents on deepblue AI

- [What are agents – and what is agentic AI?](https://www.deepblue-ai.cloud/en/agenten-und-agentic-ai/index.html.md): Agentic AI combines LLMs with tools, memory and planning, so that AI doesn't just answer but pursues goals and completes tasks on its own.
- [Agentic AI vs. Agents vs. LLMs: Who Actually Does What?](https://www.deepblue-ai.cloud/en/agentic-ai-vs-agenten-vs-llm/index.html.md): LLM = the language model, agent = a system with goals and actions, agentic AI = LLM + tools + memory + planning. The three often-confused terms, precisely defined.
- [Model Context Protocol (MCP): USB-C for AI Integrations](https://www.deepblue-ai.cloud/en/mcp-erklaert/index.html.md): MCP is an open protocol that standardizes how applications provide tools and context to LLMs – much like USB-C connects devices in a uniform way.
- [Memory, Tools & Skills: The Building Blocks of an LLM Agent](https://www.deepblue-ai.cloud/en/memory-tools-skills/index.html.md): An LLM agent consists of three core components: memory, tools (callable functions) and skills (higher-level capabilities) – and this is how they work together.
- [RAG in Detail: Vectors, Retrieval and Prompt Augmentation](https://www.deepblue-ai.cloud/en/rag-deep-dive/index.html.md): RAG consists of three phases: indexing (texts into vectors), retrieval (finding the most similar texts) and augmentation (passing them to the LLM as context).
- [Memory: How AI remembers conversations](https://www.deepblue-ai.cloud/en/ki-memory-erklaert/index.html.md): AI systems have a short-term memory (the current conversation) and can be given a long-term memory (stored notes via vector databases).
