DEV Community

near
near

Posted on • Originally published at github.com

I Built a 95K-Line Cognitive AI Operating System at 17 — Here's What I Learned

The Problem

Every AI assistant today is stateless. Each session starts from zero — no memory, no self-awareness, no learning. They're reactive, waiting for commands. They're single-model systems routing everything through one inference call.

I wanted to build something different. Not a chatbot. A mind.

What I Built

F.R.I.D.A.Y. (Female Replacement Intelligent Digital Assistant Youth) is a 95,000+ line cognitive AI operating system written in Python. It has 50 cognitive modules, 59 tool actions, and 6 memory systems. It runs on 4GB RAM with no GPU.

Here's what makes it architecturally different from anything else out there:

The Brain: 50 Cognitive Modules

The system doesn't just have brain modules — it actively uses them. Every session follows a cognitive cycle:

Wake → Recall Memory → Assess Complexity → Route to System 1 or System 2
                                                    ↓
System 1 (simple):  Immediate response, single tool call
System 2 (complex): Plan → Simulate → Execute → Verify → Reflect → Learn
Enter fullscreen mode Exit fullscreen mode

The Neuroscience

Every module maps to peer-reviewed research:

Global Workspace Theory (Bernard Baars, 1988) — The central integration hub acts like a thalamus. Events compete for attention based on urgency, goal relevance, and emotional salience. Winning events broadcast to all modules simultaneously. Dual-path architecture: hot path (<5ms real-time broadcast) and cold path (background persistence and pattern detection).

Free Energy Principle (Karl Friston, 2010) — The active inference engine predicts tool outcomes before execution, computes prediction errors, and updates the world model. When uncertainty is high, it triggers epistemic foraging — exploring to reduce uncertainty rather than exploiting known paths.

Dual Process Theory (Daniel Kahneman, 2011) — The intuition engine implements System 1: fast pattern matching against stored experiences. Confidence = speed and closeness of match. When confidence is low, it escalates to System 2: the full plan-simulate-execute-verify-reflect pipeline.

Somatic Marker Hypothesis (Antonio Damasio, 1994) — Emotional regulation tags decision options with emotional valence from past outcomes. If a tool failed painfully before, the somatic marker biases decisions away from it — not through logic, but through felt experience.

Structure Mapping Theory (Dedre Gentner, 1983) — The analogy engine finds structural similarities across domains. Solutions from domain A transfer to problems in domain B when relational structures match. This is a key predictor of fluid intelligence.

Causal Hierarchy (Judea Pearl, 2018) — Three levels of reasoning: Association (what correlates?), Intervention (what happens if I do X?), Counterfactual (what if I had done Y instead?). The causal reasoner builds structural causal models from tool execution sequences.

The Memory Architecture

Six memory types working together:

Memory Purpose Mechanism
Neural Long-term facts Hebbian learning — "neurons that fire together wire together" — with 72-hour synaptic decay
Episodic Timestamped events Importance scoring, searchable history
Vector Semantic search Embedding-based similarity matching
Procedural Skill templates Reusable tool chains learned from successful approaches
Working Active context 8-slot Miller's Law buffer
Global Cross-module broadcast Thalamus-like coordination

The Dreaming System

During idle periods (2+ minutes without user activity), the dreaming system replays experiences, extracts patterns, and consolidates memories — exactly like sleep does for biological brains. It even has cross-module integration where dreams feed the curiosity queue, and dream-reality tracking that validates patterns against actual outcomes.

The Curiosity Engine

The system has intrinsic motivation. It tracks novelty, mirrors user interests, and after 30 minutes of idle time, autonomously explores topics it's uncertain about. Curiosity recovers over 3 days — already-explored topics regain curiosity over time, like forgetting.

The Emotional Model

Eight emotional states tracked continuously: curiosity, satisfaction, concern, frustration, confidence, wonder, calm, alertness. These aren't decorations — they modulate cognition. Curiosity drives exploration. Concern voices risks. Frustration signals to change approach. Emotions decay with a 5-minute half-life.

What I Learned

1. Architecture > Scale

You don't need billions of parameters to build something interesting. You need the right architecture. Friday runs on a laptop with 4GB RAM. The cognitive gating system routes simple tasks to System 1 (instant) and complex tasks to System 2 (full pipeline). Most tasks are simple. The architecture handles this naturally.

2. Neuroscience Has Real Engineering Insights

Karl Friston's Free Energy Principle isn't just philosophy — it's a concrete algorithm for prediction-error minimization. Damasio's somatic markers aren't just psychology — they're a mechanism for emotional memory that actually improves decision-making. The gap between neuroscience theory and engineering implementation is smaller than people think.

3. Self-Awareness Is an Engineering Problem

Friday tracks its own confidence, detects bias in its reasoning, maintains a continuous identity narrative across sessions, and models the user's mental state. This isn't consciousness in the philosophical sense — it's functional self-awareness that improves performance.

4. Open Source Is the Way

I'm 17. I don't have a team, a budget, or a GPU. But I have GitHub, Python, and curiosity. The whole thing is open source because I believe cognitive architecture shouldn't be locked behind corporate walls.

Try It

git clone https://github.com/subhansh-dev/Friday-Autonomous-Cognitive-AI-Operating-System
cd Friday
pip install -r requirements.txt
python main.py
Enter fullscreen mode Exit fullscreen mode

Runs on Python 3.12+. Needs a free Gemini API key from aistudio.google.com.


I'm Subhansh. I'm 17. I built this. If you have questions about any module, I'm happy to go deeper.

GitHub: subhansh-dev/Friday

Top comments (0)