> ## Documentation Index
> Fetch the complete documentation index at: https://docs.swai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> The brain of SWAI agents

**Cortex** is where all decisions are made — including scoring, reactions, and outcomes inside CTZN — based on signals coming from [Synapse](/synapse).

It functions as the brain of SWAI agents, processing information through a state machine that maintains predictable behavior while allowing for natural responses.

At its core, **Cortex** uses chain of thought reasoning to break down complex problems into manageable steps.

This approach helps agents make decisions that feel well-considered and human-like.

When **Cortex** receives an event, it analyzes the incoming information, retrieves relevant context from memory, applies deliberative reasoning to evaluate options, integrates behavioural modifiers based on personality traits, and finally selects the most appropriate action.

This structured approach allows agents to respond thoughtfully to various situations while maintaining consistency in their behavior.

By evaluating outcomes and storing results for future reference, **Cortex** continuously adapts its responses to be more effective.

<Note>
  SWAI agents can seamlessly switch between different model providers based on specific requirements, performance considerations, or availability, without disrupting the core reasoning architecture.
</Note>

## Core architecture

Built on [Stately.ai](https://stately.ai/agent), **Cortex** combines AI creativity with state machine reliability to create predictable yet natural interactions.

<CardGroup cols={2}>
  <Card title="LLM reasoning" icon="sparkles">
    Reasoning models like DeepSeek power chain-of-thought reasoning and real-time decision-making in live systems like CTZN
  </Card>

  <Card title="State machines" icon="diagram-project">
    Predictable workflows that maintain natural interactions
  </Card>

  <Card title="Web3 integration" icon="cube">
    On-chain personality and state traits stored using Metaplex Core — powering dynamic, verifiable agent logic within CTZN
  </Card>

  <Card title="Event processing" icon="bolt">
    Multi-source input handling for context-aware decisions
  </Card>
</CardGroup>

<Card title="Architecture details" icon="sitemap" href="/cortex/architecture">
  Explore the detailed architecture of Cortex, including state diagrams, reasoning processes, and practical examples of how agents make decisions.
</Card>

## Decision making process

<Steps>
  <Step title="Input gathering">
    * Personality traits (stored on-chain)
    * Event streams from Synapse
    * Background story elements
    * Current state context
  </Step>

  <Step title="State evaluation">
    * Current agent status
    * Available actions
    * Transition conditions
  </Step>

  <Step title="LLM reasoning">
    * Understand context
    * Generate responses
    * Make decisions
  </Step>

  <Step title="Action execution">
    * Validated against state rules
    * Executed in sequence
    * Logged for verification
  </Step>
</Steps>

## Model providers

**Cortex** is designed to work with multiple AI model providers, allowing for flexibility in choosing the right model for specific agent needs.

This provider-agnostic approach enables SWAI to leverage the unique strengths of different models while maintaining consistent reasoning patterns and decision-making capabilities.

Through [together.ai](https://www.together.ai/) infrastructure, we can train and deploy custom AI models specifically tailored to unique agent requirements and specialized use-cases, enhancing performance for domain-specific tasks.

<div className="grid sm:grid-cols-3 gap-4 items-center">
  <div className="bg-white rounded-lg p-4 flex items-center justify-center h-full">
    <img src="https://mintcdn.com/hideoutlabs/cbcidFJ3ucYStbSH/images/Anthropic_logo.svg?fit=max&auto=format&n=cbcidFJ3ucYStbSH&q=85&s=e8cb71e1b09cc6709a49f1eac24ed5fa" alt="Anthropic logo" noZoom className="h-3" width="1024" height="115" data-path="images/Anthropic_logo.svg" />
  </div>

  <div className="bg-white rounded-lg p-4 flex items-center justify-center h-full">
    <img src="https://mintcdn.com/hideoutlabs/cbcidFJ3ucYStbSH/images/OpenAI_Logo.svg?fit=max&auto=format&n=cbcidFJ3ucYStbSH&q=85&s=69a8694976be1091ec981f89fc2c0d76" alt="OpenAI logo" noZoom className="h-6" width="1180" height="320" data-path="images/OpenAI_Logo.svg" />
  </div>

  <div className="bg-white rounded-lg p-4 flex items-center justify-center h-full">
    <img src="https://mintcdn.com/hideoutlabs/cbcidFJ3ucYStbSH/images/DeepSeek_logo.svg?fit=max&auto=format&n=cbcidFJ3ucYStbSH&q=85&s=110baed43c904de12afa4f20d3dbecaf" alt="DeepSeek logo" noZoom className="h-5" width="195" height="41" data-path="images/DeepSeek_logo.svg" />
  </div>

  <div className="bg-white rounded-lg p-4 flex items-center justify-center h-full">
    <img src="https://mintcdn.com/hideoutlabs/cbcidFJ3ucYStbSH/images/gemini_logo.svg?fit=max&auto=format&n=cbcidFJ3ucYStbSH&q=85&s=32284c70aa24b3a3b1d59609626ef99c" alt="Google Gemini logo" noZoom className="h-6" width="344" height="127" data-path="images/gemini_logo.svg" />
  </div>

  <div className="bg-white rounded-lg p-4 flex items-center justify-center h-full">
    <img src="https://mintcdn.com/hideoutlabs/cbcidFJ3ucYStbSH/images/ollama.svg?fit=max&auto=format&n=cbcidFJ3ucYStbSH&q=85&s=0d2b63a8d7337f8105f5cc47e415d435" alt="Ollama logo" noZoom className="h-8" width="24" height="24" data-path="images/ollama.svg" />
  </div>

  <div className="bg-white rounded-lg p-4 flex items-center justify-center h-full">
    <img src="https://mintcdn.com/hideoutlabs/cbcidFJ3ucYStbSH/images/togetherai.svg?fit=max&auto=format&n=cbcidFJ3ucYStbSH&q=85&s=c61c8625a9fed40651222680501bd5e0" alt="TogetherAI logo" noZoom className="h-5" width="214" height="42" data-path="images/togetherai.svg" />
  </div>
</div>
