Context engineering: why AI agents get lost in long conversations, and how developers are fixing it

Developers building AI agents with RAG, tools and memory run into the same problem: after a few dozen iterations, the model starts mixing up tools and leaning on old mistakes in the conversation. A new prompt doesn't fix it. What matters is controlling what information reaches the model before each step. This approach is called context engineering.

AI-processed from Habr AI; edited by Hamidun News
Context engineering: why AI agents get lost in long conversations, and how developers are fixing it
Source: Habr AI. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceHabr AI ↗
Editor-in-Chief
Key metric #1The problem doesn't show up right away, but after a few dozen iterations of a conversation with the agent
Symptomsconfusion when choosing tools, use of outdated calls, entrenchment of earlier errors
Key metric #3Context engineering stands apart from prompt engineering, RAG and MCP as a separate discipline of context management

Developers of conversational AI agents with RAG, tools and memory describe the same problem: the system works well in short conversations, but after a few dozen iterations the model starts confusing tools, pulling outdated calls into its answers and relying on an error that once made it into the context. A new discipline, context engineering, is emerging to address this.

How this differs from prompt engineering

The key point is that a new, better prompt does not always solve agent degradation. The issue isn't how the instruction is worded, but which information reaches the model before each next reasoning step. Prompt engineering works with the text of a single request, RAG with retrieving external data, and MCP with standardizing access to tools. Context engineering operates a level above: it manages the entire contents of the model's context window at every step of the conversation, including what goes in, what gets removed and in what order it is presented.

  • The problem doesn't show up right away, but after a few dozen iterations of a conversation with the agent
  • Symptoms: confusion when choosing tools, use of outdated calls, entrenchment of earlier errors
  • Context engineering stands apart from prompt engineering, RAG and MCP as a separate discipline of context management

Why the agent starts making mistakes

As a conversation grows, old tool calls, intermediate results and facts that are no longer valid pile up in the model's context window. The model does not automatically distinguish fresh information from stale: it treats everything in the context as potentially relevant. If an error gets in once, the model may rely on it in later steps, widening the gap between its picture and the actual state of the task.

What this means

As AI agents move from demos to long production workflows with RAG, tools and memory, context management is becoming an engineering discipline of its own, on par with prompt design and model selection. Teams that build explicit rules for selecting and cleaning context before each step get more stable agents in long conversations.

Story

Key Questions Answered

How this differs from prompt engineering?

The key point is that a new, better prompt does not always solve agent degradation. The issue isn't how the instruction is worded, but which information reaches the model before each next reasoning step. Prompt engineering works with the text of a single request, RAG with retrieving external data, and MCP with standardizing access to tools. Context engineering operates a level above: it manages the entire contents of the model's context window at every step of the conversation, including what goes in, what gets removed and in what order it is presented. The problem doesn't

Why the agent starts making mistakes?

As a conversation grows, old tool calls, intermediate results and facts that are no longer valid pile up in the model's context window. The model does not automatically distinguish fresh information from stale: it treats everything in the context as potentially relevant. If an error gets in once, the model may rely on it in later steps, widening the gap between its picture and the actual state of the task.

What this means?

As AI agents move from demos to long production workflows with RAG, tools and memory, context management is becoming an engineering discipline of its own, on par with prompt design and model selection. Teams that build explicit rules for selecting and cleaning context before each step get more stable agents in long conversations.

ZK
Zhemal Khamidun — CPO at Alpina Digital, product manager of AlpinaGPT. Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Unified AI Workspace · Nomad

Test Frontier LLMs & Autonomous Agents in One Workspace

Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.

Try Nomad AI →Launch Nomad Agent
What do you think?
Loading comments…