Agents
How-to

Manage the Agent lifecycle

Move an Agent safely between Idle, Running, and Error states, apply restart-required changes, recover failures, and retire it when finished.

For
Agent operators, Agent editors, Agent owners, Organization administrators, and support engineers
On this page
  1. Overview
  2. Lifecycle model
  3. State after creation
  4. Before you begin
  5. 1. Start an Agent
  6. 2. Pause an Agent
  7. 3. Restart an Agent
  8. 4. Apply configuration changes
  9. 5. Recover an Agent
  10. 6. Retire an Agent
  11. Events and retained history
  12. API behavior
  13. Operational checklist
  14. Troubleshooting
  15. Next steps

The Agent lifecycle controls whether an Agent has an active Runtime, whether it can receive work, and when configuration changes take effect.

Agent Barn persists three lifecycle states — STOPPED, RUNNING, and ERROR — and the web interface presents them with operator-oriented labels such as Idle, Working, and Needs attention.

Overview

Lifecycle state and Runtime health answer different questions:

  • Lifecycle state records whether Agent Barn considers the Agent stopped, running, or in error.
  • Runtime health reports whether the live Runtime pod and communication-platform connection are working right now.

A Running Agent may display Initializing, Working, Disconnected, or Needs attention depending on its health. An Agent persisted in ERROR displays Needs attention.

A successful Start does more than resume an existing process: Agent Barn re-renders the current pinned configuration and reconciles the Agent's managed Runtime resources. A Pause removes the active Runtime while retaining the Agent's product configuration and persistent working data.

Lifecycle model

Each row below is one transition, written as the starting state, the operation, and the resulting state.

  • Create Agent Create STOPPED
  • STOPPED Start RUNNING or ERROR
  • ERROR Start RUNNING or ERROR
  • RUNNING Pause STOPPED
  • RUNNING Apply & Restart RUNNING or ERROR
  • STOPPED, RUNNING, or ERROR Retire Agent Retired

The table describes the same transitions, including the states in which a configuration change does not move the Agent.

Current state Operation Result
StoppedStartRunning, or Error if startup fails
ErrorStartRunning, or Error if the cause remains
RunningPauseStopped
RunningApply & RestartStopped, updated, then Running or Error
StoppedApply configurationRemains Stopped
ErrorApply configurationRemains Error until a Start succeeds
Any non-deleted stateRetire AgentThe Agent is retired and no longer accessible as an active Agent

Starting an already Running Agent is a conflict, and pausing an Agent that is not Running is also a conflict. The web interface hides or replaces invalid lifecycle actions based on the current state.

State after creation

An Agent's initial state depends on the creation path and the platform.

Creation path Platform Expected behavior
Web hire wizardSlackThe post-hire access panel starts the Agent after Save or Skip for now
Web hire wizardTelegramThe post-hire access panel starts the Agent after Save or Skip for now
Web hire wizardDiscordThe Agent is created Idle and must be started from its Agent page
Direct APISlackThe Agent is created Stopped
Direct APITelegramThe Agent is created Stopped
Direct APIDiscordThe Agent is created Stopped
Direct APIMicrosoft TeamsCreation continues into Start

Closing the Slack or Telegram post-hire access panel, instead of saving it or selecting Skip for now, can leave the Agent Idle.

The current web hire wizard does not expose Microsoft Teams.

Before you begin

You need:

  • Access to the Organization that owns the Agent
  • Access to the Agent
  • Lifecycle permission for Start and Pause
  • A valid pinned Template version
  • A model that remains allowed by the Organization
  • Valid communication-platform credentials
  • Required integration credentials
  • A supported Runtime and platform combination
  • A maintenance window, before interrupting active work
Role or Permission Lifecycle authority
Agent ViewerCannot Start or Pause
Agent EditorCan manage lifecycle
Agent OwnerCan manage lifecycle and retire the Agent
Organization AdministratorHas implicit full Agent authority
Organization OwnerHas implicit full Agent authority
agent.lifecycle.manageAuthorizes both Start and Pause
agent.deleteAuthorizes retirement

Start an Agent

Open the Agent from the Organization's Home page.

A Stopped Agent shows the status Idle and a Start action. An Agent in Error shows Needs attention and the same Start action.

Select Start. The action changes to Starting… while the request is in progress.

What Start does

Agent Barn renders and reconciles the following:

  • Confirms lifecycle permission
  • Rejects the request if the Agent is already Running
  • Loads the exact pinned Template version
  • Renders Template placeholders using the Agent identity
  • Confirms the configured model is still allowed by the Organization
  • Decrypts the required platform and integration credentials
  • Loads the Agent's pinned Skill versions
  • Selects the Hermes or OpenClaw builder
  • Generates a fresh ingest key
  • Generates platform-routing and mention-gating configuration
  • Reconciles the managed configuration, Secret, storage, Service, and Deployment
  • Changes the persisted state to Running and clears a previous lifecycle error
  • Emits the agent.started Domain Event

Expected: The Agent briefly displays Initializing while its pod and platform connection become ready, then Working. Continue only once it reads Working.

Starting can also enter Error when credential checks or Runtime resource creation fail.

Start from Error

Start is the recovery transition from Error. A successful Start rebuilds the Runtime resources, generates fresh Runtime and ingest configuration, changes the state to Running, and clears the previous error.

If the underlying problem remains, the Agent returns to or stays in Error.

Pause an Agent

Open a Running Agent. The page shows its Runtime health, such as Working, and a Pause action.

Select Pause. The action changes to Pausing… while Agent Barn stops the Runtime.

What Pause does

Agent Barn attempts to:

  1. Capture a final Runtime Log snapshot.
  2. Remove the active Runtime Deployment.
  3. Remove the active generated ConfigMap and Kubernetes Secret.
  4. Mark the Agent Stopped.
  5. Emit the agent.stopped Domain Event.

The UI then displays the status:

Status after Pause
Idle

What Pause preserves

Preserved Behavior
Agent identityName, Organization, creator, Runtime, and platform remain
TemplateThe exact Template version pin remains
SkillsThe exact Skill version pins remain
ModelThe configured model remains
CredentialsEncrypted product credentials remain
Platform policyChannel, group, user, and direct-message settings remain
Agent AccessDirect assignments and General access remain
ConversationsExisting telemetry records remain
Tool callsExisting Tool-call records remain
CostsHistorical attribution remains
Persistent Runtime storageThe Agent workspace and persistent memory remain
LogsAgent Barn attempts to save a stopped-session snapshot

Pause does not retire the Agent, and it does not release its Slack or Discord bot token for another active Agent.

Effects of Pause

While the Agent is Idle, it has no active Runtime Deployment, cannot receive or process new platform work, and does not execute scheduled Runtime work. Configuration can be applied without an automatic restart, and the Agent can be started again later.

Restart an Agent

The current Agent detail page does not provide a separate Restart button. Pause followed by Start is the manual restart path.

To restart without changing configuration:

  1. Open the Agent.
  2. Select Pause.
  3. Wait for the status to become Idle.
  4. Select Start.
  5. Wait for the status to become Working.
  6. Send a controlled platform verification message.

Restarting causes Agent Barn to regenerate Runtime configuration from the current persisted Agent state. It is useful after a recoverable platform outage, external credential rotation, platform permission changes, Runtime health degradation, changes outside Agent Barn that require the platform connection to be rebuilt, or a controlled maintenance window.

Restarting does not change the Runtime, platform, Template pin, Skill pins, model, or Agent Access unless you apply those supported changes separately.

What a restart refreshes

  • Rendered Template files
  • Generated Runtime configuration
  • Platform-routing rules and mention gating
  • Integration context
  • The Runtime Kubernetes Secret and ConfigMap
  • The Deployment
  • The ingest key

Persistent Runtime storage remains associated with the Agent unless the Agent is retired.

Apply configuration changes

Open the Agent and select Configuration. Agent Barn uses state-aware apply actions.

Agent state Button Behavior
RunningApply & RestartPauses the Agent, applies the change, and starts it again
StoppedApplySaves the change and leaves the Agent Idle
ErrorApplySaves the change; select Start afterward

Sections that can require Apply or Apply & Restart include profile and model, Hermes command approval, Template selection, platform routing, Skills, keys and integrations, and published Agent Template Override selection.

Apply & Restart

For a Running Agent:

  1. Select Edit in the relevant configuration section.
  2. Make the change.
  3. Select Apply & Restart.
  4. Review the confirmation dialog and confirm the action.
  5. Wait for the Agent to return to Working.
  6. Verify the changed behavior.

Agent Barn stops the Agent before sending the update, because direct Agent configuration update is rejected while the Agent is Running.

If the update fails, the UI still attempts to start the Agent again. That prevents a failed edit from leaving a previously Running Agent stopped solely because the update did not apply, and the previous persisted configuration remains in effect.

Apply while Stopped

  1. Open Configuration.
  2. Edit the required section.
  3. Select Apply and confirm the change.
  4. Return to the Agent detail page.
  5. Select Start when ready.

Apply does not automatically start an Agent that was already Stopped.

Apply while in Error

An Agent in Error is not Running, so its configuration changes use Apply rather than Apply & Restart. Correct the configuration, apply it, then select Start.

Recover an Agent

An Agent can require recovery when start-time credential validation fails, the configured model is no longer allowed, a required Runtime resource cannot be created, the Runtime image cannot be pulled, Kubernetes cannot schedule the pod, a platform connection fails, the live Runtime crashes, or an integration or Tool repeatedly fails.

Determine the persisted state

Needs attention can represent more than one situation, and the available lifecycle action tells you which one.

Situation Lifecycle action shown Recovery path
Persisted ErrorStartCorrect the configuration, then Start
Running Agent with crashed healthPausePause, correct the configuration if needed, then Start
Running but disconnectedPauseReview Logs and connectivity, then restart if required

Recovery procedure

  1. Open the Agent.
  2. Read the error reason shown near the Agent header.
  3. Open Logs.
  4. Identify whether the failure relates to credentials, model access, Runtime resources, platform connectivity, or a Tool.
  5. Open Configuration if a persisted value must change.
  6. Apply the correction.
  7. If the Agent is still Running, use Apply & Restart, or Pause followed by Start.
  8. If the Agent is in Error or Idle, select Start.
  9. Wait for Working.
  10. Send a controlled platform verification message.
  11. Confirm that Conversations and Tool calls are reaching Agent Barn.

Common recovery decisions

Failure Recommended action
Model removed from the Organization allowlistSelect an allowed model, Apply, then Start
Slack token invalidReplace the Slack platform credentials and restart
Telegram token invalidReplace the bot token and restart
Discord bot cannot read messagesEnable Message Content Intent and restart
Discord role restrictions failEnable Server Members Intent and restart
Image pull failsCorrect registry access or image configuration, then Start
Pod cannot scheduleCorrect namespace capacity, storage, or scheduling constraints
Skill credential failsCorrect the Agent Secret or Shared Credential and restart
Runtime health is crashedPause, review Logs, then Start after correcting the cause

A Runtime crash is not the same as a successful Pause. It does not represent an intentional transition to Stopped.

Retire an Agent

Retirement permanently removes the Agent from active use. It requires Agent delete permission, normally available to an Agent Owner, and can be initiated from any non-deleted state.

Open Configuration → Danger zone, select Retire Agent, then review the confirmation and select Retire Agent again.

Before retiring

  • Confirm that the correct Agent is selected
  • Announce the shutdown to affected users
  • Stop new platform work
  • Review Conversations and Tool calls
  • Export or record any required operational evidence
  • Review costs
  • Review live Logs
  • Pause the Agent if a final stopped-session Log snapshot matters
  • Confirm that a replacement Agent is already verified
  • Confirm that the platform bot token may be released

Retirement cannot be undone

Agent Barn has no restore workflow for a retired Agent. Its configuration cannot be recovered through the UI, and the Agent cannot be returned to an active state.

To operate the same behavior again, create a replacement Agent and reproduce its Template pin, Runtime, platform, model, Skill pins, credentials, platform access, and Agent Access.

What retirement removes

Agent Barn deletes the Agent's managed Deployment, Service, persistent volume, Kubernetes Secret, and ConfigMap, then soft-deletes the Agent record. It also:

  • Attempts to block the Agent's LiteLLM key
  • Releases the active Slack bot-token hash, where applicable
  • Releases the active Discord bot-token hash, where applicable
  • Removes the Agent from normal active-Agent views
  • Prevents the configuration from being restored through the UI

Historical records may remain internally for cost attribution and related history, but the retired Agent is not available as an active or restorable Agent.

Pause before retirement

Retirement can be initiated while an Agent is Running, and it does not run the normal Pause workflow first. Pause before retiring when you need Agent Barn to attempt a final stopped-session Log snapshot.

Events and retained history

Successful lifecycle operations produce internal Domain Events.

Action Operational result
Start succeedsEmits agent.started; the Agent transitions to Running
Pause succeedsEmits agent.stopped; the Agent transitions to Stopped
Start failsNo successful started transition; the Agent may remain Stopped or enter Error
Runtime crashesNot a successful stopped transition; health may display Needs attention
Retire succeedsThe Agent is soft-deleted and its Runtime resources are removed

When event delivery and transactional email are configured, lifecycle email notifications are sent to the Agent Creator and to users with Agent Owner access, de-duplicated by email address.

Organization Owners and Administrators hold implicit Agent authority, but lifecycle notification recipients are determined by creator and Agent Owner targeting rather than by Organization role.

API behavior

The web application uses these Organization-scoped lifecycle operations. The user-facing Pause action maps to the stop operation.

Operation Valid current state Result
POST /agents/{agent_id}/startStopped or ErrorRunning or Error
POST /agents/{agent_id}/startRunning409 Conflict
POST /agents/{agent_id}/stopRunningStopped
POST /agents/{agent_id}/stopStopped or Error409 Conflict
PATCH /agents/{agent_id}Stopped or ErrorApplies supported configuration
PATCH /agents/{agent_id}Running409 Conflict
DELETE /agents/{agent_id}Any non-deleted stateRetires the Agent

There is no separate restart endpoint. Clients implement restart as two calls:

Restart sequence
POST stop
POST start

Start

Start request
POST /api/v1/organizations/{organization_id}/agents/{agent_id}/start

Pause

The UI calls this operation when the user selects Pause:

Pause request
POST /api/v1/organizations/{organization_id}/agents/{agent_id}/stop

Retire

Retire request
DELETE /api/v1/organizations/{organization_id}/agents/{agent_id}

API clients must:

  • Send the authenticated Organization context
  • Respect server-computed Agent Permissions
  • Treat 409 Conflict as a stale or invalid lifecycle transition
  • Refetch the Agent before deciding whether to retry
  • Avoid issuing concurrent lifecycle operations

Operational checklist

Before Start

  • The Template pin is correct
  • The Skill pins are correct
  • The model remains allowed
  • Platform credentials are valid
  • Required provider credentials exist
  • Runtime and platform are compatible
  • The platform access policy is intentional
  • A maintenance or test location is ready

After Start

  • The Agent reaches Working
  • An allowed explicit mention receives a response
  • An unmentioned shared message receives no response
  • Conversations report inbound and outbound messages
  • Expected Tool calls complete successfully
  • Logs contain no unresolved startup errors

Before Pause or restart

  • No consequential task is in progress
  • Scheduled work can be interrupted
  • Users have been notified
  • Important live Logs have been reviewed
  • A controlled verification prompt is ready for the restart

Before retirement

  • The replacement Agent is verified
  • Required activity and cost evidence has been reviewed
  • Final Logs have been reviewed
  • The Agent has been Paused if a final snapshot matters
  • Token reuse is understood
  • An Agent Owner has confirmed the irreversible action

Troubleshooting

Start fails

Check model access, credentials, and Runtime resources

Review the error reason and the Agent Logs, then confirm that:

  • The configured model remains allowed by the Organization
  • Platform credentials are valid
  • The Runtime and platform are compatible
  • Required integration credentials exist
  • The Runtime image is available
  • Kubernetes can create the Agent resources
  • Persistent storage can be provisioned
  • The Agent's namespace has sufficient capacity

Correct the problem, Apply the required configuration, and select Start again.

The Agent stays Initializing

Persisted as Running, health not yet confirmed

Initializing means the Agent is persisted as Running, but health has not yet confirmed that the Runtime is ready. Allow time for pod scheduling, image download, volume attachment, Runtime startup, platform authentication, and health endpoint initialization.

If Initializing persists, open Logs and inspect the Agent pod.

The Agent displays Disconnected

Health cannot confirm a working connection

Disconnected means the Agent is persisted as Running but its health endpoint cannot confirm a healthy connection. Review platform availability, platform credentials, network connectivity, Runtime Logs, Kubernetes readiness, and health endpoint reachability.

Use Pause followed by Start when rebuilding the connection is appropriate.

Needs attention is shown, but only Pause is available

Still persisted as Running

The Agent is still persisted as Running while its live health reports a crash or error. Select Pause, correct the underlying issue, then select Start.

An Agent persisted in Error displays Start instead, and needs no Pause.

Apply & Restart fails during the update

The UI still attempts the restart

For a previously Running Agent, the UI attempts to start it again even when the configuration update fails. Confirm:

  • Whether the change was actually saved
  • Whether the previous configuration remains active
  • Whether the Agent returned to Working
  • Whether Logs show a separate restart failure

Do not assume that a failed update left the Agent stopped.

The Agent remains Idle after Apply

Apply does not start a stopped Agent

Apply does not start an Agent that was already Stopped or in Error. Return to the Agent detail page and select Start.

Running Agents use Apply & Restart instead.

Start returns a conflict

The Agent is already Running

Starting an already Running Agent returns 409 Conflict.

Refetch the Agent and review its live health. If a restart is required, Pause it first and wait for the transition to complete.

Pause returns a conflict

The Agent is not Running

Pausing an Agent that is Stopped or in Error returns 409 Conflict.

Refetch the Agent. Do not retry Pause unless its persisted state is Running.

Logs are missing after Pause

Log capture is best effort

Capture can fail when:

  • The pod is already unavailable
  • Kubernetes cannot return the Logs
  • The Runtime produced no output
  • The Agent crashed before capture
  • The operator retired the Agent without pausing it first

Review important live Logs before planned maintenance or retirement.

The retired Agent cannot be restored

Retirement has no restore workflow

Create a replacement Agent and reconfigure its Template and exact version, Runtime, platform, model, Skills and versions, credentials, platform access, and Agent Access.

Verify the replacement before sending production work to it.

A Slack or Discord token can be reused after retirement

Retirement clears active token uniqueness

Retirement clears the active token-uniqueness record for that Slack or Discord bot token, so the token can then be assigned to another active Agent on the same platform.

Confirm that the retired Runtime resources are gone, and that no external platform installation still routes unexpected traffic, before reusing it.

Next steps

After establishing the lifecycle procedure:

Documentation