Skip to content

About

An open-source adaptive AI framework with DAG execution, execution-history learning, prompt evolution, and multi-layer memory.

Resources

Stars

58 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MindLatticeAI Banner

🧠 MindLatticeAI

Adaptive AI Orchestration Framework with Execution-History Learning & Cognitive DAGs

Python License: MIT Tests Architecture Status Stars


Explore Architecture β€’ Quickstart β€’ Core Innovations β€’ Live Providers β€’ Framework Comparison β€’ Roadmap


🌟 Overview

MindLatticeAI is a research-oriented, adaptive AI orchestration framework designed around a fundamental premise:

Every AI request is an experiment. An autonomous agent must formulate a strategy, compile a resilient execution graph, evaluate its own intermediate reasoning, mutate its prompt genomes, learn from execution telemetry, and store experiential knowledge across multi-layer memory meshes.

This repository is intentionally not a LangChain clone, a CrewAI-style static conversational crew, or a simple LiteLLM router. Its core abstraction is an Execution-History Learning Loop operating over Cognitive Directed Acyclic Graphs (DAGs) with checkpointed node resilience and evolvable prompt genomes.


⚑ Terminal Execution Preview

οΏ½[1;36m[MindLatticeAI Runtime]οΏ½[0m Initializing Request: οΏ½[1;33m"Calculate 21 * 2 and reflect on strategy"οΏ½[0m
οΏ½[1;34mβ”œβ”€β”€ [1. INTENT]οΏ½[0m      Task: οΏ½[32mTOOL_AUGMENTED_REASONINGοΏ½[0m | Tools Required: οΏ½[33m['calculator']οΏ½[0m | Risk: οΏ½[32mNORMALοΏ½[0m
οΏ½[1;34mβ”œβ”€β”€ [2. PLANNER]οΏ½[0m     Compiled Strategy: οΏ½[35mstrategy_da4539οΏ½[0m | Genome: οΏ½[35mgenome.default.cognitive (gen 0)οΏ½[0m
οΏ½[1;34mβ”œβ”€β”€ [3. POLICY]οΏ½[0m      Budget: Max $0.25 | Latency: 15,000ms | οΏ½[1;32mChecks Passed (ALLOWED)οΏ½[0m
οΏ½[1;34mβ”œβ”€β”€ [4. DAG ENGINE]οΏ½[0m  Executing Cognitive Graph (7 Nodes):
οΏ½[1;34mβ”‚   β”œβ”€β”€ [RUN]οΏ½[0m        tool.calculator       ───► οΏ½[1;32mSUCCEEDEDοΏ½[0m (42.0) [1ms]
οΏ½[1;34mβ”‚   β”œβ”€β”€ [RUN]οΏ½[0m        model.main            ───► οΏ½[1;32mSUCCEEDEDοΏ½[0m (routed: local:heuristic-v1) [2ms]
οΏ½[1;34mβ”‚   β”œβ”€β”€ [RUN]οΏ½[0m        reflect.self_check    ───► οΏ½[1;32mSUCCEEDEDοΏ½[0m (critique: grounded) [1ms]
οΏ½[1;34mβ”‚   β”œβ”€β”€ [RUN]οΏ½[0m        evaluate.score        ───► οΏ½[1;32mSUCCEEDEDοΏ½[0m (quality: 0.932, hallucination: 0.05)
οΏ½[1;34mβ”‚   β”œβ”€β”€ [PARALLEL]οΏ½[0m   memory.write & learn.update ───► οΏ½[1;32mSUCCEEDEDοΏ½[0m [checkpointed]
οΏ½[1;34mβ”‚   └── [FINALIZE]οΏ½[0m   final.response        ───► οΏ½[1;32mREADYοΏ½[0m
οΏ½[1;34m└── [5. LEARNER]οΏ½[0m     Feedback Prior Updated: Prior 0.85 ──► οΏ½[1;32m0.932οΏ½[0m | Genome Fitness: οΏ½[1;32m+0.082οΏ½[0m

πŸ”¬ Why MindLatticeAI?

Traditional agent frameworks rely on static, brittle chains or fixed multi-agent chat loops. MindLatticeAI pioneers an adaptive, closed-loop execution paradigm:

Feature / Dimension LangChain / LlamaIndex CrewAI / AutoGen LiteLLM 🧠 MindLatticeAI
Execution Topology Static Chains / Agents Conversational Chat Loops Flat Provider Routing Dynamic Cognitive DAGs with node checkpoints & retries
Prompt Engineering Static template strings Role descriptions Passthrough Evolvable Prompt Genomes with scoring & mutation
Adaptation Mechanism None (Deterministic) Prompt engineering Heuristic failover Continuous Learning Loop updating model & strategy priors
Memory Architecture Buffer / Vector Index Chat history buffer None 5-Layer Memory Mesh (Short, Long, Semantic, Episodic, Graph)
Self-Correction Ad-hoc retry Conversational critique None Dedicated Reflection & Hallucination Evaluator
Local-First Capability Needs external APIs Needs external APIs Needs external APIs 100% Zero-Dependency Offline-First with live API contracts

πŸ—οΈ Architecture & Cognitive Loop

Every user query triggers an adaptive cognitive cycle:

flowchart TD
    classDef startNode fill:#0ea5e9,stroke:#0284c7,stroke-width:2px,color:#fff;
    classDef processNode fill:#1e293b,stroke:#3b82f6,stroke-width:1.5px,color:#f8fafc;
    classDef engineNode fill:#4c1d95,stroke:#8b5cf6,stroke-width:2px,color:#fff;
    classDef feedbackNode fill:#065f46,stroke:#10b981,stroke-width:2px,color:#fff;

    User([User Request / AIRequest]):::startNode --> Intent[Intent Parser]:::processNode
    Intent --> Planner[Adaptive Planner]:::processNode
    Planner --> Policy[Policy Engine & Budget Constraints]:::processNode
    Policy --> DAG[Cognitive DAG Builder]:::engineNode

    subgraph ExecutionGraph [Cognitive Graph Execution Engine]
        direction TB
        DAG --> TNode[Tool Nodes: Safe Calculator / Retrieval]:::processNode
        TNode --> MNode[Model Router: Adaptive Prior Selection]:::processNode
        MNode --> RNode[Reflection Engine: Self-Check & Critique]:::processNode
        RNode --> ENode[Evaluator: Scoring & Hallucination Filter]:::processNode
    end

    ENode --> Mem[Memory Update: 5-Layer Mesh]:::feedbackNode
    ENode --> Learn[Learner Engine: Strategy & Prior Update]:::feedbackNode
    Mem --> Resp([Final Replayable Response]):::startNode
    Learn --> Resp
Loading

🧬 Core Innovations

1. πŸ•ΈοΈ Cognitive Execution Graphs (DAG Engine)

  • Requests are compiled into directed acyclic graphs containing atomic, inspectable nodes (TOOL_CALL, MODEL_CALL, REFLECTION, EVALUATION, MEMORY_WRITE, LEARNING).
  • Independent nodes execute concurrently in non-blocking event loops.
  • Node-level checkpoints enable pause, resume, and automated retries on transient network faults.
  • Native export to Graphviz DOT format for instant visualization of execution pathways.

2. 🧬 Evolvable Prompt Genomes

Prompts are not static stringsβ€”they are structured genomes containing:

  • Identity & Instructions: Role definitions, instruction sets, and dynamic constraints.
  • Self-Evaluation Criteria: Groundedness checks, uncertainty estimations, and safety bounds.
  • Generational Evolution: When an execution receives low evaluation scores, the registry mutates the genome, generating improved offspring with updated instructions and tracked parentage.

3. πŸ”„ Closed-Loop Feedback & Learning Engine

  • Tracks execution metrics across every interaction: latency, financial cost, quality score, and hallucination probability.
  • Automatically adjusts:
    • Strategy preference scores
    • Prompt genome fitness priors
    • Model routing weightings
    • Memory retrieval importance biases

4. 🧠 5-Layer Memory Mesh

  • Short-Term Memory: Working session context with automated sliding-window compression.
  • Long-Term Memory: Summarized durable memory across past interactions.
  • Semantic Memory: Content-based similarity retrieval using vectorized lexical signatures.
  • Episodic Memory: Chronological historical traces of previous graph trajectories.
  • Knowledge Graph: Triple-based relational store ((Entity, Relation, Entity)) with deduplication.

πŸš€ Quickstart

Installation

Clone the repository and install in editable mode:

git clone https://github.com/raitulh/MindLatticeAI.git
cd MindLatticeAI
python -m pip install -e .

1. Basic Synchronous Execution

MindLatticeAI runs 100% offline out-of-the-box using deterministic local heuristic providers:

from mindlatticeai import Agent

# Initialize default agent
agent = Agent()

# Execute request
response = agent.run("Calculate 21 * 2 and explain why DAG execution improves AI reliability.")

print("Response:\n", response.text)
print("\nMetrics:", response.metrics)
print("\nReplay ID:", response.replay_id)

2. Asynchronous Execution with Custom Budget

import asyncio
from mindlatticeai import Agent
from mindlatticeai.schemas import AIRequest, RuntimeBudget

async def main():
    agent = Agent()
    request = AIRequest(
        input="Provide a structured overview of cognitive computing.",
        budget=RuntimeBudget(
            max_cost_usd=0.10,
            latency_budget_ms=3000,
            quality_floor=0.80
        )
    )
    
    response = await agent.arun(request)
    print(response.text)

asyncio.run(main())

🌐 Multi-Provider Support

MindLatticeAI includes built-in, zero-dependency HTTP completion support for all major LLM backends. Simply export your API key:

import os
from mindlatticeai import Agent
from mindlatticeai.providers import (
    GeminiProvider,
    OpenAIProvider,
    ClaudeProvider,
    DeepSeekProvider,
    OllamaProvider,
)

# Set keys
os.environ["GEMINI_API_KEY"] = "your-gemini-key"
# os.environ["OPENAI_API_KEY"] = "your-openai-key"
# os.environ["ANTHROPIC_API_KEY"] = "your-anthropic-key"
# os.environ["DEEPSEEK_API_KEY"] = "your-deepseek-key"

agent = Agent(
    providers=[
        GeminiProvider(model="gemini-1.5-pro"),
        OpenAIProvider(model="gpt-4.1-mini"),
        ClaudeProvider(model="claude-3-5-sonnet"),
        DeepSeekProvider(model="deepseek-chat"),
        OllamaProvider(model="llama3.1"),
    ]
)

response = agent.run("Explain how adaptive prior routing works.")
print(response.text)

πŸ› οΈ Extending MindLatticeAI

1. Custom Tool Registration
from mindlatticeai import Agent
from mindlatticeai.tools import Tool, ToolRegistry

def reverse_string(text: str) -> str:
    return text[::-1]

tools = ToolRegistry()
tools.register(
    Tool(
        name="string_reverser",
        description="Reverses any input string",
        handler=reverse_string,
    )
)

agent = Agent(tools=tools)
2. Lifecycle Plugins & Hooks
from mindlatticeai import Agent
from mindlatticeai.plugins import PluginManager

plugins = PluginManager()

@plugins.hook("after_plan")
def log_plan(strategy):
    print(f"Strategy formulated: {strategy.id} with {len(strategy.steps)} steps")

@plugins.hook("after_learn")
def log_learning(score):
    print(f"Learning feedback registered: Quality Score = {score:.4f}")

agent = Agent(plugins=plugins)
3. Automated Benchmarking
import asyncio
from mindlatticeai import Agent
from mindlatticeai.benchmarks import BenchmarkCase, BenchmarkSuite

async def run_eval():
    agent = Agent()
    suite = BenchmarkSuite([
        BenchmarkCase(name="math", input="Calculate 15 * 3", expected_keywords=["45.0"]),
        BenchmarkCase(name="concept", input="What is a DAG?", expected_keywords=["directed"]),
    ])
    
    report = await suite.arun(agent)
    print(f"Success Rate: {report.success_rate * 100:.1f}%")
    print(f"Mean Latency: {report.mean_latency_ms:.2f}ms")

asyncio.run(run_eval())

πŸ“‚ Project Architecture

mindlatticeai/
β”œβ”€β”€ src/mindlatticeai/
β”‚   β”œβ”€β”€ core/          # Agent facade & RuntimeConfig
β”‚   β”œβ”€β”€ graph/         # DAG builder, concurrent execution engine, checkpoints
β”‚   β”œβ”€β”€ planner/       # Intent parsing & adaptive strategy synthesis
β”‚   β”œβ”€β”€ policy/        # Dynamic runtime policies & budget governors
β”‚   β”œβ”€β”€ prompts/       # Prompt Genome registry, scoring, & mutation
β”‚   β”œβ”€β”€ router/        # Multi-factor model router (latency, cost, prior)
β”‚   β”œβ”€β”€ learner/       # Continuous learning loop & prior updater
β”‚   β”œβ”€β”€ memory/        # 5-layer memory mesh (short, long, semantic, episodic, graph)
β”‚   β”œβ”€β”€ providers/     # Local heuristic & live API providers (OpenAI, Gemini, etc.)
β”‚   β”œβ”€β”€ reflection/    # Self-reflection critique & hallucination evaluator
β”‚   β”œβ”€β”€ tools/         # Built-in safe tools & extensible registry
β”‚   β”œβ”€β”€ cache/         # Exact & semantic similarity caches
β”‚   β”œβ”€β”€ replay/        # Execution replay & snapshot serialization
β”‚   β”œβ”€β”€ telemetry/     # Tracing, latency metrics, & DOT visualization
β”‚   β”œβ”€β”€ benchmarks/    # Evaluation suite primitives
β”‚   └── security/      # Sandboxing & security policies
β”œβ”€β”€ tests/             # 18 Unit & Integration test suites
β”œβ”€β”€ examples/          # Executable end-to-end usage examples
└── docs/              # In-depth architectural specifications & roadmap

πŸ§ͺ Testing & Quality Assurance

MindLatticeAI comes with comprehensive test suites covering all architectural layers:

# Run complete test suite
pytest -v

# Run with test coverage
pytest --cov=mindlatticeai

πŸ—ΊοΈ Roadmap & Research Directions

  • DAG Execution Engine with atomic checkpoints & retries
  • Evolvable Prompt Genomes with generational mutations
  • 5-Layer Multi-Layer Memory Mesh
  • Zero-dependency HTTP providers for OpenAI, Gemini, Claude, Ollama, DeepSeek
  • Contextual Bandit reinforcement learning for model routing
  • Vector database backend adapter (Qdrant, Chroma, Milvus)
  • Distributed DAG workers via Redis / Celery
  • Web dashboard for real-time trace, cost, and graph replay analysis

See the full Roadmap Document for details.


🀝 Contributing

Contributions from the AI research and engineering community are warmly welcome! Whether it's novel graph mutation algorithms, new providers, memory backends, or benchmark datasets:

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/CognitiveFeature)
  3. Commit your Changes (git commit -m 'Add CognitiveFeature')
  4. Push to the Branch (git push origin feature/CognitiveFeature)
  5. Open a Pull Request

πŸ“„ License

Distributed under the MIT License. See LICENSE for more details.


✍️ Citation

If you use MindLatticeAI in your academic research or production systems, please cite:

@software{mindlatticeai2026,
  author = {Raitul Hasan Priyo and Contributors},
  title = {MindLatticeAI: Adaptive AI Orchestration Framework with Execution-History Learning and Cognitive Graphs},
  url = {https://github.com/raitulh/MindLatticeAI},
  year = {2026}
}
Built with ❀️ by Raitul Hasan Priyo and the MindLatticeAI community.

About

An open-source adaptive AI framework with DAG execution, execution-history learning, prompt evolution, and multi-layer memory.

Resources

Stars

58 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages