Answers
What teams ask about memory and context for AI agents
Short, sourced answers to the questions engineering and AI teams ask before they give their agents memory: Claude Code, Codex and Cursor, agent memory, context engineering, AI cost and security.
Claude Code, Codex and Cursor
Why does Claude Code ignore my CLAUDE.md instructions?
Claude Code reads CLAUDE.md as context, not enforced configuration, so instructions slip when the file did not load, runs past about 200 lines, is vague or contradicts another file. Check it with /context, make each rule concrete, and move rules that must always hold into hooks or managed settings.
Read the answerHow does Claude Code memory work?
Claude Code memory is two sets of markdown files loaded at the start of every session: CLAUDE.md files you write, and auto memory notes Claude writes itself under ~/.claude/projects/<project>/memory/. Both are context, not enforced rules, and auto memory stays on the machine where Claude wrote it.
Read the answerHow do I give Claude Code memory that persists between sessions?
Save what should persist into files Claude Code loads at every session start: a project CLAUDE.md for rules, and auto memory for learned notes, which is on by default in local sessions. Run /init to create CLAUDE.md, ask Claude to remember facts, and confirm with /context that both loaded.
Read the answerWhat does Claude Code forget when it compacts a conversation?
When Claude Code compacts, it replaces the conversation with a summary: instructions given only in chat, older tool output and most files Claude read can lose detail, while the system prompt still applies and the project-root CLAUDE.md and auto memory reload from disk. Keep must-survive rules in the project-root CLAUDE.md or a SessionStart hook.
Read the answerHow can a team share one memory in Claude Code?
A team shares Claude Code memory through files committed to the repository: a project CLAUDE.md, .claude/rules/ and project-scoped subagent memory, plus a managed CLAUDE.md that IT deploys. Auto memory is machine-local, so each developer's learned notes stay on that developer's machine unless someone moves them into shared files.
Read the answerHow do I reduce Claude Code token usage?
Clear context between unrelated tasks with /clear and match the model to the job: Anthropic names these the highest-impact habits, because Claude Code sends the full conversation with every request. Also keep CLAUDE.md under 200 lines, lower thinking effort, disable unused MCP servers and send verbose work to subagents.
Read the answerWhat is the difference between CLAUDE.md and AGENTS.md?
CLAUDE.md is the instruction file Claude Code loads in every session; AGENTS.md is an open Markdown format that OpenAI Codex and Cursor read natively. Since v2.1.277, Claude Code also reads AGENTS.md, but by default only when no CLAUDE.md exists. To share one file, keep AGENTS.md and import it with @AGENTS.md.
Read the answerDoes OpenAI Codex remember context between sessions?
Only partly by default. OpenAI Codex rereads your AGENTS.md files at the start of every run and can reopen a saved chat with codex resume, but local Codex memories, which learn from past chats, are off by default. Turn them on with memories = true under [features] in config.toml.
Read the answerWhy does Cursor ignore my rules?
Cursor usually skips a rule because of how it is set up: a plain .md file in .cursor/rules instead of .mdc, a rule type without a description or with a glob that matches nothing, or a feature such as Tab completion or Bugbot where rules do not apply. A loaded rule is still guidance; use hooks for hard limits.
Read the answerWhat is an MCP memory server?
An MCP memory server gives an AI agent tools to save and look up knowledge through the Model Context Protocol, so Claude Code, Codex or Cursor can reuse facts across sessions. The official reference server stores a knowledge graph in a local JSONL file and exposes 9 tools; the agent recalls only when it calls them.
Read the answerCan Claude Code, Codex and Cursor share one memory?
Not out of the box: Claude Code, OpenAI Codex and Cursor each keep their own memory and rules. They do share two open standards, AGENTS.md for instructions and the Model Context Protocol for tools, so you can build one shared memory from those, or connect a runtime that plugs into all three.
Read the answer
Agent memory
What is memory for AI agents?
Memory for AI agents is information stored outside the language model and loaded back into its context window on later turns or sessions, because the model keeps nothing between calls. The CoALA framework (Sumers et al., 2023) splits it into working memory plus three long-term types: episodic, semantic and procedural.
Read the answerWhat is the difference between agent memory and RAG?
RAG (Lewis et al., 2020) retrieves passages from a document index that people maintain, to ground an answer. Agent memory is a store the agent writes to as it works, keeping experience, decisions and corrections across turns and sessions. RAG reads what the documents say; memory keeps what the agent learned. Most production agents use both.
Read the answerShould AI agent memory use a vector database or a graph database?
Use a vector database when your agent needs text similar in meaning to the current request, a graph database when it must follow relationships between entities, and both when it needs both. Microsoft researchers' GraphRAG paper (2024) found vector retrieval works for questions answered by a few records, not for whole-dataset questions.
Read the answerHow do multiple AI agents share memory?
Multiple AI agents share memory through a store outside every agent's context window that all of them can read and write, plus rules for who writes what. Anthropic's multi-agent Research system saves the lead agent's plan to memory and has subagents pass lightweight references to stored work instead of copying it.
Read the answerHow do I choose a memory layer for AI agents?
Choose a memory layer by who must share it, who writes to it, how it handles stale and conflicting facts, how much context it adds per turn and where the data lives. For one person in one tool, built-in memory such as Claude Code's is often enough; several agents, tools and teams need memory outside one vendor's tools.
Read the answerWhat happens when an AI agent's memory contains conflicting information?
When an agent's memory holds conflicting facts, the model usually sees both and has no built-in way to tell which is current, so it may act on either. Claude Code's documentation says Claude "may pick one arbitrarily". The fix is a step before the model call that tracks sources, marks superseded facts and shows real disagreements.
Read the answer
Context engineering and AI cost
What is context engineering for AI agents?
Context engineering is the practice of choosing which tokens an AI agent's model sees on every call: instructions, tools, retrieved data, tool results and message history. Anthropic describes the goal as the smallest possible set of high-signal tokens for the desired outcome, because accuracy falls as context grows.
Read the answerWhat is context rot?
Context rot is the drop in a language model's accuracy and recall as the number of tokens in its context window grows. A July 2025 Chroma report that tested 18 models found performance degrading with input length even on simple tasks, so what an agent sees matters more than how much fits.
Read the answerDoes a bigger context window make AI agents more accurate?
No. A bigger context window raises how many tokens an agent can hold, up to 1M on current Claude models such as Claude Opus 5.5, but not how well the model uses them. In a July 2025 test, focused prompts scored higher than full ones across all models tested, so curate the context instead of filling it.
Read the answerHow can I reduce AI agent token costs without switching models?
Reduce AI agent token costs without switching models by paying less per token and sending fewer tokens. Anthropic bills prompt cache reads at 0.1 times the base input price on most Claude models (0.05 times on Opus 5.5 and Sonnet 5.5), its Batch API takes 50 percent off asynchronous work, and pruning what each turn sends cuts the bill at the source.
Read the answerHow do I reduce hallucinations in AI agents?
Reduce hallucinations in AI agents by grounding answers in quoted sources, letting the agent say "I don't know", keeping stale and conflicting facts out of its context, and checking claims before the agent acts. Anthropic's guide covers the grounding and checking techniques and warns that they reduce hallucinations but do not remove them entirely.
Read the answer
Security and deployment
What is a pluggable runtime for AI agents?
A pluggable runtime for AI agents attaches to the harness you already run, such as Claude Code, OpenAI Codex or Cursor, and decides on every turn what the model sees, without hosting the agent or changing the model. A hosted agent runtime, such as Amazon Bedrock AgentCore Runtime, instead runs your agent code in the cloud.
Read the answerWhat should security teams check before AI agents get access to company knowledge?
Check eight things before AI agents reach company knowledge: data location, credentials and access scope, copies versus pointers, retention and training use, tenant isolation, deployment options, a per-turn audit trail, and controls for prompt injection and excessive agency, which the OWASP Top 10 for LLM Applications 2025 lists as LLM01 and LLM06.
Read the answerHow do I audit what an AI agent saw and did?
Keep one record per turn that links what the agent read, what entered its context window, which tools it called, who approved each action and what it wrote back. Model provider logs and transcripts miss most of this. Store the record append-only, hash-chained and signed, out of reach of the agent.
Read the answer