
Enterprise architect Dominikย Tomicevicย shares recent best practice about a fast-moving area in AI developmentย
Prompt engineeringย is powerful but not enough on itsย ownโcontextย is the critical factor here. Graph-based approaches, particularlyย GraphRAG, areย emergingย as the next evolution, moving beyond vanilla prompt engineering to what is now called context engineering.ย
Hereโsย the logic, starting with something that sounds, and is, problematicโcontext rot. Context rot is an emerging challenge in enterprise AI, occurring when a modelโs understanding of context degrades over time or across tasks. Repeated queriesย exacerbateย the problem, as outdated or poorly linked context can dominate responses, slowly eroding trust in the AI system.ย
Large language models (LLMs) rely heavily on curated contextโstructured data, knowledge graphs, and other inputsโto generate reliable outputs. But as information accumulates, shifts, or becomes fragmented across multiple sources, the context available to the model can become diluted or inconsistent, reducing the accuracy and relevance of its responses.ย
This leads to outputs that are less precise, more prone to hallucinations, and often disconnected from the underlying business reality.ย Multipleย studiesย confirm that beyond a certain context size, AI model accuracy tends to decline.ย Essentially, thereย comes a point where adding more context canย actually reduceย model performance.ย
Surely more context is better?ย ย
To some, this might seem counterintuitive: surely the more a model โknows,โ the better it should be at making inferences?ย But,ย weโreย dealing with AI here, not the human brain. With current architectures, context windows have limitsโan LLMโs attention mechanism simply cannot interact with every token inย a very largeย dataset.ย
As a result, the larger the context window, the more opportunities for error or misinterpreted information. In a business setting,ย thatโsย a real problem in terms of valid inferences: the model may focus on irrelevant facts, and the extra context canย actually diluteย the relevance of its outputs.ย
Bottom line: on their own, an LLM cannot inherently understand an organizationโs data schema or the implicit relationships between entities. This knowledge must be explicitlyย modeledโoften through a combination of knowledge graphs and curated datasets. Without this structure, even the most advanced LLM can generate invalid queries or misinterpret the data.ย
To be honest, I see this every day with customers trying, and often struggling, to build non-trivial AI applications. The real solution is to focus on relevance, not volume. Counterintuitive as it may seem, the key is to provide theย minimumย necessary context to solve the task at hand.ย
Giving an LLM too many tools or access to excessive datasets can lead to tool overload: the model might select the wrong tool, misuse it, or generate inaccurate outputs. We need ways to limit access to only the essential tools and data for a given task, which may involve training models on tool-specific APIs or query languages. Without this discipline, even well-curated data may produce inaccurate results.ย
Why you need to think bigger than โpromptsโย
If the search space is appropriately constrained, then, even if that sounds counterintuitive, it becomes highly effective. This is where we need to move beyond the ideas of prompts. While prompts work well for simple ChatGPT-level tasks, real enterprise AI requires engineering the right context rather than endlessly refining prompts. The focus should shift from prompt finesse to deliberately designing the search space the modelย operatesย within.ย
Asย youโllย quickly see, thisย isnโtย work that happens in the question boxโitโsย a programming task focused on what information the model isย actually ingesting. Effective context engineering relies on both quantitative and qualitative metrics to find the right balance. Like prompt engineering, it involves iterating on what information helps the model produce useful, reliable outputsโbut the iteration happens in code, not text.ย
What should be happening at the code level? A key computer science concept to guide us here is recursion. The goal is to structure and filter context by recursively summarizing relevant portions of a graph-structured dataset. YesโI deliberately smuggled in the word โgraphโโbecause best practices suggest that basic RAGย isnโtย enough to handle this recursion elegantly. Instead, we need the next evolution of Retrieval-Augmented Generation:ย GraphRAG.ย
First developed at Microsoft Research,ย GraphRAGย is our friend here asย itโsย a very effectiveย way of structuring and filtering context across graph-structured datasets. And yes, we want graphs, not something like SQL, for two key reasons. First, graphs are better suited to capture the nuances of relationships in complex information. Second, they allow complex tasks to be broken into smaller subtasks, each of which can be handled separately, with results aggregated to form a coherentย final answer.ย
Thatโsย a nicely modular approach that reduces context complexity and ensures that the modelโs reasoning is aligned with business logic. This makesย GraphRAGย an excellent tool for context engineering: it allows us to avoid loading the entire graphโor even a large subgraphโinto the modelโs context, and instead:ย
- expanding from possible relevant nodes out of points that areย possible contextย entriesย
- summarizing at each expansion step, and so constantly reminding the LLM to really focus on the task at handย
- trimming irrelevant informationย
- and ensuring that the final context is concise and tailored for the specific user task.ย
Top context engineer tipsย
From our experience helping organizations start down this path, several practical lessons about context engineering haveย emerged.ย
One: It really helps to pre-process the LLM with smaller amounts of context at a time, preventing it from becoming overwhelmed. Two: Combining prompt engineeringโto remind the model of the task and the need for concise, relevant answersโwith step-by-step or recursive summarization can significantly improve context quality and reduce that dreaded context rot.ย ย
Three: For complex workflows, context engineeringย isnโtย just about providingย the right data, it also involves dynamically selecting which tools and datasets are relevant for each step. For example, a model might need to fetch the latest financial metrics via a specialized query tool while simultaneously consulting a market sentiment model. Effective orchestration is essential to ensure that eachย submodelย only ever sees the context it needs.ย
In sum, context rot isย a real challengeย when working with large context windows in LLMs. Developers tackling this issue consistently report that the most effective mitigation involves structuring, filtering, summarizing, and continuously testing context so that only essential information enters the modelโs working memory.ย
Mitigating context rot requires deliberate engineering: curating high-quality context, segmenting complex tasks, dynamically managing tool access, andย leveragingย knowledge graphs to ensure the model always sees the most relevant, well-structured information.ย
Without these context-aiding steps, AI workflows risk producing unreliable insights, no matter how large or sophisticated the underlying model is. Growing evidence shows that structuring enterprise data as graphs and applying RAG methods enables AI to reason effectively over large datasets, helping to overcome the limitations of context windows.ย
The takeaway for anyone trying to make AI work for their company is that the days of clever prompts are over. The best path forward with LLMs lies in structuring data,ย leveragingย knowledge graphs, and curating tool accessโproviding your model with the ideal context it needs to reason accurately and reliably across complex enterprise workflows. Doing so ensures the AI produces insights that truly help the business move the needle.ย
Dominik Tomicevicย is CEO and Co-founder ofย Memgraph, a high-performance, in-memory graph database that serves as a real-time context engine for AI applications, powering enterprise solutions with richer context, sub-millisecond query performance, and explainable results that developers can trust.




