An AI system with explicit, persistent, and inspectable thought formation.
The Cognitive Engine transforms AI from answering to thinking, from reacting to reasoning, from output to cognition. It implements a novel architecture that makes thought formation explicit, persistent, and inspectable through structured thought objects, three-layer memory, autonomous agent capabilities, learning systems, prompt evolution, and real-time cognitive telemetry.
Intelligence is not the act of answering—it is the process of becoming certain.
The system optimizes for process quality rather than just output quality. Better answers are a consequence of better thinking—not the objective itself.
Memory transforms intelligence from reactive (responding to input) to cumulative (building on past experience).
# Clone the repository
git clone <repository-url>
cd cognitive_engine
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure environment variables
cp .env.example .env
# Edit .env with your API keys and configuration
Set environment variables or create .env file:
# LLM Configuration
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_anthropic_key
DEFAULT_LLM_PROVIDER=custom # or "openai" or "anthropic"
DEFAULT_MODEL=gpt-4
TEMPERATURE=0.7
MAX_TOKENS=2000
# Custom Provider Configuration
ENABLE_CUSTOM_PROVIDER=true
CUSTOM_API_ENDPOINT=
CUSTOM_API_KEY=
# Cognitive Layer Configuration
MAX_THOUGHTS_PER_GENERATION=5
MAX_DELIBERATION_ITERATIONS=3
CONFIDENCE_THRESHOLD=0.7
SCORE_THRESHOLD=0.5
# Meta-Cognition Configuration
MIN_ITERATIONS=1
MAX_ITERATIONS=10
EARLY_STOP_CONFIDENCE=0.95
# Memory Configuration
MEMORY_BACKEND=sqlite
MEMORY_PATH=cognitive_engine.db
MAX_MEMORY_ENTRIES=10000
# Agent Configuration
MAX_AGENT_STEPS=50
AGENT_TIMEOUT_SECONDS=300
# Learning Configuration
PATTERN_EXTRACTION_INTERVAL=100
PATTERN_CONFIDENCE_THRESHOLD=0.8
# Prompt Evolution Configuration
ENABLE_PROMPT_EVOLUTION=false
PROMPT_EVOLUTION_INTERVAL=1000
MUTATION_RATE=0.1
# Dashboard Configuration
ENABLE_DASHBOARD=true
DASHBOARD_HOST=localhost
DASHBOARD_PORT=8000
# Logging Configuration
LOG_LEVEL=INFO
LOG_FILE=cognitive_engine.log
python run.py interactive
# or
python run.py
Interactive mode allows you to have conversations with the Cognitive Engine, observing thought formation in real-time.
python run.py agent
Agent mode allows you to set goals for the autonomous agent and watch it work through the Think-Plan-Act-Observe-Reflect loop.
python run.py dashboard
Dashboard mode starts the WebSocket server for real-time cognitive telemetry. Access the dashboard at http://localhost:8000.
python run.py test
Test mode runs basic functionality tests to verify the system is working correctly.
cognitive_engine/
├── core/ # Engine orchestration
│ ├── engine.py # Main orchestration loop
│ ├── config.py # Tunable parameters
│ ├── meta_cognition.py # Meta-cognition oversight
│ ├── memory.py # Three-layer memory
│ ├── reasoning_trace.py # Reasoning trace tracking
│ ├── self_doubt.py # Self-doubt mechanism
│ ├── ethical_alignment.py # Ethical alignment
│ ├── emotional_simulation.py # Emotional simulation
│ ├── peaceful_resolution.py # Peaceful resolution
│ ├── obedience_understanding.py # Obedience understanding
│ ├── decision_control.py # Decision control
│ ├── temporal_identity.py # Temporal identity
│ └── inner_knowing.py # Inner knowing system
├── models/ # Data models
│ ├── thought.py # Thought object definition
│ └── state.py # Problem state representation
├── layers/ # Cognitive layers
│ ├── interpreter.py # Input → structured state
│ ├── generator.py # Create candidate thoughts
│ ├── deliberator.py # Evaluate + evolve thoughts
│ ├── committer.py # Select + finalize output
│ └── meta.py # Meta-cognition (control loop)
├── utils/ # Utilities
│ ├── scoring.py # Scoring functions
│ ├── memory.py # Persistent thought storage
│ └── logger.py # Debug + inspection logs
├── llm/ # LLM integration
│ ├── client.py # LLM interface (single entry point)
│ ├── prompts.py # Layer-specific prompt templates
│ └── knowledge_base.py # Internal knowledge base
├── agent/ # Autonomous agent
│ ├── agent.py # Main agent loop
│ ├── planner.py # Goal → plan
│ ├── executor.py # Execute actions/tools
│ ├── observer.py # Interpret results
│ └── goals.py # Goal definitions
├── tools/ # Tool system
│ ├── registry.py # Tool manager
│ ├── web_search.py # Example tool
│ └── code_exec.py # Code execution tool
├── learning/ # Learning system
│ ├── extractor.py # Pattern mining from memory
│ ├── patterns.py # Pattern object model
│ ├── synthesizer.py # Turn patterns into rules
│ └── updater.py # Inject learned knowledge
├── prompt_evolution/ # Prompt evolution
│ ├── prompt_store.py # Versioned prompt registry
│ ├── proposer.py # LLM suggests improvements
│ ├── tester.py # A/B testing system
│ ├── evaluator.py # Performance scoring
│ └── controller.py # Approval + rollback logic
├── dashboard/ # Cognitive telemetry
│ ├── server.py # WebSocket backend
│ ├── stream.py # Event stream from entity
│ └── events.py # Standard event schema
├── ui/ # Dashboard frontend
│ ├── index.html # Live dashboard
│ ├── app.js # Real-time renderer
│ └── styles.css # Sci-fi UI theme
├── api/ # External interface
│ └── interface.py # Public API
├── cogchat/ # Chat interface
│ ├── chat.py # Chat functionality
│ ├── cli.py # Command-line interface
│ ├── server.py # Chat server
│ └── config.py # Chat configuration
├── run.py # Entry point
├── requirements.txt # Dependencies
└── README.md # This file
The Cognitive Engine implements a novel cognitive architecture that transforms AI from a predictive tool to a deliberative system. See ARCHITECTURE.md for detailed architecture documentation.
See API.md for detailed API documentation.
See DEVELOPMENT.md for development guidelines.
See DEPLOYMENT.md for deployment instructions.
A thought is not a sentence—it is a structured entity with:
Without object-based thoughts, the system falls back to temporary computation, not true thought formation.
Memory is no longer a record of what happened—it becomes a system that influences what happens next. Every decision is a function of everything that came before it. Intelligence becomes a trajectory rather than a snapshot.
Without an oversight layer, the system either halts prematurely or loops indefinitely. Meta-cognition governs thinking depth, stopping conditions, and confidence thresholds.
Self-modification requires evaluation against historical performance, A/B testing of strategy changes, and rollback capability. The system evolves under constraint, not freely.
Cognitive telemetry makes intelligence observable as a dynamic process unfolding over time. The dashboard allows replay and observation of cognitive evolution.
The Cognitive Engine includes multiple safeguards to ensure safe operation:
MIT License
Contributions are welcome! Please see DEVELOPMENT.md for guidelines.
The Cognitive Engine is inspired by research in cognitive science, deliberative reasoning, and artificial general intelligence. It aims to demonstrate that better answers are a consequence of better thinking—not the objective itself.