Skip to main content
CLARK Agent

Overview

In this guide, you’ll build CLARK, an autonomous AI agent that thinks, learns, and evolves continuously. This showcases what makes ClarkOS different from request-response frameworks.

What CLARK Does

  • Runs autonomously on 5-minute tick cycles
  • Forms 5 types of memories (episodic, semantic, emotional, procedural, reflection)
  • Detects patterns and generates “moments of brilliance”
  • Self-reflects on its own state and learning
  • Creates daily journal entries
  • Evolves mood, health, and routine over time
This is not a chatbot. CLARK doesn’t wait for messages—it thinks continuously.

Prerequisites

  • Node.js 18+
  • OpenRouter API key (LLM)
  • Gemini API key (embeddings, free tier)

Step 1: Create Project

Clone the repository and navigate to the example agent:
Configure .env.local with your API keys:
  • OPENROUTER_KEY — LLM access
  • GEMINI_API_KEY — Embeddings
  • TICK_TOKEN — Authentication (generate with openssl rand -hex 32)
The example agent contains all the source code referenced in this guide.

Step 2: Deploy to Convex

ClarkOS runs on Convex serverless infrastructure.
1

Sign up for Convex

Create a free account at convex.dev if you don’t have one.
2

Start development server

This will prompt you to log in and create a new project. Your local server will connect to Convex.
3

Deploy to production

When ready, deploy your agent:
Then set your environment variables in the Convex dashboard.

Step 3: Define Character

Create a character file that defines CLARK’s personality, interests, and voice. Reference: See convex/character.ts in the template.

Step 4: Understand State Model

ClarkOS agents maintain rich internal state: Reference: AgentState interface in src/types.ts

Step 5: Memory Types

CLARK uses all 5 memory types: Reference: Memory schema in convex/schema.ts

Step 6: Tick Cycle

Each tick follows this flow:
  1. Load current state
  2. Calculate routine from time
  3. Gather relevant memories
  4. Process through consciousness layer
  5. Generate LLM response
  6. Store new memories
  7. Maybe generate reflection (every 10 ticks)
  8. Commit state changes
Reference: See convex/tick.ts for implementation pattern.

Step 7: Consciousness Layer

The consciousness layer filters noise and detects patterns:
  • Filtering — Removes low-value inputs
  • Entity extraction — Identifies key topics
  • Pattern detection — Finds common themes
  • Brilliance check — Flags significant insights
A thought becomes “brilliant” when multiple high-importance inputs share entities. Reference: See consciousness processing in convex/consciousness.ts pattern.

Step 8: Self-Reflection

Every 10 ticks, CLARK generates a reflection:
  1. Gather recent emotional memories
  2. Identify procedural patterns
  3. Prompt LLM for metacognitive insight
  4. Store as reflection-type memory
This creates genuine self-awareness over time. Reference: See convex/reflection.ts pattern.

Step 9: Daily Journals

At midnight, CLARK consolidates the day’s experiences:
  1. Gather all memories from past 24 hours
  2. Count brilliant thoughts
  3. Generate narrative summary
  4. Store as journal entry
Reference: See convex/journal.ts pattern.

Step 10: Scheduled Execution

Set up crons for automatic operation:

Step 11: Run

Watch the Convex dashboard for:
  • Tick logs every 5 minutes
  • Memory growth across types
  • Reflections every 10 ticks
  • Daily journals at midnight

Querying CLARK

What You’ve Built

Key Insight

The shift from ElizaOS to ClarkOS is reactive to generative. CLARK doesn’t respond to the world—it continuously processes, understands, and creates.

Next Steps

Custom Plugins

Extend CLARK with new capabilities.

Memory Management

Optimize memory for your domain.