Context engineering is the discipline of deciding what information, tools, memory, retrieval results, instructions, examples, and intermediate state should enter an LLM’s limited context window for a specific step. Anthropic frames it as the work of curating and maintaining the optimal set of tokens during inference, with the goal of finding the smallest high-signal context that maximizes the desired behavior (Anthropic Engineering).
This is broader than prompt engineering. LlamaIndex describes context engineering as the art and science of filling the context window with the right information for the next step, including system prompts, user input, chat history, long-term memory, retrieved knowledge, tool definitions, tool responses, structured outputs, and workflow state (LlamaIndex). LangChain makes the same distinction operationally: model context controls what the LLM sees in a single call, tool context controls what tools can read and write, and lifecycle context controls what happens between model and tool calls, such as summarization, guardrails, and logging (LangChain Docs).
Keep this in Trial because the practice is becoming essential for production agents, but the patterns are still maturing. Teams need measurable strategies for retrieval, compression, memory promotion, tool selection, context isolation, and evaluation before context engineering becomes a repeatable platform capability rather than a collection of ad hoc prompt and RAG tricks.
Poor context selection can make a capable model behave like a weak one. LangChain notes that agent failures often come from the wrong context being passed to the model rather than the model being incapable, and warns that too many tools can overload context and increase errors (LangChain Docs).
Context growth creates quality, latency, and cost trade-offs. Anthropic warns about context pollution and relevance issues, while LlamaIndex emphasizes that the context window has a literal size limit and that workflows need compression, ordering, and focused steps to avoid overcrowding the model’s working memory (Anthropic Engineering, LlamaIndex).
Memory systems can decay if they store everything. Weaviate argues that production agents need selective memory promotion and maintenance, including pruning, merging duplicates, deleting outdated facts, and replacing long transcripts with compact summaries; otherwise long-term memory becomes noisy and retrieval quality degrades (Weaviate).
Compaction can also remove the wrong details. Anthropic recommends tuning compaction prompts on complex traces, starting with recall and then improving precision, because overly aggressive summaries can drop subtle context whose importance only becomes apparent later (Anthropic Engineering).
Finally, context engineering can become vendor-specific platform glue if it is not documented and measured. LangChain recommends starting simple, testing context features incrementally, monitoring model calls, token usage, and latency, and documenting what context is passed and why (LangChain Docs).
Trial context engineering as a dedicated discipline for production AI systems, especially agents, coding assistants, research workflows, RAG products, and customer-facing copilots. Start by mapping every model call to its context inputs: system instructions, user state, conversation history, retrieved records, tool definitions, tool outputs, structured response schema, memory, and lifecycle middleware.
Operationalize it with a small set of platform patterns: just-in-time retrieval instead of eager context stuffing, dynamic tool selection, message trimming or summarization, durable memory with explicit promotion rules, structured note-taking for long-horizon tasks, and sub-agents for isolated research or execution contexts. Measure success with task-level evals, retrieval precision and recall, token usage, latency, tool error rates, compaction loss, and regression tests for known context failures.
Do not treat bigger context windows as the solution by themselves. Larger windows can reduce pressure, but production systems still need ranking, compression, provenance, access control, stale-memory cleanup, and observability around what context was supplied to each model call.