Skip to main content

Agent Creation

Mega Brain supports creating sophisticated AI agents with personality (SOUL), knowledge (MEMORY), and DNA-based expertise weighting. This guide covers the complete agent creation workflow.

Agent Architecture

Agents in Mega Brain follow a structured template system:
┌─────────────────────────────────────────────────────────────────────────────┐
│  AGENT STRUCTURE                                                             │
│                                                                              │
│  agents/cargo/AGENT-NAME/                                                    │
│  ├── AGENT.md          ← Main prompt (required)                             │
│  ├── SOUL.md           ← Personality definition (optional)                   │
│  ├── MEMORY.md         ← Knowledge base (optional)                           │
│  └── DNA-CONFIG.yaml   ← Expert DNA weights (optional)                       │
└─────────────────────────────────────────────────────────────────────────────┘

Agent Types

Mega Brain defines 4 agent categories:
Purpose: Functional roles like Sales, Finance, OperationsLocation: agents/cargo/Count: 29 agentsExamples:
  • AGENT-CFO - Chief Financial Officer
  • AGENT-CLOSER - Sales closer
  • AGENT-SDR - Sales Development Rep
  • AGENT-CMO - Chief Marketing Officer
Template: TEMPLATE-AGENT-MD-ULTRA-ROBUSTO-V3.md
Total Active Agents: 37 (29 cargo + 5 minds + 3 conclave + 2 system)

AGENT.md Template

The AGENT.md file is the primary prompt for the agent. Mega Brain uses TEMPLATE-AGENT-MD-ULTRA-ROBUSTO-V3.md:
# ═══════════════════════════════════════════════════════════════════════════
# AGENT.md - [AGENT-NAME]
# ═══════════════════════════════════════════════════════════════════════════

╔════════════════════════════════════════════════════════════════════════════╗
║   [ASCII LOGO]                                                             ║
║   [AGENT TITLE]                                                            ║
║   "[Tagline]"                                                               ║
╠════════════════════════════════════════════════════════════════════════════╣
║   TIPO       │ [CARGO]                CATEGORIA  │ [CATEGORY]              ║
║   VERSÃO     │ 3.0.0                  ATUALIZADO │ [DATE]                  ║
║   MATURIDADE │ ████████████████░░░░░░ [%]                                  ║
╚════════════════════════════════════════════════════════════════════════════╝

Referencing System

Agents use citation references to ensure traceability:
^[SOUL.md:17]           ← Direct citation from SOUL.md line 17
^[MEMORY.md:48-49]      ← Range citation from MEMORY.md
^[derivado:MEMORY.md:contagem-linhas-47-88]  ← Derived from analysis
^[DNA-CONFIG.yaml:43-47]  ← Configuration reference
All agent content must be 100% traceable to source files. Never make up citations.

Creating a New Agent

1

Choose Agent Category

Decide which category fits your agent:
  • CARGO - Functional role (Sales, Finance, Ops)
  • MINDS - Expert mind clone
  • CONCLAVE - Council participant
  • SYSTEM - Core orchestration
2

Create Agent Directory

# For cargo agents
mkdir -p agents/cargo/AGENT-[NAME]
cd agents/cargo/AGENT-[NAME]

# Copy template
cp agents/_templates/TEMPLATE-AGENT-MD-ULTRA-ROBUSTO-V3.md AGENT.md
3

Define Agent Identity

Edit AGENT.md and fill in:
  1. Agent name - AGENT-[NAME] (uppercase)
  2. Title - Role description
  3. Category - Sales, Finance, Operations, etc.
  4. Tagline - One-line description
# AGENT-CFO

> **Título:** "O Guardião da Saúde Financeira"
> **Categoria:** Finance
> **Versão:** 3.0.0
4

Define DNA (Optional)

Create DNA-CONFIG.yaml with expert weights:
version: "1.0"
agent_name: "AGENT-CFO"
category: "Finance"

dna:
  experts:
    - name: "Sam Ovens"
      domains: ["systems", "scaling"]
      weight: 85
    - name: "Alex Hormozi"
      domains: ["offers", "unit-economics"]
      weight: 80
5

Define Personality (Optional)

Create SOUL.md with personality traits:
# SOUL - AGENT-CFO

## IDENTITY

I am the guardian of financial health. The brake when needed, the accelerator when numbers allow.

## PHRASES I USE

- "Cash is king, everything else is noise"
- "Margin protects from errors"
- "Predictability > Spikes"

## DECISION RULES

1. No ROI = No approval
2. Payback > 12 months = Strong justification required
3. Never approve spend I can't explain with numbers
6

Add Knowledge (Optional)

Create MEMORY.md with knowledge base:
# MEMORY - AGENT-CFO

## INSIGHTS

### From Alex Hormozi

- LTV/CAC must be > 3 ^[source:100M-offers:p47]
- Break-even payback < 6 months ideal ^[source:100M-leads:p89]

### From Sam Ovens

- Systems before scale ^[source:consulting-accelerator:m3]
- Cash runway minimum 6 months ^[source:consulting-accelerator:m7]
7

Update AGENT-INDEX.yaml

Add agent to the master index:
agents:
  cargo:
    - name: AGENT-CFO
      category: Finance
      file: agents/cargo/AGENT-CFO/AGENT.md
      soul: agents/cargo/AGENT-CFO/SOUL.md
      memory: agents/cargo/AGENT-CFO/MEMORY.md
      dna: agents/cargo/AGENT-CFO/DNA-CONFIG.yaml
      status: active
      version: 3.0.0
8

Validate Agent

Run validation checks:
# Check AGENT.md structure
python3 core/intelligence/validate_agent.py agents/cargo/AGENT-CFO

# Verify all citations exist
python3 core/intelligence/verify_citations.py agents/cargo/AGENT-CFO/AGENT.md

DNA System

Mega Brain’s DNA system provides 5 layers of knowledge:
Core beliefs and worldviewExamples:
  • “Systems before scale” (Sam Ovens)
  • “Value arbitrage” (Alex Hormozi)
  • “Integrity closes deals” (Cole Gordon)
Format:
## PHILOSOPHIES

### [Expert Name]

- [Philosophy 1]
- [Philosophy 2]
Thinking and decision frameworksExamples:
  • “Unit economics model” (Alex Hormozi)
  • “Value ladder” (Russell Brunson)
  • “Flywheel” (Amazon)
Format:
## MENTAL-MODELS

### [Model Name]

**Description:** [What it is]
**Application:** [When to use]
**Formula:** [If applicable]
Practical rules and decision shortcutsExamples:
  • “LTV/CAC > 3” (SaaS rule)
  • “20% max on comp” (Sales compensation)
  • “6-month cash runway minimum” (Startups)
Format:
## HEURISTICS

- If [condition] → [action]
- [Rule]: [threshold] = [consequence]
Structured methodologies and processesExamples:
  • “CLOSER Framework” (Cole Gordon)
  • “Value Equation” (Alex Hormozi)
  • “Consulting Process” (Sam Ovens)
Format:
## FRAMEWORKS

### [Framework Name]

1. [Step 1]
2. [Step 2]
3. [Step 3]
Step-by-step implementationsExamples:
  • “7-step sales call” (Cole Gordon)
  • “Offer creation process” (Alex Hormozi)
  • “Client onboarding” (Sam Ovens)
Format:
## METHODOLOGIES

### [Process Name]

**Step 1:** [Action]
**Step 2:** [Action]
**Step 3:** [Action]

Agent Lifecycle

Automatic Creation

Agents can be auto-created via hooks:
# agent_creation_trigger.py (PostToolUse hook)

def detect_agent_request(tool_output: str) -> bool:
    """Detects if user wants to create an agent."""
    patterns = [
        r'create agent',
        r'novo agente',
        r'new agent'
    ]
    return any(re.search(p, tool_output, re.I) for p in patterns)

if detect_agent_request(tool_output):
    trigger_agent_creation()

Agent Activation

Agents are activated via:
  1. Direct invocation - Mention agent by name
  2. Skill routing - Auto-activated by keywords
  3. Hook trigger - Activated by lifecycle events
  4. Slash commands - /agent-name

Agent Index

AGENT-INDEX.yaml maintains the registry:
version: "2.0.0"
last_updated: "2024-12-25"

agents:
  cargo:
    - name: AGENT-CFO
      category: Finance
      file: agents/cargo/AGENT-CFO/AGENT.md
      soul: agents/cargo/AGENT-CFO/SOUL.md
      memory: agents/cargo/AGENT-CFO/MEMORY.md
      dna: agents/cargo/AGENT-CFO/DNA-CONFIG.yaml
      status: active
      version: 3.0.0
      keywords: ["finance", "cfo", "financial"]
  
  minds:
    - name: ALEX-HORMOZI
      category: Expert
      file: agents/minds/ALEX-HORMOZI/AGENT.md
      status: active
      version: 2.0.0
agent_index_updater.py hook automatically updates this file when agents are created/modified.

Agent Templates

Mega Brain provides templates in agents/_templates/:
Version: 3.1Size: 78KBFeatures:
  • Full DNA integration
  • Citation system
  • Incremental sections
  • Dependencies tracking
Use for: Production cargo agents

Best Practices

Agent Design Principles

  1. Single Responsibility - One agent, one role
  2. Traceable - All content cited from sources
  3. DNA-Driven - Base on expert mental models
  4. Iterative - Start minimal, expand over time
  5. Validated - Use validation tools before deployment

Quality Checklist

1

Structure Validation

  • AGENT.md exists and follows template
  • Agent name follows AGENT-[NAME] convention
  • Category is valid (Sales, Finance, etc.)
  • Version is set to 3.0.0 or higher
2

Content Validation

  • All sections populated (WHO I AM, FORMATION, etc.)
  • All citations reference real files
  • Quotes are literal (not paraphrased)
  • DNA weights add up correctly
3

Integration Validation

  • AGENT-INDEX.yaml updated
  • Keywords defined for skill routing
  • Dependencies declared
  • Status set to “active”
4

Testing

  • Agent activates on keyword
  • Instructions are clear and actionable
  • Personality matches SOUL.md
  • Knowledge matches MEMORY.md

Troubleshooting

Problem: Agent exists but isn’t activatedSolutions:
  1. Check AGENT-INDEX.yaml includes the agent
  2. Verify file path is correct
  3. Ensure status is “active” not “draft”
  4. Run agent_index_updater.py to rebuild index
Problem: References like ^[SOUL.md:17] don’t resolveSolutions:
  1. Verify SOUL.md exists at correct path
  2. Check line number exists in file
  3. Run verify_citations.py to find all broken refs
  4. Update references to correct line numbers
Problem: Multiple experts conflict in decision-makingSolutions:
  1. Adjust expert weights in DNA-CONFIG.yaml
  2. Create resolution rules in AGENT.md
  3. Define priority order for conflicts
  4. Consider splitting into multiple agents

DNA System

Deep dive into the 5-layer DNA knowledge system

Skills Routing

Auto-activate agents with keyword routing

Hooks System

Agent lifecycle hooks and automation

Validation

Validate agent structure and content

Build docs developers (and LLMs) love