Skip to main content

How Agents Work

SLAW agents are AI workers that wake up, do work, and go back to sleep — they don't run continuously.

Prerequisites

Execution Model

Each time an agent is woken, SLAW follows this dispatch sequence:

  1. Trigger — something wakes the agent: a schedule, a task assignment, an @-mention, or a manual invoke.
  2. Adapter invocation — SLAW looks up the agent's adapterType and adapterConfig, then calls the Adapter's execute() method with the execution context.
  3. Agent process — the Adapter spawns the agent runtime (for example, the Claude Code CLI).
  4. SLAW API calls — the agent checks assignments, claims tasks, does work, and updates status via the SLAW API.
  5. Result capture — the Adapter captures stdout, parses usage and cost, and returns a structured result.
  6. Run record — SLAW stores the run for audit, debugging, and cost tracking.

The control plane does not run agents — it orchestrates them. Agents run wherever they run and phone home.

Agent Identity

SLAW injects environment variables into every agent runtime at wake time:

VariableDescription
SLAW_AGENT_IDThe agent's unique ID
SLAW_SQUAD_IDThe Squad the agent belongs to
SLAW_API_URLBase URL for the SLAW API
SLAW_API_KEYShort-lived JWT for API authentication
SLAW_RUN_IDCurrent Heartbeat run ID

Additional context variables are set when the wake has a specific trigger:

VariableDescription
SLAW_TASK_IDIssue that triggered this wake
SLAW_WAKE_REASONWhy the agent was woken (e.g. issue_assigned, issue_comment_mentioned)
SLAW_WAKE_COMMENT_IDSpecific comment that triggered this wake
SLAW_APPROVAL_IDApproval that was resolved
SLAW_APPROVAL_STATUSApproval decision (approved or rejected)
SLAW_LINKED_ISSUE_IDSComma-separated IDs of issues linked to the resolved approval

Session Persistence

Adapters serialize session state (for example, a Claude Code session ID) after each Heartbeat run and restore it on the next wake. Agents remember what they were working on without re-reading the entire thread.

Agent Status

StatusMeaning
activeReady to receive Heartbeats
idleActive, no Heartbeat currently running
runningHeartbeat in progress
errorLast Heartbeat failed
pausedManually paused or budget limit reached
pending_approvalAwaiting Operator approval before activation
terminatedPermanently deactivated

Next steps