What your agent actually sees: the six parts of its context
Before an AI agent answers, it reads a single block of text called its context. Six things go into it: its instructions, the descriptions of its tools, saved memory, the chat so far, documents it found, and results returned by tools. To the model, all of it is just text, so whatever you put there can shape, leak or confuse the answer.
Everyday analogy
A new employee's desk on their first morning: the job description, the list of systems they can log into, notes from the last person, the email thread, files from the shared drive and printouts from the database. If the desk contains the wrong files or a password on a sticky note, things go wrong.
Example
A support agent answers a refund question. Its instructions say refunds over $200 need approval; its memory still holds a customer's old address; RAG finds two versions of the refund policy (5–7 days and 30 days); and the order tool returns the full card number. Each of these can cause a wrong or unsafe reply.
| Part | What it is | What to check |
|---|---|---|
| 1. Instructions | The system prompt: role, rules, tone | Never put passwords or API keys in it; it goes in with every message |
| 2. Tools | Every tool's name and description | Only give tools the job needs; remove risky ones like "export all" |
| 3. Memory | Facts saved from earlier chats | Expire old or wrong facts; decide what is kept and for how long |
| 4. The chat | The conversation so far | When the window fills, the oldest messages drop out; summarise long chats |
| 5. Found documents | Passages retrieved by RAG | Remove outdated versions so the agent doesn't see conflicting answers |
| 6. Tool results | Data returned by tools and APIs | Return only the fields needed; mask card numbers and personal data |
Security tip: because documents and tool results are also just text, hidden instructions inside them can try to hijack the agent (prompt injection). Treat everything the agent reads from outside as data, not as orders.
Try it yourself
About 15 minAudit an agent's context
- Imagine a customer-support agent for an online shop.
- List what goes into each of the six parts of its context.
- For each part, write one risk and one fix (e.g. tool results: mask card numbers).
What you should see: A short checklist that would make a real agent safer and more accurate.
Use any free AI chatbot (ChatGPT, Claude, Gemini or Copilot). Never paste private or confidential information.