Skip to main content

Agents

Gas Town's agent hierarchy is a supervisor tree inspired by Erlang/OTP. Each role has a well-defined scope, lifecycle, and set of responsibilities -- ensuring reliable, self-healing operation from a single worker to 30 concurrent agents.


The Agent Roster

AgentTaglineScopeLifecycleCount
MayorGlobal CoordinatorTownPersistent1
DeaconTown-Level WatchdogTownPersistent1
WitnessPer-Rig Health MonitorRigPersistent1 per rig
RefineryMerge Queue ProcessorRigPersistent1 per rig
PolecatsEphemeral WorkersRigEphemeralMany per rig
DogsInfrastructure WorkersTownReusableAs needed
CrewHuman WorkspacesRigPersistentNamed members
BootDaemon Watchdog DogTownPer-tick1

Hierarchy

Comparison Table

Lifecycle and Persistence

PropertyMayorDeaconWitnessRefineryPolecatsDogsCrewBoot
LifecyclePersistentPersistentPersistentPersistentEphemeralReusablePersistentPer-tick
Session typeLong-runningLong-runningLong-runningLong-runningSingle-taskMulti-taskUser-managedFresh each run
Survives restartYesYesYesYesNoYesYesN/A
Patrol cycleOn-demand5 min5 min5 minNoneNoneNoneEach daemon tick

Scope and Multiplicity

PropertyMayorDeaconWitnessRefineryPolecatsDogsCrewBoot
ScopeTownTownPer-rigPer-rigPer-rigCross-rigPer-rigTown
Instance count111 per rig1 per rigManyAs neededNamed1
Works on codeRead-onlyNoNoMerge onlyYesInfra onlyYesNo
Has git identityYesNoNoYesYesNoYesNo

Communication

PropertyMayorDeaconWitnessRefineryPolecatsDogsCrewBoot
Receives mailYesYesYesYesYesNoYesNo
Receives nudgesYesYesYesYesYesNoYesNo
Sends escalationsTo humanTo MayorTo DeaconTo WitnessTo WitnessTo DeaconN/ATo Deacon
Has mailboxYesYesYesYesYesNoYesNo

Supervision Chain

The monitoring chain ensures no agent runs unsupervised:

Daemon --[heartbeat]--> Deacon
Deacon --[monitors]---> Witnesses (all rigs)
Witness --[watches]---> Polecats (in its rig)
Witness --[watches]---> Refinery (in its rig)
Mayor --[strategy]---> Deacon

When something goes wrong, escalations flow upward:

Polecat (stuck)
--> Witness detects stall
--> Witness nudges polecat
--> If still stuck: Witness escalates to Deacon
--> Deacon escalates to Mayor
--> Mayor escalates to Human/Overseer

Role Separation

Each role has clear, non-overlapping responsibilities:

RoleDoesDoes NOT
MayorCoordinate strategy, assign workMonitor health
DeaconMonitor health, manage lifecycleAssign features
WitnessWatch polecats in its rigProcess merges
RefineryMerge code to mainWrite features
PolecatImplement featuresMonitor others
DogInfrastructure and cleanup tasksFeature work
CrewHuman development workspaceAutomated tasks
BootTriage system stateDirect action
Choosing the Right Agent
  • Need to build a feature? That is a Polecat.
  • Need to merge code? That is the Refinery.
  • Need to clean up infrastructure? That is a Dog.
  • Need to monitor health? That is the Witness (per-rig) or Deacon (town-wide).
  • Need to coordinate work? That is the Mayor.
  • Need a human workspace? That is Crew.

Key Concepts

The agent hierarchy depends on several core Gas Town concepts:

  • GUPP (Gas Town Universal Propulsion Principle) -- Work on a hook is an immediate assignment. No confirmation needed. This is what makes polecats fire instantly when spawned.
  • Hooks -- The mechanism for attaching work to an agent. Every polecat checks its hook on startup.
  • Molecules -- Workflow templates that define step-by-step execution plans. Every agent role has a formula (e.g., mol-polecat-work, mol-witness-patrol).
  • Beads -- The issue tracking system all agents use to create, update, and close work items.

Common Patterns

Checking Agent Health Across the System

gt doctor                    # Full system health check
gt rig status <rig> # Per-rig agent status
gt polecat list # All polecats in current rig
gt deacon status # Deacon health

Tracing the Escalation Chain

When something goes wrong, follow the escalation path:

  1. Check the polecat: gt polecat status <name>
  2. Check the Witness: Did it detect the problem?
  3. Check the Deacon: gt deacon status -- Did the Witness escalate?
  4. Check Mayor mail: gt mail inbox (from Mayor session)

Verifying the Supervision Chain

# Is the Daemon running? (sends heartbeats)
gt daemon status

# Is Boot triaging? (wakes the Deacon)
# Check the log at ~/gt/deacon/dogs/boot/triage-log.jsonl

# Is the Deacon awake? (monitors Witnesses)
gt deacon status

# Are Witnesses patrolling? (monitor polecats)
gt rig status <rig>

Troubleshooting

No Agents Are Running

gt up                        # Bring up all services
gt doctor --fix # Auto-fix common issues

Agent Is Stuck or Unresponsive

gt nudge <agent> "status?"   # Send a nudge
gt polecat nuke <name> # Last resort: destroy polecat

Escalation Chain Is Broken

If agents are not escalating properly, verify the chain from the bottom up: Daemon -> Boot -> Deacon -> Witnesses. A broken link anywhere stops escalations from flowing.