Skip to content

🧠 Context Engineering is an open-source toolkit to visualize, test, and optimize how LLMs process context windows. Includes a Streamlit app, RAG simulation, educational docs, and Docker supportβ€”perfect for prompt engineers, researchers, and AI developers.

License

Notifications You must be signed in to change notification settings

oxbshw/context-engineering

Repository files navigation

Context Engineering Toolkit

Introduction

Welcome to the Context Engineering Toolkit! This open-source project provides a comprehensive suite of tools for developing advanced conversational AI systems through layered context management. Whether you're a prompt engineer, AI researcher, or developer, this toolkit offers visualizations, simulations, and practical implementations to help you understand and optimize how language models process context.

Key Features

  • Layered Context Management: Implement context engineering principles across multiple layers (atomic, molecular, cellular, organ, field, and meta-recursive)
  • Context Field Operations: Manage continuous semantic operations with attractors, resonance, and emergence
  • Protocol Shells: Execute structured field operations for co-emergence, resonance scaffolding, memory management, and self-repair
  • Self-Improvement Capabilities: Demonstrate meta-recursive improvement through continuous learning and adaptation
  • Visualization Tools: Include tools for visualizing context fields, attractor dynamics, and field operations
  • Educational Resources: Provide documentation and examples to help understand context engineering concepts

Architecture

Context Field Architecture:
β”œβ”€β”€ Core Layer: Basic conversation handling
β”œβ”€β”€ Protocol Layer: Field operations and resonance
β”œβ”€β”€ Memory Layer: Persistent attractor dynamics
β”œβ”€β”€ Meta Layer: Self-reflection and improvement
└── Integration: Unified field orchestration

Project Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Project Ecosystem                   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  chatbot_   │◄──►│  protocol_  │◄──►│  context_   β”‚  β”‚
β”‚  β”‚  core.py    β”‚    β”‚  shells.py  β”‚    β”‚  field.py   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚        β”‚                   β”‚                   β”‚        β”‚
β”‚        β–Ό                   β–Ό                   β–Ό        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ conversationβ”‚    β”‚ meta_       β”‚    β”‚             β”‚  β”‚
β”‚  β”‚ examples.py β”‚    β”‚ recursive_  β”‚    β”‚  utils.py   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚  demo.py    β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β”‚
β”‚                                                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  docs/      β”‚    β”‚  notebooks/ β”‚    β”‚  assets/    β”‚  β”‚
β”‚  β”‚  tutorials  β”‚    β”‚  examples   β”‚    β”‚  diagrams   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Getting Started

Prerequisites

  • Python 3.8+
  • Required packages: numpy, matplotlib, scipy

Installation

git clone https://github.com/oxbshw/context-engineering.git
cd context-engineering
pip install -r requirements.txt

Usage

Basic Conversation

from chatbot_core import ToyContextChatbot

# Initialize the chatbot
chatbot = ToyContextChatbot()

# Start a conversation
response = chatbot.chat("Hello, how are you?")
print(response)

# Show field state
chatbot.show_field_state()

Demonstrate Field Operations

# Execute protocol shells
attractor_results = chatbot.field.protocols["attractor_co_emerge"].execute(chatbot.field)
resonance_results = chatbot.field.protocols["field_resonance"].execute(chatbot.field)

# Show field coherence
print(f"Field coherence: {resonance_results['field_coherence']:.2f}")

Meta-Recursive Improvement

# Perform self-improvement
improvement_info = chatbot.meta_improve()
print(f"Improvement strategy: {improvement_info.get('last_strategy', 'Unknown')}")

Demonstration Examples

The repository includes several demonstration examples showcasing different aspects of context engineering:

  1. Basic Conversation: Simple prompt-response interactions (atomic layer)
  2. Context Retention: Remembering previous topics across exchanges (cellular layer)
  3. Field Operations: Attractor formation and resonance (field layer)
  4. Self-Repair: Handling inconsistencies and restoring field integrity (field layer)
  5. Meta-Recursive: Self-observation and continuous improvement (meta-recursive layer)

Documentation

For detailed documentation and tutorials, refer to the documentation directory. You'll find:

  • Conceptual Overviews: Deep dives into context engineering theory
  • API Documentation: Full reference for all classes and methods
  • Tutorials: Step-by-step guides for various applications
  • Examples: Complete code examples for different use cases

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

We welcome contributions from the community! Please see our contributing guidelines for details on how to get involved.

Citation

If you use this toolkit in your research, please cite it using the following BibTeX entry:

@misc{context_engineering_toolkit,
  author = {Your Name},
  title = {Context Engineering Toolkit},
  year = {2023},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/oxbshw/context-engineering}},
}

Thank you for your interest in the Context Engineering Toolkit! We hope this resource helps you explore and develop advanced conversational AI systems.

About

🧠 Context Engineering is an open-source toolkit to visualize, test, and optimize how LLMs process context windows. Includes a Streamlit app, RAG simulation, educational docs, and Docker supportβ€”perfect for prompt engineers, researchers, and AI developers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages