Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Core Concepts Overview

Tinytown has exactly 5 core types. That’s it. No more, no less.

┌─────────────────────────────────────────┐
│           Your Application              │
└──────────────┬──────────────────────────┘
               │
        ┌──────▼───────┐
        │    Town      │  ← Orchestrator
        └──────┬───────┘
               │
        ┌──────▼──────────────────┐
        │   Channel (Redis)       │  ← Message passing
        └──────┬──────────────────┘
               │
    ┌──────────┼──────────────┐
    ▼          ▼              ▼
┌────────┐ ┌────────┐    ┌────────┐
│ Agent  │ │ Agent  │ .. │ Agent  │  ← Workers
└───┬────┘ └───┬────┘    └───┬────┘
    │          │              │
    ▼          ▼              ▼
  Tasks      Tasks          Tasks      ← Work units

The 5 Core Types

TypeWhat It IsRedis Key Pattern
TownThe orchestrator that manages everythingN/A (local)
AgentA worker that executes taskstt:<town>:agent:<id>
TaskA unit of work with lifecyclett:<town>:task:<id>
MessageCommunication between agentsTransient
ChannelRedis-based message transporttt:<town>:inbox:<id>

How They Work Together

1. Town Orchestrates

The Town is your control center. It:

  • Starts and manages Redis
  • Spawns and tracks agents
  • Provides the API for coordination
tt init my-project
tt status

2. Agents Execute

Agents are workers. Each agent has:

  • A unique ID
  • A name (human-readable)
  • A model (claude, auggie, codex, etc.)
  • A state (starting, idle, working, stopped)
tt spawn worker-1 --model claude
tt list

3. Tasks Represent Work

Tasks are what agents work on. Each task has:

  • A description
  • A state (pending → assigned → running → completed/failed)
  • An assigned agent
tt assign worker-1 "Implement the login API"
tt tasks

4. Messages Coordinate

Messages are how agents communicate. They carry:

  • Sender and recipient
  • Message type (TaskAssign, TaskDone, StatusRequest, etc.)
  • Priority (Low, Normal, High, Urgent)
tt send worker-1 "Please update the README"
tt send worker-1 --urgent "Critical bug in production!"

5. Channel Transports

The Channel is the Redis connection that moves messages. It provides:

  • Priority queues (urgent messages go first)
  • Blocking receive (agents wait efficiently)
  • State persistence (survives restarts)

Mental Model

Think of it like a small company:

TinytownCompany Analogy
TownThe office building
AgentAn employee
TaskA work ticket
MessageAn email/Slack message
ChannelThe email/Slack system

What’s NOT in Tinytown

Deliberately excluded to keep things simple:

  • Workflow DAGs — Just assign tasks directly
  • Recovery daemons — Redis persistence handles crashes
  • Multi-tier databases — One Redis instance
  • Complex agent hierarchies — All agents are peers

If you need these, you can build them on top of Tinytown’s primitives, or use a more complex system like Gastown.

Next Steps

Deep dive into each type: