https://github.com/Denis2054/Context-Engineering-for-Multi-Agent-Systems
Save thousands of lines of code by building universal, domain-agnostic Multi-Agent Systems (MAS) through high-level semantic orchestration. This repository provides a production-ready blueprint for the Agentic Era, allowing you to replace rigid, hard-coded workflows with a dynamic transparent Context Engine that provides 100% transparency.
https://github.com/Denis2054/Context-Engineering-for-Multi-Agent-Systems
agentic-ai agentic-rag context-engineering deterministic-ai gpt-5-api mcp model-context-protocol multi-agent-systems pinecone rag semantic-analysis semantic-blueprints universal-context-engine
Last synced: 13 days ago
JSON representation
Save thousands of lines of code by building universal, domain-agnostic Multi-Agent Systems (MAS) through high-level semantic orchestration. This repository provides a production-ready blueprint for the Agentic Era, allowing you to replace rigid, hard-coded workflows with a dynamic transparent Context Engine that provides 100% transparency.
- Host: GitHub
- URL: https://github.com/Denis2054/Context-Engineering-for-Multi-Agent-Systems
- Owner: Denis2054
- License: mit
- Created: 2025-09-01T16:39:14.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2026-04-11T13:28:00.000Z (15 days ago)
- Last Synced: 2026-04-11T14:24:00.630Z (15 days ago)
- Topics: agentic-ai, agentic-rag, context-engineering, deterministic-ai, gpt-5-api, mcp, model-context-protocol, multi-agent-systems, pinecone, rag, semantic-analysis, semantic-blueprints, universal-context-engine
- Language: Jupyter Notebook
- Homepage: https://www.linkedin.com/in/denis-rothman-0b034043/
- Size: 7.48 MB
- Stars: 208
- Watchers: 3
- Forks: 65
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.MD
- License: LICENSE
- Citation: CITATION.cff
Awesome Lists containing this project
- awesome - Context Engineering for Multi-Agent Systems - Build universal domain-agnostic multi-agent systems through high-level semantic orchestration with a dynamic context engine providing 100% transparency. ([Read more](/details/context-engineering-for-multi-agent-systems.md)) `Multi Agent` `Context Engineering` `Orchestration` (Machine Learning & AI)
README
# Context Engineering for Multi-Agent Systems
[](https://opensource.org/licenses/MIT)
Move beyond prompting to build a Context Engine in a transparent architecture of context and reasoning

[**đď¸âśď¸**](https://denis2054.github.io/Context-Engineering-for-Multi-Agent-Systems/media/player.html) **In 21stâcentury Agentic AI, NaturalâLanguageâProgrammed LLMs are the execution agents, and the domainâagnostic dualâRAG MAS is the environment they operate in.**
This repository provides a production-ready blueprint for the Agentic Era, allowing you to replace rigid, hard-coded workflows with a dynamic, **transparent**, **observable**, and **sovereign** **Context Engine**. By building universal, domain-agnostic Multi-Agent Systems through high-level semantic orchestration, you can save thousands of lines of code while maintaining 100% observability.
Copyright 2025-2026, Denis Rothman. Last updated: April 11, 2026
See the Changelog for updates, fixes, and upgrades(past, present, coming).
Save thousands of lines of code by building universal, domain-agnostic Multi-Agent Systems (MAS) using the ultimate new programming language:
[**đ°ď¸ View Software Evolution Timeline**](https://denis2054.github.io/Context-Engineering-for-Multi-Agent-Systems/media/index.html)
đŹ March 14, 2026 update of the January 24, 2026 Release: **OpenAI gpt-5.4 implemented** in the Universal Context Engine
**Sovereign Universal Context Engine**: A new **Glass Box Context Engine** implementation - `Chapter10/Universal_Context_Engine.ipynb` and `Chapter10/Universal_Context_Engine_UI.ipynb`- demonstrating **domain-agnostic architecture** by running *cross-domain* use cases on the same core.
**Token Analytics**: engine.py and the Dashboard provide rigorous transparency into token usage (Input, Output, Difference) for cost and verbosity analysis.
### đ§ LLM API Update
For a detailed list of affected notebooks and all changes, see the âĄď¸ [CHANGELOG.md](./CHANGELOG.md)
**LLM API update:**
Several notebooks have been upgraded to use **GPTâ5.1** along with the latest OpenAI library standards.
These improvements provide *better performance, lower reasoning latency,* and more reliable handling of structured agent outputs.
This update also includes fixes to the **Moderation API**, ensuring safer and more robust processing of multiâagent interactions.
**Alternative: Sovereign AI Without External LLM APIs:**
If you prefer not to rely on an external LLM API, a full **DeepSeekâR1 Sovereign AI Implementation Guide and the Hardware benchmark notebook** (with code) is available:
âĄď¸ **[DeepSeekâR1 Sovereign AI Guide](https://github.com/Denis2054/Context-Engineering-for-Multi-Agent-Systems/blob/main/sovereign_ai/README.md)**
đ NEW: Interactive Trace Dashboard
Available in the Context Engine Room of Chapters 8 & 9: Visualize agent reasoning with our new HTML-based trace renderer.
Denis Rothman
âââââ
âââââ
âââââ
âââââ
About the book
.
Generative AI is powerful, yet often unpredictable. This guide shows you how to turn that unpredictability into reliability by thinking beyond prompts and approaching AI like an architect. At its core is the Context Engine, a glass-box, multi-agent system youâll learn to design, strengthen, and apply across real-world scenarios.
Written by an AI guru and author of various cutting-edge AI books, this book takes you on a hands-on journey from the foundations of context design to building a fully operational Context Engine. Instead of relying on brittle prompts that give only simple instructions, youâll begin with semantic blueprints that map goals and roles with precision, then orchestrate specialized agents using the Model Context Protocol (MCP). As the engine evolves, youâll integrate memory and high-fidelity retrieval with citations, implement safeguards against data poisoning and prompt injection, and enforce moderation to keep outputs aligned with policy. Youâll also harden the system into a resilient architecture, then see it pivot seamlessly across domains, from legal compliance to strategic marketing, proving its domain independence.
By the end of this book, youâll be equipped with the skills needed to engineer an adaptable, verifiable architecture you can repurpose across domains and deploy with confidence.
Key Architecture Highlights
-
Glass Box Architecture: Provides 100% observability into agent reasoning through interactive trace dashboards and detailed execution logs. -
Universal Context Engine: A domain-agnostic core that runs cross-domain use cases (e.g., Legal and Marketing) without changing a single line of code. -
Dual High-Fidelity RAG: Implements research agents(dual: instructions and facts) with automated input sanitization and source-verifiable citations to ensure accuracy and defense. -
Telemetryâdriven context layers: Continuous ingestion and structuring of environmental signals that form the dynamic operational context for multiâagent reasoning. -
Protocol-Driven: Orchestrates specialized agents using the Model Context Protocol (MCP) for seamless, modular multi-agent workflows. -
Token & Cost Analytics: Integrated tracking of input/output tokens to monitor cost-efficiency and model verbosity at every step.
Key Learnings
- Develop memory models to retain short-term and cross-session context
- Craft semantic blueprints and drive multi-agent orchestration with MCP
- Implement high-fidelity RAG pipelines with verifiable citations
- Apply safeguards against prompt injection and data poisoning
- Enforce moderation and policy-driven control in AI workflows
- Repurpose the Context Engine across legal, marketing, and beyond
- Deploy a scalable, observable Context Engine in production
đŁ Upcoming Live Workshop Session â Cohort 2

Stop tinkering with prompts. Start engineering context. Most AI implementations fail at scale because they rely on black-box prompting â sending a request into the void and hoping for a coherent reply. Following the success of our January session, **Cohort 2** of this hands-on workshop is now open. We move beyond simple instructions to build a Context Engine: a transparent, glass-box architecture where agents don't just guess â they execute a precise, structured plan.
**April 25, 2026 ¡ 09:00 AM EST ¡ Live & Virtual**
â The Levels of Efficient Context ¡ â Dual RAG ¡ â Agent Orchestration
đ [Register on Eventbrite](http://bit.ly/4my96D1)
đĽ Deep Dive: Architecture â Context â Agents â Code
This recorded session walks through the entire stack behind the sentence:
**âIn 21stâcentury Agentic AI, NaturalâLanguageâProgrammed LLMs are the agents, and the domainâagnostic dualâRAG MAS is the environment they operate in.â**
The deep dive unpacks each term stepâbyâstep:
- **21stâcentury Agentic AI** â why agents are naturalâlanguageâprogrammed programs
- **LLMs as agents** â how reasoning, memory, and protocols turn models into actors
- **Domainâagnostic Context Engine** â the universal core that runs any use case
- **DualâRAG MAS** â the twoâchannel research architecture (instructions + facts)
- **Environment design** â how telemetry, context layers, and MCP orchestrate agents
- **Full drillâdown to code** â notebooks, pipelines, and execution traces
- **Full climb back up** â how the code reâforms the architecture endâtoâend
[đş**Watch the full deep dive on LinkedIn**](https://www.linkedin.com/posts/denis-rothman_ai-agenticera-contextengineering-activity-7424026873652850688-eXw8)
If you are an architect or lead looking for:
â
ROI & Domain Agnosticism logic
â
Glass-Box Observability traces
â
Sovereign RAG blueprints
Join the engineering discussion here: [**Link to GitHub Discussion**](https://github.com/Denis2054/Context-Engineering-for-Multi-Agent-Systems/discussions/2)
Chapters: From Architecture to code
| Chapters | Colab | Kaggle | Studio Lab |
| :-------- | :-------- | :------- | :-------- |
| **Chapter 1: From Prompts to Context: Building the Semantic Blueprint** | | | |
|
- SLR.ipynb
|
|
|
|
- Use_Case.ipynb
|
|
|
| **Chapter 2: Building a Multi-Agent System with MCP** | | | |
|
- MAS_MCP.ipynb
|
|
|
|
- MAS_MCP_control.ipynb
|
|
|
| **Chapter 3: Building the Context-Aware Multi-Agent System** | | | |
|
- RAG_Pipeline.ipynb
|
|
|
|
- Context_Aware_MAS.ipynb
|
|
|
| **Chapter 4: Assembling the Context Engine** | | | |
|
- Context_Engine.ipynb
|
|
|
| **Chapter 5: Hardening the Context Engine** | | | |
|
- Context_Engine_MAS_MCP.ipynb
|
|
|
|
- Context_Engine_Pre_Production.ipynb
|
|
|
| **Chapter 6: Building the Summarizer Agent for Context Reduction** | | | |
|
- Context_Engine_Content_Reduction.ipynb
|
|
|
| **Chapter 7: High-Fidelity RAG and Defense: The NASA-Inspired Research Assistant** | | | |
Domainâagnostic Universal Context Engine architectures are powered by environmentâingestion agents illustrated in `High_Fidelity_Data_Ingestion.ipynb`that dynamically construct the operational context for complex, crossâdomain agentic systems.
|
- High_Fidelity_Data_Ingestion.ipynb
|
|
|
Domainâagnostic Universal Context Engine architectures are also driven by MASâRAGâContext Engines, illustrated in `NASA_Research_Assistant_and_Retrocompatibility.ipynb`, which combine highâfidelity retrieval, defense, and multiâagent reasoning into a unified operational environment.
|
- NASA_Research_Assistant_and_Retrocompatibility.ipynb
|
|
|
| **Chapter 8: Architecting for Reality: Moderation, Latency, and Policy-Driven AI** | | | |
|
- Data_Ingestion.ipynb
|
|
|
|
- Legal_assistant_Explorer.ipynb
|
|
|
| **Chapter 9: Architecting for Brand and Agility: The Strategic Marketing Engine** | | | | |
|
- Data_Ingestion_Marketing.ipynb
|
|
|
|
- Marketing_Assistant.ipynb
|
|
|
| **Chapter 10: The Blueprint for Production-Ready AI** | | | |
The Universal Context Engine provides full **architectural sovereignty** through *glassâbox reasoning*, *verifiable multiâagent traces*, and complete *control over memory*, *dual RAG*, *moderation*, and *orchestration*. Its **domainâagnostic core** can be deployed in restricted, *missionâcritical*, *strategic environments* where transparency, auditability, and **sovereignty are mandatory**.
The `Universal_Context_Engine.ipynb` version runs a list of explicit scenarios for batch processing.
|
- đŹUniversal_Context_Engine.ipynb - March 14, 2026 update of the January 24, 2026 Release: **OpenAI gpt-5.4**
|
|
|
The `Universal_Context_Engine_UI.ipynb`provides an IPython interface for interactive sessions that highlights how the industry is converging toward domainâagnostic, environmentâdriven agentic systems built on transparent, contextârich architectures.
|
- đŹUniversal_Context_Engine_UI.ipynb - March 14, 2026 update of the January 24, 2026 Release: **OpenAI gpt-5.4**
|
|
|

## đĄď¸ Sovereign AI & Open-Source Engineering
For organizations requiring **100% data privacy** and **zero external API dependencies**, this repository provides a dedicated **Sovereign Path**.
By leveraging highâreasoning openâsource models like **DeepSeekâR1**, you can achieve **industrialâgrade performance** entirely on your own infrastructure.
### đ Key Highlights of the Sovereign Path
âĄ**Performance**: Benchmarked at **~9.75 seconds** on **NVIDIA H100** hardware for complex multiâstep reasoning.
đ**Transparency**: Provides **100% GlassâBox observability** using local reasoning traces (`` blocks).
đ ď¸**Independence**: Fully disconnected execution with **no vendor lockâin** and **no unpredictable API costs**.
[Read the DeepSeek-R1 Sovereign AI Guide and the Hardware benchmark notebook](https://github.com/Denis2054/Context-Engineering-for-Multi-Agent-Systems/blob/main/sovereign_ai/README.md)
Launch the DeepSeekâR1 Sovereign AI Guide in Google Colab
Requirements for this book
Before running the code, ensure your development environment is properly configured.
### â
Prerequisites
- **Python:** Version 3.10+
- **Environment Options:** Google Colab, Kaggle, or Local
Requirements for this book
Before running the code, ensure your development environment is properly set up. All hands-on chapters use reproducible Python-based environments, tested in **Google Colab** and **VS Code**.
> **A Note on Latency:** The Context Engine built in this book and repository performs complex, multi-step reasoning, not simple, single-shot answers. The delay you observe in Colab is the "thinking" time, as the engine dynamically plans and executes a sequence of API calls (e.g., planning, then RAG, then generation). This is the same reason advanced platforms like Gemini or ChatGPT require a moment to "think" for complex requests, even though they benefit from significantly more powerful environments.
### â
Prerequisites
- **Python**: Version **3.10+**
- **Environment Options:**
- Google Colab **or**
- Local Python environment with:
- `openai`
- `pinecone-client`
- `tiktoken`
- `tenacity`
- `fastapi`
### đ Quick Start
Get up and running using cloud-based virtual machines using the Google Colab links provided for each notebook.
No local installation is required.
#### 1. Get Your API Keys
Before running the notebooks, you will need valid API keys for the underlying services:
* **OpenAI**: Sign up and generate a key at [platform.openai.com](https://platform.openai.com/).
* **Pinecone**: Sign up and generate a free API key at [pinecone.io](https://www.pinecone.io/).
### 2. Run the Notebooks
Click the badges below to launch the notebooks directly in a pre-configured Google Colab VM. You will be asked to add your API keys to the Colab Secrets Manager upon launch.
| Chapter | Notebook | Launch |
| :--- | :--- | :--- |
| **Chapter 4** | **Context Engine** | [](https://colab.research.google.com/github/YOUR_USERNAME/YOUR_REPO/blob/main/Context_Engine.ipynb) |
| **Chapter X** | *Another Notebook* | [](https://colab.research.google.com/github/YOUR_USERNAME/YOUR_REPO/blob/main/FILENAME.ipynb) |
### â
Project Structure
Create a GitHub or local workspace containing at least:
- `helpers.py`
- `agents.py`
- `registry.py`
- `engine.py`
- Notebook files for each chapter
### â
Required API Keys
- **OpenAI** â model access and moderation
- **Pinecone** â vector database storage and retrieval
- **(Optional)** Google Cloud or AWS â for deployment sections in Chapter 10
### â
System Requirements
| Requirement | Minimum | Recommended |
|------------|---------|--------------|
| CPU | Dual-core | Any modern multi-core |
| RAM | 8 GB | 16 GB or Google Colab Pro |
| GPU | Optional, but helpful for embeddings and token-heavy operations |
> **Note:** From **Chapter 5 onward**, modular components depend on earlier notebooks. Ensure your environment is configured correctly, as setup steps may not be repeated in later chapters.
### â
Additional Notes
- Local execution may incur **token and API costs** with large contexts.
- The **Summarizer Agent** (Chapter 6) helps reduce token usage.
- Familiarity with **RAG workflows** and **MCP-based agent orchestration** is recommended.
- Refer to **Appendix: Context Engine Reference Guide** for quick lookup of component structures and explanations.
About the Author
### â Get to know the Author
Denis Rothman is an AI systems architect and author whose work bridges foundational AI research with todayâs generative and agentic architectures. A graduate of Sorbonne University and ParisâDiderot University, he designed one of the earliest patented *word2matrix* numerical encoding systems which was a precursor to modern embedding techniques. He designed one of the first industrial conversational agents, deployed as an automated language teacher for MoĂŤt & Chandon and other global companies.
Throughout his career, Denis has built largeâscale AI systems across industries, from IBM resource optimizers to worldwide Advanced Planning and Scheduling (APS) solutions, always focusing on transparent, explainable, and productionâready architectures.
Building on decades of applied AI engineering, he has become a leading voice in the agentic era of AI, authoring influential books on transformers, RAG pipelines, businessâready generative AI, and now *Context Engineering for MultiâAgent Systems*. His work emphasizes modelâagnostic engineering, semantic design, and the construction of resilient, domainâindependent AI systems that go far beyond prompting.
Denis continues to publish handsâon frameworks, openâsource architectures, and practical guides that help engineers, researchers, and organizations build the next generation of verifiable, contextâdriven AI systems.
### â
Other Related Books
- Building Business-Ready Generative AI Systems, First Edition
- RAG-Drive Generative AI, First Edition
- Transformers for Natural Language Processing and Computer Vision, Third Edition
## Contributing
We welcome contributions! High interaction through Issues, PRs, and Comments helps the Context Engine grow and improves the trending visibility for the community.
### How to get started:
1. **Check Issues:** Look for the [**good first issue**](https://github.com/Denis2054/Context-Engineering-for-Multi-Agent-Systems/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) label for approachable tasks.
2. **Discussions:** Join our [**Discussions tab**](https://github.com/Denis2054/Context-Engineering-for-Multi-Agent-Systems/discussions) to propose new features or "Context Chaining" techniques.
3. **Pull Requests:** Submit improvements to the core `engine.py` or new specialized agents in `agents.py`.