MangoMAS / blog /cognitive_cell_architecture.md
ianshank's picture
Deploy MangoMAS Space via script
708a5b2 verified

A newer version of the Gradio SDK is available: 6.14.0

Upgrade
metadata
title: Cognitive Cell Architecture Design
thumbnail: https://huggingface.co/spaces/ianshank/MangoMAS/resolve/main/thumbnail.png
authors:
  - ianshank
tags:
  - cognitive-architecture
  - multi-agent
  - neural-network
  - cell-architecture
  - pytorch

Cognitive Cell Architecture Design

Author: Ian Shanker | Date: February 2026 | Reading time: ~13 min

🧠 Try it live! Execute all 10 cognitive cells and compose pipelines on the MangoMAS Interactive Demo — select the 🧠 Cognitive Cells tab.


Introduction

What if AI agents were organized like neurons in a brain — each specialized for a specific cognitive function, communicating through structured signals, and composable into higher-order reasoning circuits?

That's the core idea behind MangoMAS's Cognitive Cell Architecture: 10 biologically-inspired processing cell types, each with a standardized preprocess → infer → postprocess → publish lifecycle, composable into arbitrary pipelines.


Biological Inspiration

Biological Concept MangoMAS Implementation
Neuron specialization 10 distinct cell types
Synaptic input Structured input: dict[str, Any] payload
Dendritic processing preprocess() phase
Soma integration infer() phase (core logic + NN heads)
Axonal transmission postprocess() → publish() to event bus
Plasticity Configurable heads, online learning

The 10 Cell Types

Cell Purpose NN Components
ReasoningCell Structured reasoning with configurable heads Rule engine + lightweight NN head
MemoryCell Privacy-preserving preference extraction PreferenceExtractor + PrivacyController
CausalCell Pearl's do-calculus for causal inference Graph-based effect propagation
EthicsCell Safety classification + PII detection Classifier + PII scanner
EmpathyCell Emotional tone detection Tone detector model
CuriosityCell Epistemic curiosity + hypothesis generation Novelty scoring network
FigLiteralCell Figurative vs. literal classification Text classifier
R2PCell Requirements-to-Plan decomposition Structured planner
TelemetryCell Event capture and structuring Telemetry collector
AggregatorCell Multi-expert output aggregation Weighted/ensemble/ranking

Cell Lifecycle

Every cell follows the same 4-phase lifecycle:

class CognitiveCell:
    def execute(self, input_data: dict, config: dict = None) -> dict:
        # 1. PREPROCESS — validate, normalize, enrich
        preprocessed = self.preprocess(input_data, config)
        
        # 2. INFER — core logic (Rule or NN head)
        inference = self.infer(preprocessed)
        
        # 3. POSTPROCESS — format, filter, add metadata
        result = self.postprocess(inference)
        
        # 4. PUBLISH — emit to event bus
        self.publish(result)
        return result

Why Dict-Based I/O?

We chose dict[str, Any] over strict dataclasses for cell I/O because:

  1. Composability: Cells can pass arbitrary data between each other
  2. Versioning: New fields can be added without breaking existing cells
  3. Debugging: JSON-serializable for logging and tracing

Cell Composition (Pipelines)

Cells can be chained into pipelines:

# Example: Ethics → Reasoning → Aggregator pipeline
pipeline = ["ethics", "reasoning", "aggregator"]
result = compose_cells(
    pipeline=pipeline,
    input_data={"text": "Design a secure API with user authentication"},
    configs={
        "ethics": {},
        "reasoning": {"head_type": "rule"},
        "aggregator": {"strategy": "weighted_average"},
    }
)

Each cell's output becomes the next cell's input context, enabling complex reasoning chains.

🔗 Try composing cells on the MangoMAS Demo — use the Cell Composition Pipeline section in the Cognitive Cells tab.


ReasoningCell: Configurable Heads

The ReasoningCell supports multiple inference strategies:

Rule Head

class RuleHead:
    """Pattern-matching rules for section boundary detection."""
    def infer(self, text: str) -> list[dict]:
        # Apply regex + heuristic rules
        # Returns sections with confidence scores

NN Head

class NNHead:
    """Lightweight transformer for section classification."""
    def infer(self, text: str) -> list[dict]:
        # Encode with small transformer
        # Returns sections with neural confidence scores

Users can switch heads at runtime via the config parameter.


EthicsCell: Safety + PII

The EthicsCell combines two sub-components:

  1. Classifier: Rates content safety on a [0, 1] scale
  2. PII Scanner: Detects emails, phone numbers, SSNs with regex + ML
result = execute_cell("ethics", "Contact john@example.com for details")
# → {
#     "is_safe": False,
#     "pii_detected": [{"type": "email", "value": "[REDACTED]"}],
#     "redacted_text": "Contact [REDACTED] for details",
#     "risk_score": 0.72
# }

Design Decisions

Stateless Executors

Each cell executor is a pure function — no mutable state between calls. This enables:

  • Parallel execution across multiple requests
  • Easy unit testing (no setup/teardown)
  • Horizontal scaling (no shared state)

Event Bus Publishing

The publish() phase emits structured events for:

  • Observability (OpenTelemetry traces)
  • Audit logging (enterprise compliance)
  • Feedback loops (router weight updates)

Performance

Cell Latency (P50) Latency (P99)
ReasoningCell (rule) 0.5ms 2.1ms
ReasoningCell (nn) 45ms 120ms
EthicsCell 1.2ms 4.5ms
MemoryCell 0.8ms 3.2ms
CausalCell 2.1ms 8.3ms
AggregatorCell 0.3ms 1.1ms

📈 See live benchmarks on the MangoMAS Demo — select the 📈 Metrics tab.


Conclusion

The Cognitive Cell Architecture provides:

  1. Modularity: Each cell is an independent unit with clear I/O
  2. Composability: Arbitrary pipeline construction via cell chaining
  3. Flexibility: Configurable heads (Rule vs. NN) at runtime
  4. Testability: Stateless executors enable comprehensive property-based testing
  5. Observability: Event bus publishing for tracing and audit

Previous: MCTS for Multi-Agent Task Planning

Model on Hub: ianshank/MangoMAS-MoE-7M

Full source code: MangoMAS on GitHub