
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:.env.local with your API keys:
OPENROUTER_KEY— LLM accessGEMINI_API_KEY— EmbeddingsTICK_TOKEN— Authentication (generate withopenssl rand -hex 32)
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
3
Deploy to production
Step 3: Define Character
Create a character file that defines CLARK’s personality, interests, and voice. Reference: Seeconvex/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:- Load current state
- Calculate routine from time
- Gather relevant memories
- Process through consciousness layer
- Generate LLM response
- Store new memories
- Maybe generate reflection (every 10 ticks)
- Commit state changes
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
convex/consciousness.ts pattern.
Step 8: Self-Reflection
Every 10 ticks, CLARK generates a reflection:- Gather recent emotional memories
- Identify procedural patterns
- Prompt LLM for metacognitive insight
- Store as reflection-type memory
convex/reflection.ts pattern.
Step 9: Daily Journals
At midnight, CLARK consolidates the day’s experiences:- Gather all memories from past 24 hours
- Count brilliant thoughts
- Generate narrative summary
- Store as journal entry
convex/journal.ts pattern.
Step 10: Scheduled Execution
Set up crons for automatic operation:Step 11: Run
- 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.