Context Engineering

repository·main·Indexed 27 days ago

https://github.com/jasontang-ai/context-engineering

A first-principles handbook and resource repository for the design and orchestration of the LLM context window. It includes a comprehensive 12-week course covering mathematical foundations, RAG systems, memory architectures (including reconstructive memory), multi-agent orchestration, and frontier research such as neural field theory, quantum semantics, and meta-recursive systems.

Tokens
298.4K
Snippets
364
Records
707
Agent score
94%

What's inside context-engineering

  1. Overview of the Context Engineering Course

    main
    The Context Engineering course is a comprehensive curriculum designed to take learners from foundational mathematical principles to frontier systems. It synthesizes research from a 2025 survey paper on Context Engineering for Large Language Models to provide a systematic progression of learning. The course is structured into four main phases: Foundations, System Implementations, Integration, and Frontier systems.
  2. Overview of Advanced Cognitive Program Architecture

    main

    Advanced cognitive programs are designed for sophisticated reasoning tasks using a cyclical architecture. The framework consists of three primary layers that interact in a loop:

    1. Planning Layer: Initiates the reasoning process by defining steps or strategies.
    2. Execution Layer: Carries out the tasks defined by the planning layer.
    3. Reflection Layer: Evaluates the outcomes of the execution and provides feedback to the planning layer to refine future actions.

    This architecture enables adaptability and nuance through a continuous feedback loop between planning, execution, and reflection.

  3. Overview of the Statistical Arbitrage Analysis System

    main

    The project is a statistical arbitrage analysis system implemented as a Telegram bot for cryptocurrency spread trading. It uses a multi-stage pipeline to identify arbitrage opportunities through market filtering, synthetic spread creation, and rigorous statistical testing (stationarity and cointegration).

    Core Components

    • Bot Core (test/main.py): Uses aiogram 3.4.1 to handle user interactions and orchestration. Settings are stored in settings/*.json.
    • Statistical Analysis Pipeline: Includes StationarityFilter, CointegrationTester, GrangerSettingsManager, and MarketDataFilter.
    • Calculation Engines: Includes SpreadCalculator, BinanceLotCalculator, and Correlation utilities.
  4. Overview of Orchestration Capstone: From Components to Coherent Intelligence

    main

    The Orchestration Capstone is the final module of the Context Engineering course. It focuses on transitioning from individual AI components to unified, coherent intelligent systems. The capstone is structured around three stages of mastery: Systems Architecture Mastery, Integration Virtuosity, and Adaptive Intelligence Design, with a final emphasis on Production Excellence.

    The capstone architecture is divided into two primary movements:

    • Movement I: Foundation Symphony (Weeks 9-10.1)
    • Movement II: Emergence Concerto (Weeks 10.2-10.3)
  5. Overview of Context Engineering Templates

    main

    The 20_templates directory contains reusable, composable components for implementing context engineering. Templates follow a progressive complexity model, moving from simple single-prompt 'atoms' to complex 'neural fields' that include persistence and cognitive tools.

    Complexity Model: atoms (single prompt) $\rightarrow$ molecules (few-shot) $\rightarrow$ cells (memory/agents) $\rightarrow$ organs (multi-agents) $\rightarrow$ neural systems (cognitive tools/prompt programs) $\rightarrow$ neural fields (fields + persistence).

  6. Understand the Context-Engineering Architecture Evolution

    main

    The repository tracks its architectural evolution through versioned STRUCTURE documents. Use these to understand the theoretical framework, implementation patterns, and directory organization.

    • v1.0 (structure.md): Focuses on a biological metaphor (atoms → molecules → cells → organs).
    • v2.0 (STRUCTURE_v2.md): Incorporates neural field theory, protocol shells, and concepts like attractors, resonance, boundaries, and emergence.
    • v3.0 (STRUCTURE_v3.md): The current advanced meta-recursive architecture featuring meta-recursive frameworks, interpretability scaffolding, collaborative co-evolution, and cross-modal integration.
  7. Understand Protocol-Driven Context Management

    main

    Protocol-driven context management uses structured templates to optimize token usage and prevent information truncation in AI models. Instead of unstructured text, context is organized into intentional allocations (e.g., System, History, Current, Field) to ensure critical information is preserved within the token budget.

    This approach utilizes three complementary methods:

    1. Protocol Shells: Structured templates for organizing context.
    2. Pareto-lang: A declarative language for context operations.
    3. Fractal.json: Recursive patterns for token management.
  8. Understand the spread analysis filtering pipeline

    main

    The bot uses an 8-stage filtering system to identify high-quality arbitrage spreads:

    1. Data Acquisition: Loading and validating exchange data.
    2. Market Filters: Checking volume, liquidity, and volatility.
    3. Spread Creation: Forming and normalizing spreads using the formula log((A*B)/(C*D)).
    4. Asset Correlation: Verifying the relationship between assets.
    5. Fast Stationarity: Preliminary filtering for speed.
    6. Full Stationarity Tests: ADF, KPSS, Hurst exponent, Ljung-Box, and Granger tests.
    7. Cointegration: Engle-Granger and Johansen tests.
    8. Result: Outputting only high-quality arbitrage spreads.
  9. Cross-modal integration principles and components

    main

    Cross-modal integration in context engineering relies on several key conceptual components to ensure that moving between modalities (like text to image) does not result in information loss:

    Integration Principles

    • Unified Semantic Field: A shared space that transcends individual modalities.
    • Bidirectional Translation: Moving information between forms while preserving core meaning.
    • Modal-specific Strengths: Leveraging the unique properties of each modality (e.g., the precision of code vs. the nuance of text).
    • Attractor Dynamics: Patterns that maintain stability and resonance across representational boundaries.

    Core Protocols (The Synesthesia Model)

    • Translation: Mapping between different modalities.
    • Blending: Creating hybrid experiences where modalities overlap.
    • Resonance: Identifying shared patterns of meaning across different inputs.
    • Preservation: Ensuring the core semantics remain intact during transformation.
  10. Understand Schema Pattern Architecture Layers

    main

    The project defines a four-layered approach to robust schema architecture. When designing a data modeling system, you should organize your patterns into these layers:

    1. Meta-Schema Layer: Handles schema validation, management, pattern composition/inheritance, and cross-schema relationships.
    2. Domain Schema Layer: Focuses on business entity/concept modeling, domain-specific validation, and semantic relationships.
    3. Structural Pattern Layer: Provides reusable templates for common data structures, composition/aggregation, and standard validation idioms.
    4. Primitive Pattern Layer: Defines the fundamental building blocks like basic data types, core validation patterns, and serialization formats.