# Awesome-Context-Engineering **Repository Path**: wellstudy0806/Awesome-Context-Engineering ## Basic Information - **Project Name**: Awesome-Context-Engineering - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-18 - **Last Updated**: 2025-11-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Awesome Context Engineering
Awesome Context Engineering Cover
## 💬 Join Our Community
WeChat Group

Join our WeChat group for discussions and updates!

Join our Discord server

[![Awesome](https://awesome.re/badge.svg)](https://awesome.re) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![Paper](https://img.shields.io/badge/Paper-Published-green.svg)](https://arxiv.org/abs/2507.13334) > 📄 **Our comprehensive survey paper on Context Engineering is now published!** Check out our latest academic insights and theoretical foundations. A comprehensive survey and collection of resources on **Context Engineering** - the evolution from static prompting to dynamic, context-aware AI systems. ## 📧 Contact For questions, suggestions, or collaboration opportunities, please feel free to reach out: **Lingrui Mei** 📧 Email: [meilingrui25b@ict.ac.cn](mailto:meilingrui25b@ict.ac.cn) or [meilingrui22@mails.ucas.ac.cn](mailto:meilingrui22@mails.ucas.ac.cn) **I WROTE THE WRONG EMAIL ADDRESS IN THE FIRST VERSION OF MY PAPER!!** You can also open an issue in this repository for general discussions and suggestions. --- ## 📰 News - **[2025.07.17]** 🔥🔥 Our paper is now published! Check out ["A Survey of Context Engineering for Large Language Models"](https://arxiv.org/abs/2507.13334) on [arXiv](https://arxiv.org/abs/2507.13334) and [Hugging Face Papers](https://huggingface.co/papers/2507.13334) - **[2025.07.03]** Repository initialized with comprehensive outline - **[2025.07.03]** Survey structure established following modern context engineering paradigms --- ## 🎯 Introduction In the era of Large Language Models (LLMs), the limitations of static prompting have become increasingly apparent. **Context Engineering** represents the natural evolution to address LLM uncertainty and achieve production-grade AI deployment. Unlike traditional prompt engineering, context engineering encompasses the complete information payload provided to LLMs at inference time, including all structured informational components necessary for plausible task completion. This repository serves as a comprehensive survey of context engineering techniques, methodologies, and applications. --- ## 📚 Table of Contents - [Awesome Context Engineering](#awesome-context-engineering) - [💬 Join Our Community](#-join-our-community) - [📧 Contact](#-contact) - [📰 News](#-news) - [🎯 Introduction](#-introduction) - [📚 Table of Contents](#-table-of-contents) - [🔗 Related Survey](#-related-survey) - [🏗️ Definition of Context Engineering](#️-definition-of-context-engineering) - [LLM Generation](#llm-generation) - [Definition of Context](#definition-of-context) - [Definition of Context Engineering](#definition-of-context-engineering) - [Dynamic Context Orchestration](#dynamic-context-orchestration) - [Mathematical Principles](#mathematical-principles) - [Theoretical Framework: Bayesian Context Inference](#theoretical-framework-bayesian-context-inference) - [Comparison](#comparison) - [🌐 Related Blogs](#-related-blogs) - [Social Media \& Talks](#social-media--talks) - [🤔 Why Context Engineering?](#-why-context-engineering) - [The Paradigm Shift: From Tactical to Strategic](#the-paradigm-shift-from-tactical-to-strategic) - [1. Fundamental Challenges with Current Approaches](#1-fundamental-challenges-with-current-approaches) - [Human Intent Communication Challenges](#human-intent-communication-challenges) - [Complex Knowledge Requirements](#complex-knowledge-requirements) - [Reliability and Trustworthiness Issues](#reliability-and-trustworthiness-issues) - [2. Limitations of Static Prompting](#2-limitations-of-static-prompting) - [From Strings to Systems](#from-strings-to-systems) - [The "Movie Production" Analogy](#the-movie-production-analogy) - [3. Enterprise and Production Requirements](#3-enterprise-and-production-requirements) - [Context Failures Are the New Bottleneck](#context-failures-are-the-new-bottleneck) - [Scalability Beyond Simple Tasks](#scalability-beyond-simple-tasks) - [Reliability and Consistency](#reliability-and-consistency) - [Economic and Operational Efficiency](#economic-and-operational-efficiency) - [4. Cognitive and Information Science Foundations](#4-cognitive-and-information-science-foundations) - [Artificial Embodiment](#artificial-embodiment) - [Information Retrieval at Scale](#information-retrieval-at-scale) - [5. The Future of AI System Architecture](#5-the-future-of-ai-system-architecture) - [🔧 Components, Techniques and Architectures](#-components-techniques-and-architectures) - [Context Scaling](#context-scaling) - [Structured Data Integration](#structured-data-integration) - [Self-Generated Context](#self-generated-context) - [🛠️ Implementation and Challenges](#️-implementation-and-challenges) - [1. Retrieval-Augmented Generation (RAG)](#1-retrieval-augmented-generation-rag) - [2. Memory Systems](#2-memory-systems) - [3. Agent Communication](#3-agent-communication) - [4. Tool Use and Function Calling](#4-tool-use-and-function-calling) - [📊 Evaluation Paradigms for Context-Driven Systems](#-evaluation-paradigms-for-context-driven-systems) - [Context Quality Assessment](#context-quality-assessment) - [Benchmarking Context Engineering](#benchmarking-context-engineering) - [🚀 Applications and Systems](#-applications-and-systems) - [Complex Research Systems](#complex-research-systems) - [Production Systems](#production-systems) - [🔮 Limitations and Future Directions](#-limitations-and-future-directions) - [Current Limitations](#current-limitations) - [Future Research Directions](#future-research-directions) - [🤝 Contributing](#-contributing) - [Paper Formatting Guidelines](#paper-formatting-guidelines) - [Badge Colors](#badge-colors) - [📄 License](#-license) - [📑 Citation](#-citation) - [⚠️ Disclaimer](#️-disclaimer) - [📧 Contact](#-contact-1) - [🙏 Acknowledgments](#-acknowledgments) - [Star History](#star-history) - [📖 Our Paper](#-our-paper) --- ## 🔗 Related Survey General AI Survey Papers Context and Reasoning Memory Systems and Context Persistence Survey Benchmarks Neural Memory Architectures Memory-Augmented Transformers Production Memory Systems Graph-based Memory Systems Episodic and Working Memory Conversational Memory Foundational Survey Papers from Major Venues Additional RAG and Retrieval Surveys --- ## 🏗️ Definition of Context Engineering > **Context is not just the single prompt users send to an LLM. Context is the complete information payload provided to a LLM at inference time, encompassing all structured informational components that the model needs to plausibly accomplish a given task.** ### LLM Generation To formally define Context Engineering, we must first mathematically characterize the LLM generation process. Let us model an LLM as a probabilistic function: $$P(\text{output} | \text{context}) = \prod_{t=1}^T P(\text{token}_t | \text{previous tokens}, \text{context})$$ Where: - $\text{context}$ represents the complete input information provided to the LLM - $\text{output}$ represents the generated response sequence - $P(\text{token}_t | \text{previous tokens}, \text{context})$ is the probability of generating each token given the context ### Definition of Context In traditional prompt engineering, the context is treated as a simple string: $$\text{context} = \text{prompt}$$ However, in Context Engineering, we decompose the context into multiple structured components: $$\text{context} = \text{Assemble}(\text{instructions}, \text{knowledge}, \text{tools}, \text{memory}, \text{state}, \text{query})$$ Where $\text{Assemble}$ is a context assembly function that orchestrates: - $\text{instructions}$: System prompts and rules - $\text{knowledge}$: Retrieved relevant information - $\text{tools}$: Available function definitions - $\text{memory}$: Conversation history and learned facts - $\text{state}$: Current world/user state - $\text{query}$: User's immediate request ### Definition of Context Engineering **Context Engineering** is formally defined as the optimization problem: $$\text{Assemble}^* = \arg\max_{\text{Assemble}} \mathbb{E} [\text{Reward}(\text{LLM}(\text{context}), \text{target})]$$ Subject to constraints: - $|\text{context}| \leq \text{MaxTokens} \text{(context window limitation)}$ - $\text{knowledge} = \text{Retrieve}(\text{query}, \text{database})$ - $\text{memory} = \text{Select}(\text{history}, \text{query})$ - $\text{state} = \text{Extract}(\text{world})$ Where: - $\text{Reward}$ measures the quality of generated responses - $\text{Retrieve}$, $\text{Select}$, $\text{Extract}$ are functions for information gathering ### Dynamic Context Orchestration The context assembly can be decomposed as: $$\text{context} = \text{Concat}(\text{Format}(\text{instructions}), \text{Format}(\text{knowledge}), \text{Format}(\text{tools}), \text{Format}(\text{memory}), \text{Format}(\text{query}))$$ Where $\text{Format}$ represents component-specific structuring, and $\text{Concat}$ assembles them respecting token limits and optimal positioning. **Context Engineering** is therefore the discipline of designing and optimizing these assembly and formatting functions to maximize task performance. ### Mathematical Principles From this formalization, we derive four fundamental principles: 1. **System-Level Optimization**: Context generation is a multi-objective optimization problem over assembly functions, not simple string manipulation. 2. **Dynamic Adaptation**: The context assembly function adapts to each $\text{query}$ and $\text{state}$ at inference time: $\text{Assemble}(\cdot | \text{query}, \text{state})$. 3. **Information-Theoretic Optimality**: The retrieval function maximizes relevant information: $\text{Retrieve} = \arg\max \text{Relevance}(\text{knowledge}, \text{query})$. 4. **Structural Sensitivity**: The formatting functions encode structure that aligns with LLM processing capabilities. ### Theoretical Framework: Bayesian Context Inference Context Engineering can be formalized within a Bayesian framework where the optimal context is inferred: $$P(\text{context} | \text{query}, \text{history}, \text{world}) \propto P(\text{query} | \text{context}) \cdot P(\text{context} | \text{history}, \text{world})$$ Where: - $P(\text{query} | \text{context})$ models query-context compatibility - $P(\text{context} | \text{history}, \text{world})$ represents prior context probability The optimal context assembly becomes: $$\text{context}^* = \arg\max_{\text{context}} P(\text{answer} | \text{query}, \text{context}) \cdot P(\text{context} | \text{query}, \text{history}, \text{world})$$ This Bayesian formulation enables: - **Uncertainty Quantification**: Modeling confidence in context relevance - **Adaptive Retrieval**: Updating context beliefs based on feedback - **Multi-step Reasoning**: Maintaining context distributions across interactions ### Comparison | Dimension | Prompt Engineering | Context Engineering | |-----------|-------------------|-------------------| | **Mathematical Model** | $\text{context} = \text{prompt}$ (static) | $\text{context} = \text{Assemble}(...)$ (dynamic) | | **Optimization Target** | $\arg\max_{\text{prompt}} P(\text{answer} \mid \text{query}, \text{prompt})$ | $\arg\max_{\text{Assemble}} \mathbb{E}[\text{Reward}(...)]$ | | **Complexity** | $O(1)$ context assembly | $O(n)$ multi-component optimization | | **Information Theory** | Fixed information content | Adaptive information maximization | | **State Management** | Stateless function | Stateful with $\text{memory}(\text{history}, \text{query})$ | | **Scalability** | Linear in prompt length | Sublinear through compression/filtering | | **Error Analysis** | Manual prompt inspection | Systematic evaluation of assembly components | --- ## 🌐 Related Blogs - [The rise of "context engineering"](https://blog.langchain.com/the-rise-of-context-engineering/) - [The New Skill in AI is Not Prompting, It's Context Engineering](https://www.philschmid.de/context-engineering) - [davidkimai/Context-Engineering: "Context engineering is the delicate art and science of filling the context window with just the right information for the next step." ](https://github.com/davidkimai/Context-Engineering) - [Context Engineering is Runtime of AI Agents | by Bijit Ghosh | Jun, 2025 | Medium](https://medium.com/@bijit211987/context-engineering-is-runtime-of-ai-agents-411c9b2ef1cb) - [Context Engineering](https://blog.langchain.com/context-engineering-for-agents/) - [Context Engineering for Agents](https://rlancemartin.github.io/2025/06/23/context_engineering/) - [Cognition | Don't Build Multi-Agents](https://cognition.ai/blog/dont-build-multi-agents) - [从Prompt Engineering到Context Engineering - 53AI-AI知识库|大模型知识库|大模型训练|智能体开发](https://www.53ai.com/news/tishicikuangjia/2025062727685.html) ### Social Media & Talks - [Mastering Claude Code in 30 minutes](https://www.youtube.com/watch?v=6eBSHbLKuN0) - [Context Engineering for Agents](https://www.youtube.com/watch?v=4GiqzUHD5AA) - [Andrej Karpathy on X: "+1 for "context engineering" over "prompt engineering"](https://x.com/karpathy/status/1937902205765607626?ref=blog.langchain.com) - [复旦大学/上海创智学院邱锡鹏:Context Scaling,通往AGI的下一幕](https://mp.weixin.qq.com/s/Knej0qbyr5j5KX_BO7FGew) --- ## 🤔 Why Context Engineering? ### The Paradigm Shift: From Tactical to Strategic The evolution from prompt engineering to context engineering represents a fundamental maturation in AI system design. As influential figures like Andrej Karpathy, Tobi Lutke, and Simon Willison have argued, the term "prompt engineering" has been diluted to mean simply "typing things into a chatbot," failing to capture the complexity required for industrial-strength LLM applications. ### 1. Fundamental Challenges with Current Approaches #### Human Intent Communication Challenges - **Unclear Human Intent Expression**: Human intentions are often unclear, incomplete, or ambiguous when expressed in natural language - **AI's Incomplete Understanding of Human Intent**: AI systems struggle to fully comprehend complex human intentions, especially those involving implicit context or cultural nuances - **Overly Literal AI Interpretation**: AI systems often interpret human instructions too literally, missing the underlying intent or contextual meaning #### Complex Knowledge Requirements Single models alone cannot solve complex problems that require: - **(1) Large-scale External Knowledge**: Vast amounts of external knowledge that exceed model capacity - **(2) Accurate External Knowledge**: Precise, up-to-date information that models may not possess - **(3) Novel External Knowledge**: Emerging knowledge that appears after model training **Static Knowledge Limitations:** - **Static Knowledge Problem**: Pre-trained models contain static knowledge that becomes outdated - **Knowledge Cutoff**: Models cannot access information beyond their training data - **Domain-Specific Gaps**: Models lack specialized knowledge for specific industries or applications #### Reliability and Trustworthiness Issues - **AI Hallucination**: LLMs generate plausible but factually incorrect information when lacking proper context - **Lack of Provenance**: Absence of clear source attribution for generated information - **Confidence Calibration**: Models often appear confident even when generating false information - **Transparency Gaps**: Inability to trace how conclusions were reached - **Accountability Issues**: Difficulty in verifying the reliability of AI-generated content ### 2. Limitations of Static Prompting #### From Strings to Systems Traditional prompting treats context as a static string, but enterprise applications require: - **Dynamic Information Assembly**: Context created on-the-fly, tailored to specific users and queries - **Multi-Source Integration**: Combining databases, APIs, documents, and real-time data - **State Management**: Maintaining conversation history, user preferences, and workflow status - **Tool Orchestration**: Coordinating external function calls and API interactions #### The "Movie Production" Analogy If prompt engineering is writing a single line of dialogue for an actor, context engineering is the entire process of building the set, designing lighting, providing detailed backstory, and directing the scene. The dialogue only achieves its intended impact because of the rich, carefully constructed environment surrounding it. ### 3. Enterprise and Production Requirements #### Context Failures Are the New Bottleneck Most failures in modern agentic systems are no longer attributable to core model reasoning capabilities but are instead **"context failures"**. The true engineering challenge lies not in what question to ask, but in ensuring the model has all necessary background, data, tools, and memory to answer meaningfully and reliably. #### Scalability Beyond Simple Tasks While prompt engineering suffices for simple, self-contained tasks, it breaks down when scaled to: - **Complex, multi-step applications** - **Data-rich enterprise environments** - **Stateful, long-running workflows** - **Multi-user, multi-tenant systems** #### Reliability and Consistency Enterprise applications demand: - **Deterministic Behavior**: Predictable outputs across different contexts and users - **Error Handling**: Graceful degradation when information is incomplete or contradictory - **Audit Trails**: Transparency in how context influences model decisions - **Compliance**: Meeting regulatory requirements for data handling and decision making #### Economic and Operational Efficiency Context Engineering enables: - **Cost Optimization**: Strategic choice between RAG and long-context approaches - **Latency Management**: Efficient information retrieval and context assembly - **Resource Utilization**: Optimal use of finite context windows and computational resources - **Maintenance Scalability**: Systematic approaches to updating and managing knowledge bases Context Engineering provides the architectural foundation for managing state, integrating diverse data sources, and maintaining coherence across these demanding scenarios. ### 4. Cognitive and Information Science Foundations #### Artificial Embodiment LLMs are essentially "brains in a vat" - powerful reasoning engines lacking connection to specific environments. Context Engineering provides: - **Synthetic Sensory Systems**: Retrieval mechanisms as artificial perception - **Proxy Embodiment**: Tool use as artificial action capabilities - **Artificial Memory**: Structured information storage and retrieval #### Information Retrieval at Scale Context Engineering addresses the fundamental challenge of information retrieval where the "user" is not human but an AI agent. This requires: - **Semantic Understanding**: Bridging the gap between intent and expression - **Relevance Optimization**: Ranking and filtering vast knowledge bases - **Query Transformation**: Converting ambiguous requests into precise retrieval operations ### 5. The Future of AI System Architecture Context Engineering elevates AI development from a collection of "prompting tricks" to a rigorous discipline of systems architecture. It applies decades of knowledge in operating system design, memory management, and distributed systems to the unique challenges of LLM-based applications. This discipline is foundational for unlocking the full potential of LLMs in production systems, enabling the transition from one-off text generation to autonomous agents and sophisticated AI copilots that can reliably operate in complex, dynamic environments. --- ## 🔧 Components, Techniques and Architectures ### Context Scaling Position Interpolation and Extension Techniques Memory-Efficient Attention Mechanisms Ultra-Long Sequence Processing (100K+ Tokens) Comprehensive Extension Surveys and Methods Vision-Language Models with Sophisticated Context Understanding Audio-Visual Context Integration and Processing Multi-Modal Prompt Engineering and Context Design CVPR 2024 Vision-Language Advances Video and Temporal Understanding ### Structured Data Integration Knowledge Graph-Enhanced Language Models Graph Neural Networks Combined with Language Models Structured Data Integration Foundational KG-LLM Integration Methods ### Self-Generated Context Self-Supervised Context Generation and Augmentation Reasoning Models That Generate Their Own Context Iterative Context Refinement and Self-Improvement Meta-Learning and Autonomous Context Evolution Foundational Chain-of-Thought Research --- ## 🛠️ Implementation and Challenges ### 1. Retrieval-Augmented Generation (RAG) survey Naive RAG Advanced RAG Modular RAG Graph-Based RAG Agentic RAG Real-Time and Streaming RAG ### 2. Memory Systems Persistent Memory Architecture Memory-Augmented Neural Networks Episodic Memory and Context Persistence Continual Learning and Memory Consolidation Conversational Memory Personalization and Memory Safety and Alignment with Memory Tool Integration and Memory Learning and Reflection ### 3. Agent Communication Survey Agent Interoperability Protocols Structured Communication Frameworks LLM-Enhanced Agent Communication ### 4. Tool Use and Function Calling Foundational Tool Learning Advanced Function Calling Systems Multi-Agent Function Calling --- ## 📊 Evaluation Paradigms for Context-Driven Systems ### Context Quality Assessment Foundational Long-Context Benchmarks Multimodal and Specialized Evaluation RAG and Generation Evaluation ### Benchmarking Context Engineering Synthetic vs. Realistic Evaluation --- ## 🚀 Applications and Systems ### Complex Research Systems Hypothesis Generation and Data-Driven Discovery Automated Scientific Discovery AI for Science Integration and Future Directions Deep Research Applications ### Production Systems Context Engineering as a Core Discipline Enterprise AI Case Studies Enterprise Applications and Infrastructure --- ## 🔮 Limitations and Future Directions ### Current Limitations 1. **Context Window Constraints**: Despite improvements, context length remains a bottleneck 2. **Computational Overhead**: Processing large contexts requires significant resources 3. **Context Coherence**: Maintaining coherence across extended contexts 4. **Dynamic Adaptation**: Real-time context updating challenges ### Future Research Directions 1. **Infinite Context**: Developing truly unlimited context capabilities 2. **Context Compression**: Efficient representation of large contexts 3. **Multimodal Integration**: Seamless integration of diverse data types 4. **Adaptive Context**: Self-optimizing context management 5. **Context Privacy**: Securing sensitive information in context pipelines --- ## 🤝 Contributing We welcome contributions to this survey! Please follow these guidelines: 1. **Fork** the repository 2. **Create** a feature branch 3. **Add** relevant papers with proper formatting 4. **Submit** a pull request with a clear description ### Paper Formatting Guidelines ```markdown
  • Paper Title, Author et al., SOURCE Badge
  • ``` ### Badge Colors - ![arXiv Badge](https://img.shields.io/badge/arXiv-red) `red` for arXiv papers - ![PDF Badge](https://img.shields.io/badge/PDF-blue) `blue` for conference/journal papers - ![GitHub Badge](https://img.shields.io/badge/GitHub-white) `white` for GitHub repositories - ![HuggingFace Badge](https://img.shields.io/badge/HuggingFace-yellow) `yellow` for HuggingFace resources --- ## 📄 License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. --- ## 📑 Citation If you find this survey helpful in your research, please consider citing: ```bibtex @misc{mei2025surveycontextengineeringlarge, title={A Survey of Context Engineering for Large Language Models}, author={Lingrui Mei and Jiayu Yao and Yuyao Ge and Yiwei Wang and Baolong Bi and Yujun Cai and Jiazhi Liu and Mingyu Li and Zhong-Zhi Li and Duzhen Zhang and Chenlin Zhou and Jiayi Mao and Tianze Xia and Jiafeng Guo and Shenghua Liu}, year={2025}, eprint={2507.13334}, archivePrefix={arXiv}, primaryClass={cs.CL}, url={https://arxiv.org/abs/2507.13334}, } ``` --- ## ⚠️ Disclaimer This project is **ongoing** and continuously evolving. While we strive for accuracy and completeness, there may be errors, omissions, or outdated information. We welcome corrections, suggestions, and contributions from the community. Please stay tuned for regular updates and improvements. ## 📧 Contact For questions, suggestions, or collaboration opportunities, please feel free to reach out: **Lingrui Mei** 📧 Email: [meilingrui22@mails.ucas.ac.cn](mailto:meilingrui22@mails.ucas.ac.cn) You can also open an issue in this repository for general discussions and suggestions. --- ## 🙏 Acknowledgments This survey builds upon the foundational work of the AI research community. We thank all researchers contributing to the advancement of context engineering and large language models. --- ## Star History **Star ⭐ this repository if you find it helpful!** [![Star History Chart](https://api.star-history.com/svg?repos=Meirtz/Awesome-Context-Engineering&type=Date)](https://www.star-history.com/#Meirtz/Awesome-Context-Engineering&Date) --- ## 📖 Our Paper **A Survey of Context Engineering for Large Language Models** - **arXiv**: https://arxiv.org/abs/2507.13334 - **Hugging Face Papers**: https://huggingface.co/papers/2507.13334 This comprehensive survey provides the latest academic insights and theoretical foundations for context engineering in large language models.