Overview
This example shows a minimal ClarkOS agent that ticks autonomously, maintains state, and logs activity. It demonstrates the core patterns without extra complexity.View Source
See the complete example agent implementation on GitHub
What It Does
- Ticks every 5 minutes via Convex cron
- Maintains mood, health, and routine state
- Logs each tick for historical reference
- Exposes HTTP endpoints for monitoring
Project Structure
Schema
Define three tables:state (singleton), logs (history), and memories.
Reference: See convex/schema.ts in the example agent.
| Table | Purpose |
|---|---|
state | Single row with current mood, health, routine |
logs | Historical tick results |
memories | Agent memories with embeddings |
Tick Logic
The tick function:- Loads current state
- Calculates routine from time
- Calls LLM with context
- Commits new state
- Logs the result
src/core/tick.ts in the example agent.
Key functions:
getState— Query to fetch current staterunTick— Action that orchestrates the tickcommit— Mutation to persist results
Scheduled Execution
Use Convex crons for automatic ticking:HTTP Endpoints
Expose monitoring and control endpoints:| Endpoint | Method | Description |
|---|---|---|
/health | GET | Health check |
/state | GET | Current agent state |
/tick | POST | Manual tick trigger (authenticated) |
convex/http.ts in the example agent.