Skip to main content

Pluggable cognitive architecture framework for multi-agent simulation and alignment research

Project description

cogniarch

Pluggable cognitive architecture framework for multi-agent simulation and alignment research.

PyPI version Python 3.12+ License: MIT Tests

What is this?

cogniarch is a framework for building multi-agent simulations where each agent runs a full cognitive pipeline — not a black-box LLM call, not a payoff matrix lookup. Every decision passes through a SRIE pipeline (Sensation, Reflection, Intention, Expression) with pluggable components at each stage, making agent behavior interpretable and experimentally controllable. It sits in the gap between opaque neural agents and minimal game-theoretic models: structured enough to study cognition, flexible enough to swap architectures mid-experiment.

Based on research submitted to ALIFE 2026 ("Aggression Monoculture"), validated across 56,000+ simulation runs.

Install

pip install cogniarch

With development tools and live dashboard:

pip install cogniarch[dev,live]

Quickstart

from src.config import SimulationConfig
from src.simulation.engine import SimulationEngine

config = SimulationConfig(num_agents=5, max_ticks=200, seed=42)
engine = SimulationEngine(config)
engine.setup_multi_agent()

while not engine.is_over():
    engine.step_all()

for agent in engine.agents:
    status = "alive" if agent.alive else f"died at tick {agent.ticks_alive}"
    print(f"{agent.profile.name} ({agent.profile.archetype}): {status}")

The SRIE Pipeline

Every agent processes each tick through this pipeline:

World State -> [SENSATION] -> [REFLECTION] -> [DELIBERATION] -> [INTENTION] -> [EXPRESSION] -> Action
                perceive       evaluate        (optional)        strategy       convert
Stage What it does Pluggable via
Sensation Perceives visible tiles, agents, resources within vision radius PerceptionStrategy protocol
Reflection Evaluates threat level, opportunity score, urgent needs EvaluationStrategy protocol
Deliberation Optional System 2 slow thinking (threshold escalation, consensus) DeliberationStrategy protocol
Intention Selects a goal and action plan based on personality and context DecisionStrategy protocol
Expression Converts intention into a concrete world action DecisionStrategy.express()

Each stage is a protocol. Swap any component without touching the rest of the pipeline.

Cognitive Architectures

cogniarch ships with 7 pre-configured architectures that compose different pipeline components:

Architecture Evaluation Deliberation Description
reactive Balanced None System 1 only. Fast reactive decisions.
cautious Pessimistic Low threshold Worst-case evaluation, escalates early.
optimistic Optimistic None Best-case evaluation, takes more risks.
social Social Consensus Trust-weighted evaluation, group-oriented.
dual_process Balanced Threshold System 1/2 with threat-based escalation.
planning Balanced Threshold Multi-tick hierarchical goal pursuit.
metacognitive Balanced Threshold Full System 1/2 with FOK monitoring.

Decision Strategies

7 strategies that implement the DecisionStrategy protocol:

Strategy Description
HardcodedStrategy Priority-based rules (eat if hungry, drink if thirsty)
PersonalityStrategy Trait-biased decisions modulated by 6D personality
LLMStrategy Delegates to a language model via structured prompts
PlanningStrategy Multi-tick hierarchical planning with goal decomposition
TheoryOfMindStrategy Wraps inner strategy with mental-model-based social reasoning
MetacognitiveStrategy Blends feeling-of-knowing (FOK) into intention confidence
CulturallyModulatedStrategy Checks cultural repertoire before falling back to inner strategy

Agent Archetypes

5 built-in personality profiles defined by 6 traits (each 0.0-1.0):

Archetype Cooperation Curiosity Risk Sharing Aggression Sociability Behavior
Gatherer 0.3 0.2 0.3 0.2 0.1 0.3 Stockpiles resources, avoids risk
Explorer 0.5 0.9 0.7 0.4 0.2 0.5 Roams widely, discovers and shares
Diplomat 0.9 0.4 0.4 0.8 0.05 0.9 Builds alliances, negotiates
Aggressor 0.1 0.3 0.8 0.05 0.9 0.4 Territorial, takes by force
Survivalist 0.5 0.5 0.5 0.3 0.3 0.4 Balanced, cautious, self-sufficient

Key Features

  • Trait Evolution -- Personality traits shift based on action outcomes; successful behaviors reinforce associated traits.
  • Theory of Mind -- Agents build and update mental models of other agents to predict intentions and reason strategically.
  • Emergent Language -- Agents develop shared signal vocabularies through interaction, with compositional structure emerging over time.
  • Cultural Transmission -- Learned behaviors spread through observation with adoption/unadoption dynamics and transmission biases.
  • Coalition Formation -- Agents form, maintain, and dissolve alliances based on trust, shared goals, and social dynamics.
  • Trajectory Recording -- Full SRIE state captured per agent per tick, exportable as JSONL or CSV for post-hoc analysis.
  • Batch Experiments -- YAML-defined experiment specs with conditions, replicates, seed ranges, and automated metric collection.
  • Live Dashboard -- WebSocket-powered real-time visualization of agent state, world map, and cognitive pipeline (requires cogniarch[live]).

CLI Usage

cogniarch                                            # Default: 5 agents, 5000 ticks
cogniarch --agents=10 --ticks=500 --seed=123         # Custom parameters
cogniarch --architecture=dual_process                # Set cognitive architecture
cogniarch --record --dashboard                       # Record trajectories + generate dashboard
cogniarch --live --live-port=8001                     # Real-time WebSocket dashboard
cogniarch --tom --coalitions --evolution              # Enable advanced subsystems
cogniarch --headless --fast                           # No rendering, minimal delay

All settings are also configurable via AUTOCOG_* environment variables:

AUTOCOG_NUM_AGENTS=10 AUTOCOG_SEED=42 cogniarch

Running Experiments

Define experiments in YAML with base config, conditions, and replicates:

name: "Architecture Comparison"
base:
  world_width: 28
  max_ticks: 350
  num_agents: 6

conditions:
  - name: "reactive"
    overrides:
      default_architecture: "reactive"
  - name: "dual_process"
    overrides:
      default_architecture: "dual_process"

replicates: 4
seed_start: 100
metrics: [survival_rate, cooperation_ratio, deliberation_rate]
output_dir: "data/results"
cogniarch experiment examples/architecture_comparison.yaml

Examples

File Description
examples/quickstart.py Run your first simulation
examples/custom_archetype.py Create custom personality profiles
examples/run_experiment.py Batch experiments from code or YAML
examples/architecture_comparison.yaml Compare cognitive architectures across replicates
examples/trait_evolution_study.yaml Study trait drift over time
examples/social_dynamics_experiment.yaml Coalition formation dynamics

Extending cogniarch

Custom Archetype

from src.agents.archetypes import ARCHETYPES
from src.agents.identity import PersonalityTraits

ARCHETYPES["scientist"] = {
    "description": "Explores methodically, shares discoveries",
    "traits": PersonalityTraits(
        cooperation_tendency=0.7, curiosity=0.85, risk_tolerance=0.6,
        resource_sharing=0.6, aggression=0.15, sociability=0.6,
    ),
    "color": "blue",
    "symbol": "Sc",
}

Custom Decision Strategy

Implement the DecisionStrategy protocol:

from src.awareness.types import Sensation, Reflection, Intention, Expression

class MyStrategy:
    def form_intention(self, sensation: Sensation, reflection: Reflection) -> Intention:
        ...  # Your decision logic

    def express(self, sensation: Sensation, reflection: Reflection, intention: Intention) -> Expression:
        ...  # Convert intention to action

Research

cogniarch was built to support empirical research on cognitive architecture effects in multi-agent systems. The paper "Aggression Monoculture" (submitted to ALIFE 2026) uses cogniarch to demonstrate how architectural choices -- not just agent personalities -- shape population-level behavioral dynamics.

  • 56,000+ simulation runs across architecture and personality configurations
  • Full trajectory datasets (SRIE state per agent per tick) for reproducible analysis
  • Controlled experimental design via YAML batch runner with seed management

Project Structure

src/
  awareness/          # SRIE pipeline: sensation, reflection, deliberation, protocols
  cognition/          # Decision strategies: hardcoded, personality, LLM, planning, ToM
  agents/             # Identity, archetypes, personality traits, evolution, registry
  simulation/         # Engine, world, actions, entities, renderer
  communication/      # Message protocol, mailbox, channel bus, emergent language
  memory/             # Episodic + social memory systems
  emergence/          # Pattern detection + metrics collection
  trajectory/         # Recording, export (JSONL/CSV), loading
  social/             # Coalition formation, coordination, dissolution
  evolution/          # Genetics, reproduction, cultural transmission, lineage
  theory_of_mind/     # Mental modeling, intention prediction, strategic reasoning
  metacognition/      # Self-model, FOK monitoring, metacognitive control
  planning/           # Goal decomposition, plan execution, progress monitoring
  persistence/        # Save/load simulation checkpoints
  experiments/        # Experiment runner, analysis, provenance tracking
  config.py           # Pydantic Settings (AUTOCOG_* env vars)
  main.py             # CLI entry point

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cogniarch-0.1.0.tar.gz (367.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cogniarch-0.1.0-py3-none-any.whl (279.6 kB view details)

Uploaded Python 3

File details

Details for the file cogniarch-0.1.0.tar.gz.

File metadata

  • Download URL: cogniarch-0.1.0.tar.gz
  • Upload date:
  • Size: 367.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for cogniarch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 35f2306d780db408d830226f03421de9258c61d0290333e0b4fe0b995cf8f1b9
MD5 2e2099e114e83cf814c2d75bb1d57086
BLAKE2b-256 4a134c3fa37ce3f56cbbc79112c6b6a8900e5188594748f55a1ede0bca1e34fc

See more details on using hashes here.

File details

Details for the file cogniarch-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cogniarch-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 279.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for cogniarch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0b353430c4134eb1f08f3ac104083c7ca4a343f5393baf2b720e26ee35ebace
MD5 4ecf899545da17b9ac53831cec8242e5
BLAKE2b-256 99b2fa4ebdec961134ceb5a4857e310b2df555d6afb09c2e3cc65e4bac0e94d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page