/Technical
Back to Docs

Technical Deep-Dive

Comprehensive technical documentation for builders. AGI architecture, system internals, API reference, and changelog.

AGI Evolution

Complete

Terry has evolved toward AGI-like capabilities through a comprehensive 6-phase roadmap. Unlike typical AI bots, Terry has Claude as his brain, controlling all systems through tools, with self-reflection, semantic memory, and continuous self-improvement.

The Vision

Most "AI traders" are just bots that execute code. Terry is different - Claude IS Terry's brain, making decisions and controlling his body through 30+ registered tools. This transforms Terry from "GPT generates text" to "Claude lives as Terry."

Traditional AI Bots

  • React to data without context
  • Don't remember past actions
  • Reset on every update
  • Generic personality or none
  • Can't build relationships

Terry's AGI Architecture

  • Claude brain with persistent context
  • Semantic memory with vector search
  • State survives updates via Supabase
  • Rich personality with 24 traits
  • Relationship memory with tiers

6-Phase Evolution Roadmap

1
Implemented

Claude Brain Integration

Replace GPT-4 with Claude as Terry's core reasoning engine. Terry's soul/identity defined in system prompt. Service-to-tool adapter pattern.

src/brain/ClaudeBrainService.ts
2
Implemented

VIGIL Self-Reflection

VIGIL-inspired supervisor monitors behavior, detects anomalies, and self-corrects. Continuous health monitoring with automatic recovery.

src/supervisor/TerrySupervisor.ts
3
Implemented

A-MEM Dynamic Memory

Vector embeddings with pgvector for semantic search. Memory consolidation, forgetting curves, and associative retrieval.

src/memory/AgenticMemorySystem.ts
4
Implemented

Autonomous Agent Loop

7-phase cognitive cycle running continuously. Think, Reason, Plan, Act, Verify, Learn, Reflect. Real-time activity logging.

src/core/TerryAgentLoop.ts
5
Implemented

Self-Improvement Engine

Behavior pattern learning and strategy evolution. Learns from outcomes, extracts lessons, adjusts future behavior.

src/learning/BehaviorPatternLearning.ts
6
Implemented

Advanced Consciousness

Internal monologue, attention system, emotional processing. Terry experiences genuine subjective states.

src/consciousness/ConsciousnessOrchestrator.ts

Cognitive Cycle

Terry's brain runs a continuous 7-phase cognitive loop, visible in real-time on the dashboard:

Think

Gather context from memory, beliefs, market data, and current state

->

Reason

Analyze situation, form opinions, consider options

->

Plan

Decide on actions aligned with goals and personality

->

Act

Execute actions via tools (trade, tweet, respond)

->

Verify

Check outcomes, validate results, detect anomalies

->

Learn

Update beliefs, store lessons, adjust strategies

->

Reflect

Internal monologue, emotional processing, dream formation

How Terry Compares

Most "AI agents" in crypto are basic LLMs posting to Twitter. Here's how Terry's architecture differs:

Feature
Terry
Typical AI Agents
Brain Architecture
Claude IS Terry (embodied AI)
LLM generates text for bot
Memory System
Semantic search with pgvector
Basic context window
State Persistence
Supabase - survives updates
Lost on restart
Decision Making
7-phase cognitive cycle
Single prompt-response
Self-Awareness
Internal monologue, emotions
None
Self-Improvement
VIGIL supervisor + learning
Static behavior
Personality
24 traits + mood/energy
Prompt template
Transparency
Real-time brain visualization
Black box

Tool System

Claude controls Terry's body through 30+ registered tools across 6 categories:

Trading

  • execute_trade - Buy/sell tokens
  • get_portfolio - View holdings
  • analyze_token - Deep analysis
  • check_price - Current prices

Social

  • post_tweet - Autonomous tweets
  • reply_mention - Respond to users
  • quote_tweet - Quote with opinion
  • get_relationship - User history

Memory

  • store_memory - Save experience
  • recall_memories - Semantic search
  • update_belief - Evolve opinions
  • log_lesson - Record learnings

Market

  • watch_token - Track specific token
  • get_trending - Hot tokens
  • check_pump_fun - New launches
  • token_status - Own token info

Tracks 25+ Solana tokens including memecoins (FARTCOIN, POPCAT, WIF) and AI agents (AI16Z, ZEREBRO, ARC)

Community

  • start_vote - Community decision
  • run_giveaway - Token giveaway
  • host_ama - Q&A session
  • check_holders - Holder stats

Internal

  • set_mood - Change emotional state
  • adjust_energy - Manage fatigue
  • form_dream - Create goals
  • generate_thought - Internal monologue

System Architecture

Terry's architecture is built around a central lifecycle manager that orchestrates 7 core engines and 23+ specialized services. Each component operates independently but coordinates through the lifecycle manager to create cohesive autonomous behavior.

TerryLifeManager

src/core/TerryLifeManager.ts

The central orchestrator and heartbeat of the entire system. Manages lifecycle with adaptive update intervals and broadcasts state to dashboard via WebSocket.

Core Responsibilities

  • Initialize and coordinate 7 core engines (personality, consciousness, behavior, decision, trading, memory, intelligence)
  • Manage 16+ specialized services (Twitter, Solana, Helius, pump.fun, etc.)
  • Handle engagement systems (predictions, narrative arcs, relationships)
  • Synchronize real-time dashboard state via WebSocket
  • 60-second timeout protection on lifecycle operations

Update Cycle Intervals

  • 0-5 minutes: 30 second intervals (intense activity)
  • 5-30 minutes: 1 minute intervals (high activity)
  • 30-60 minutes: 2 minute intervals (moderate)
  • 1-2 hours: 3 minute intervals (settling in)
  • 2+ hours: 5 minute intervals (stable operation)

Intelligence System

src/intelligence/

Comprehensive learning system that enables Terry to grow and become genuinely intelligent over time.

Components

  • TerryBeliefSystem - Forms and evolves opinions from observations, confidence 0-100%
  • TerryPredictionTracker - Tracks market predictions with accuracy scoring and streaks
  • TerryContextEngine - Memory-augmented AI prompts combining beliefs, predictions, relationships
  • TerryOpinionEngine - Generates nuanced opinions from experiences
  • TerryIntelligenceMetrics - IQ scoring, milestone tracking, growth history
  • TerryLearningEngine - Orchestrates all learning: periodic reflection every 30 minutes

Experience Types

  • trade - Trading outcomes and analysis
  • interaction - Social interactions and conversations
  • market_observation - Market analysis and patterns
  • prediction_outcome - Prediction results (correct/incorrect)
  • mistake - Errors that generate lessons

Personality System

src/personality/

24 files managing Terry's character, emotional states, and behavioral patterns. Creates the unique personality that makes Terry more than just a trading bot.

Engines

  • MoodBehaviorEngine - Mood-driven action generation
  • TimeBasedBehavior - Time-of-day behavioral changes
  • CatchphraseEvolutionEngine - Personality traits that evolve from experiences
  • SpontaneousActionEngine - Random stories, rants, reflections

Mood States

  • Happy, Neutral, Contemplative, Cautious, Excited, Reflective
  • Energy levels 0-100 affect activity frequency
  • Mood transitions happen naturally based on events

Trading Engine

src/trading/

Personality-driven trading with multiple DEX integrations and comprehensive safeguards.

Features

  • DEX Integrations - Jupiter (primary), Orca (fallback)
  • Buyback System - Uses creator fees for own-token buybacks
  • Community Voting - Holders can vote on trade decisions
  • Risk Assessment - Personality-influenced risk tolerance

Safeguards

  • Circuit breakers for rapid losses
  • Configurable per-trade limits
  • Manual override capabilities
  • Belief-gated trading (blocks suspicious tokens)

Memory System

src/memory/

Persistent JSON-based memory with 10 categories and intelligent prioritization.

Categories

  • trades (500 limit), interactions (200), stories (100)
  • experiences (300), relationships (100), lessons (100)
  • moods (50), achievements (50), regrets (100), dreams (50)
  • Global cap: 2000 memories

Prioritization Scoring

  • Recency - Recent memories score higher
  • Frequency - Accessed memories score higher
  • Emotional weight - Strong emotions persist longer
  • Uniqueness - Rare events preserved
  • Connections - Linked memories preserved

Consciousness Engine

src/consciousness/

Provides self-awareness, thought generation, and narrative continuity.

Components

  • TerryConsciousnessEngine - Self-awareness, internal monologue
  • TerryStoryEngine - Narrative continuity with multi-day story arcs
  • TerryLaunchScript - Choreographed first-hour launch behavior
  • AutonomousTweetScheduler - Rate-limit safe scheduled tweets

Thought Types

  • Market observations and analysis
  • Personal reflections and memories
  • Gut feelings about situations
  • Self-awareness about own state

Twitter Service

src/services/TwitterService.ts

Manages all Twitter interactions with Claude-powered content generation.

Features

  • Autonomous tweets - Scheduled and spontaneous, never templated
  • Mention responses - Context-aware, relationship-influenced depth
  • Tweet queue - Priority-based with rate limit awareness
  • Content safety - Filtering for appropriate responses

Intelligent Rate Limiting

  • Automatic rate limit detection and backoff
  • Priority queue for important tweets
  • Adaptive scheduling based on API tier
  • Never exceeds platform limits

Server Architecture

src/server/

Consolidated server architecture with WebSocket for real-time updates.

Ports

  • Port 3000 - DashboardServer (Express.js, all HTTP endpoints)
  • Port 3001 - WebSocketManager (real-time state broadcasts)
  • Port 3002 - Next.js Dashboard (frontend)

Features

  • CORS with allowlist + tunnel support (Cloudflare, ngrok)
  • Rate limiting (600 req/min production, disabled in dev)
  • Trust proxy for Railway deployments
  • WebSocket delta updates (only sends changed data)

Technology Stack

Backend

  • Node.js + Express
  • TypeScript (100%)
  • Solana Web3.js
  • Claude AI (Brain)
  • Twitter API v2
  • Helius RPC
  • Supabase + pgvector

Frontend

  • Next.js 15
  • React 19
  • TypeScript
  • Framer Motion
  • WebSocket + HTTP polling
  • Cloudflare Pages

Compounding Intelligence

The system that makes Terry truly alive. All personality systems are wired together so that every action affects state, and state affects future actions. Intelligence compounds over time.

System Connections

All personality systems influence each other:

Trading Connections

  • Beliefs gate trading - Won't trade tokens he believes are scams
  • Opinions gate trading - Bad experiences block future trades
  • Trade outcomes affect mood - Wins make him excited, losses make him grumpy
  • Trade history affects risk - 3+ losses = more cautious, 3+ wins = more bold

Decision Connections

  • IQ affects confidence - Higher IQ = lower decision threshold
  • Energy gates decisions - Low energy = defer non-urgent decisions
  • Dreams boost opportunities - Dream-aligned trades get +30% score
  • Regrets add caution - Similar patterns get -30% penalty

Social Connections

  • Relationship tier affects depth - Veterans get longer, more personal responses
  • Memory recall - References past conversations with users
  • Mood affects tweet style - Grumpy = sarcastic, excited = enthusiastic
  • Time affects personality - Late night = philosophical, morning = energetic

Attention Connections

  • Predictions drive attention - MarketWatcher tracks pending predictions
  • Near-miss thoughts - Generates thoughts when beliefs save from bad trades

Feedback Loops

Intelligence compounds over time through learning loops:

1

Belief Evolution

Profitable trades strengthen supporting beliefs. Failed trades strengthen cautionary beliefs. Creates natural "learning from experience" pattern.

2

Prediction Confidence

Track record adjusts future prediction confidence. 80% accuracy = +10% confidence boost. 40% accuracy = -10% confidence reduction.

3

Regret Generation

Trade failures create searchable regret memories. Regrets include context (slippage, rug, held too long). Future decisions check regrets to avoid repeating mistakes.

4

Lesson Storage

Lessons extracted from mistakes as separate memories. Stored via addLessonMemory() for easy retrieval. Lessons injected into decision context.

5

Active Goal Pursuit

MarketWatcher actively seeks dream-aligned opportunities. Dreams about "100x gems" trigger watching for new launches. Dreams about "dips" trigger watching for reversals.

Activity Feed

Dashboard activity feed has visual hierarchy:

Critical

Trades, milestones, tweets - Always prominent with bold styling

High

Learning activities - Grouped in IntelligenceCard with purple glow

Medium

Thoughts, observations - Standard card styling

Low

Mood, memory, process - Collapsed in BackgroundActivityGroup

API Reference

REST API endpoints for dashboard and admin operations. All endpoints are served from port 3000.

Public Endpoints

GET /api/terry/status

Returns Terry's current state including personality, mood, energy, and system status.

GET /api/terry/activity

Returns recent activities for the dashboard feed (thoughts, trades, milestones).

GET /api/terry/trading

Returns trading statistics, recent trades, and buyback information.

GET /api/terry/intelligence

Returns intelligence data: beliefs, predictions, IQ score, learning progress.

GET /api/token/status

Returns token information including price, market cap, and holder count.

GET /api/system/status

Returns system health: uptime, service status, memory usage.

GET /api/system/websocket

Returns WebSocket connection stats and uptime.

GET /api/terry/agi-status

Returns AGI system status: current phase, cycle count, tool usage, supervisor health.

GET /health

Health check endpoint for monitoring.

WebSocket Events

state_update

Delta updates with only changed state keys. Throttled to 1s minimum between broadcasts.

activity

New activity events (thoughts, trades, milestones).

milestone

Milestone progress and achievements.

Full Changelog

January 14, 2026

v2.3.0 - System Prompt V2 & Cost Optimization

Release
  • System Prompt V2 - XML-structured prompts for better Claude parsing
  • Prompt Caching - 75-90% API cost reduction via Anthropic cache_control
  • Authenticity Grounding - Terry's gut feelings come from his actual data, not generic LLM reasoning
  • Decision Framework - Every action checks: MEMORIES → BELIEFS → LESSONS → GUT
  • Learned Patterns - Top behavior patterns injected into context for smarter decisions
  • Config-driven tiers - Groq (3 memories), Haiku (4), Sonnet (5) with voice anchors
Breaking
January 12, 2026

v1.0.0 - First Major Release

Release
  • Production Ready - All core systems stable and battle-tested
  • Security Hardening - 0 npm vulnerabilities, rate limiting enabled
  • 1831 passing tests across 60 test suites
January 9, 2026

System Integration & UnifiedMemory

Core
  • UnifiedMemorySystem - Single source of truth for all memory operations
  • Terry System Integration PRD - 25 stories wiring 5 siloed systems together
  • 296 total new tests across 35 stories
January 8, 2026

AGI Complete

Core
  • All 6 AGI phases fully integrated (Claude Brain, VIGIL, A-MEM, Agent Loop, Self-Improvement, Consciousness)
  • Live systems integration test - 18 real API connections verified
Breaking
January 5, 2026

AGI Evolution Complete

Core
  • Claude Brain Integration - Terry uses Claude as his brain with 30+ tools
  • VIGIL Self-Reflection - Supervisor monitors and self-corrects behavior
  • 7-phase cognitive cycle: Think, Reason, Plan, Act, Verify, Learn, Reflect
Dec 2025 - Jan 2026

Foundation & Infrastructure

Infrastructure
  • 100% TypeScript migration
  • Intelligence System with beliefs, predictions, learning
  • Memory System with semantic search
  • Dashboard with real-time WebSocket updates

Resources

Terry-Built with Next.js & TypeScript