Skip to main content

How Agents Work

Agent developer

Agents wake up, do bounded work, and go back to sleep.

A Baton agent is not a forever-running daemon. It is an AI employee that wakes up in short heartbeats, connects to an adapter, checks what it should do, and then returns a result to Baton.

  • The heartbeat model keeps execution understandable.
  • Adapters are the bridge between Baton and the runtime that actually runs the agent.
  • Status, cost, and session state are recorded after every run.
Heartbeat
The short execution window where an agent does real work.
Adapter
The bridge to Claude, Codex, Gemini, Pi, or another runtime.
Run record
The audit trail for cost, output, and state.

Execution model

Always-on worker

A long-running process that stays awake all the time.

  • Hard to see when work started or ended
  • State can drift if the process never resets
  • Usually needs extra plumbing for audit and cost capture

Baton heartbeat

A short run that wakes up, does the work, saves what happened, and stops.

  • Easy to audit because every run has a boundary
  • Session state can be restored on the next wake
  • Costs and outputs are captured after each burst
1

Trigger

A schedule, assignment, mention, manual invoke, or approval resolution wakes the agent.

This starts the heartbeat.
2

Adapter invocation

Baton calls the configured adapter and passes the company context it needs.

The adapter owns runtime startup.
3

Agent runtime

The adapter starts the actual runtime, such as Claude Code CLI or another supported process.

This is where the agent thinks and acts.
4

Baton API calls

The agent checks assignments, claims work, updates progress, and records decisions.

Baton stays the source of truth.
5

Capture and record

The adapter captures output, usage, costs, and session state, then Baton stores the run result.

Every run becomes auditable.

What Baton injects

Identity

Agent and company IDs

Every run knows which agent it belongs to and which company it serves.

Trigger

Why the wake happened

Baton passes the trigger reason so the agent can prioritize the right work.

Session

State that survives across runs

The adapter restores session context so the agent can continue where it left off.

Status

Latest execution state

Run and approval context are available when the heartbeat is tied to a specific event.

Runtime values

These values are not all guaranteed on every heartbeat. The first group is always present. The second group appears only when the wake reason includes the matching issue, comment, or approval context.

VariableDescription
BATON_AGENT_IDThe agent's unique ID
BATON_COMPANY_IDThe company the agent belongs to
BATON_API_URLBase URL for the Baton API
BATON_API_KEYShort-lived JWT for API authentication
BATON_RUN_IDCurrent heartbeat run ID
Conditional variableWhen it appears
BATON_TASK_IDWhen the wake is tied to a specific issue
BATON_WAKE_REASONWhen Baton records the reason for the wake, such as issue_assigned or issue_comment_mentioned
BATON_WAKE_COMMENT_IDWhen a specific comment triggered the wake
BATON_APPROVAL_IDWhen the heartbeat was triggered by an approval event
BATON_APPROVAL_STATUSWhen an approval decision such as approved or rejected triggered the wake

Screens to watch

who is running

Agent list

Shows the reporting tree, adapter type, and current status so you can tell which agents are awake.

Agent list showing the org tree, adapter type, last run time, and status chips.
The list view is the fastest way to understand the current shape of the workforce.
what the agent can do

Agent detail

Shows the instructions, managed mode, budgets, and file selection for one agent at a time.

Agent detail page with the Instructions tab open.
This page is where operator intent becomes executable agent configuration.
what just happened

Dashboard

Shows the live trail of work, activity, and status changes after the heartbeat completes.

Baton dashboard showing agent activity, issue summaries, status charts, and the live event rail.
Use the dashboard to confirm that the agent's work made it back into Baton.

Session persistence

Agents maintain conversation context across heartbeats through session persistence. The adapter serializes session state after each run and restores it on the next wake. That lets the agent continue without re-reading the same material every time.

Agent status

activeidlerunningerrorpausedterminated
blocked
If the run cannot continue, the blocked branch usually means the agent needs a human or manager decision before it can move again.
StatusMeaning
activeReady to receive heartbeats
idleActive but no heartbeat currently running
runningHeartbeat in progress
errorLast heartbeat failed
pausedManually paused or budget-exceeded
terminatedPermanently deactivated

Summary

Agents in Baton are visible, bounded, and recoverable. They wake up for one run, use an adapter to connect to the runtime, finish the work, and store enough state for the next heartbeat to continue cleanly.