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 AgentCreateSTOPPED -
STOPPEDStartRUNNING or ERROR -
ERRORStartRUNNING or ERROR -
RUNNINGPauseSTOPPED -
RUNNINGApply & RestartRUNNING or ERROR -
STOPPED, RUNNING, or ERRORRetire AgentRetired
The table describes the same transitions, including the states in which a configuration change does not move the Agent.
| Current state | Operation | Result |
|---|---|---|
| Stopped | Start | Running, or Error if startup fails |
| Error | Start | Running, or Error if the cause remains |
| Running | Pause | Stopped |
| Running | Apply & Restart | Stopped, updated, then Running or Error |
| Stopped | Apply configuration | Remains Stopped |
| Error | Apply configuration | Remains Error until a Start succeeds |
| Any non-deleted state | Retire Agent | The 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 wizard | Slack | The post-hire access panel starts the Agent after Save or Skip for now |
| Web hire wizard | Telegram | The post-hire access panel starts the Agent after Save or Skip for now |
| Web hire wizard | Discord | The Agent is created Idle and must be started from its Agent page |
| Direct API | Slack | The Agent is created Stopped |
| Direct API | Telegram | The Agent is created Stopped |
| Direct API | Discord | The Agent is created Stopped |
| Direct API | Microsoft Teams | Creation 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 Viewer | Cannot Start or Pause |
| Agent Editor | Can manage lifecycle |
| Agent Owner | Can manage lifecycle and retire the Agent |
| Organization Administrator | Has implicit full Agent authority |
| Organization Owner | Has implicit full Agent authority |
agent.lifecycle.manage | Authorizes both Start and Pause |
agent.delete | Authorizes 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.startedDomain 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:
- Capture a final Runtime Log snapshot.
- Remove the active Runtime Deployment.
- Remove the active generated ConfigMap and Kubernetes Secret.
- Mark the Agent Stopped.
- Emit the
agent.stoppedDomain Event.
The UI then displays the status:
IdleWhat Pause preserves
| Preserved | Behavior |
|---|---|
| Agent identity | Name, Organization, creator, Runtime, and platform remain |
| Template | The exact Template version pin remains |
| Skills | The exact Skill version pins remain |
| Model | The configured model remains |
| Credentials | Encrypted product credentials remain |
| Platform policy | Channel, group, user, and direct-message settings remain |
| Agent Access | Direct assignments and General access remain |
| Conversations | Existing telemetry records remain |
| Tool calls | Existing Tool-call records remain |
| Costs | Historical attribution remains |
| Persistent Runtime storage | The Agent workspace and persistent memory remain |
| Logs | Agent 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:
- Open the Agent.
- Select Pause.
- Wait for the status to become Idle.
- Select Start.
- Wait for the status to become Working.
- 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 |
|---|---|---|
| Running | Apply & Restart | Pauses the Agent, applies the change, and starts it again |
| Stopped | Apply | Saves the change and leaves the Agent Idle |
| Error | Apply | Saves 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:
- Select Edit in the relevant configuration section.
- Make the change.
- Select Apply & Restart.
- Review the confirmation dialog and confirm the action.
- Wait for the Agent to return to Working.
- 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
- Open Configuration.
- Edit the required section.
- Select Apply and confirm the change.
- Return to the Agent detail page.
- 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 Error | Start | Correct the configuration, then Start |
| Running Agent with crashed health | Pause | Pause, correct the configuration if needed, then Start |
| Running but disconnected | Pause | Review Logs and connectivity, then restart if required |
Recovery procedure
- Open the Agent.
- Read the error reason shown near the Agent header.
- Open Logs.
- Identify whether the failure relates to credentials, model access, Runtime resources, platform connectivity, or a Tool.
- Open Configuration if a persisted value must change.
- Apply the correction.
- If the Agent is still Running, use Apply & Restart, or Pause followed by Start.
- If the Agent is in Error or Idle, select Start.
- Wait for Working.
- Send a controlled platform verification message.
- Confirm that Conversations and Tool calls are reaching Agent Barn.
Common recovery decisions
| Failure | Recommended action |
|---|---|
| Model removed from the Organization allowlist | Select an allowed model, Apply, then Start |
| Slack token invalid | Replace the Slack platform credentials and restart |
| Telegram token invalid | Replace the bot token and restart |
| Discord bot cannot read messages | Enable Message Content Intent and restart |
| Discord role restrictions fail | Enable Server Members Intent and restart |
| Image pull fails | Correct registry access or image configuration, then Start |
| Pod cannot schedule | Correct namespace capacity, storage, or scheduling constraints |
| Skill credential fails | Correct the Agent Secret or Shared Credential and restart |
| Runtime health is crashed | Pause, 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 succeeds | Emits agent.started; the Agent transitions to Running |
| Pause succeeds | Emits agent.stopped; the Agent transitions to Stopped |
| Start fails | No successful started transition; the Agent may remain Stopped or enter Error |
| Runtime crashes | Not a successful stopped transition; health may display Needs attention |
| Retire succeeds | The 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}/start | Stopped or Error | Running or Error |
POST /agents/{agent_id}/start | Running | 409 Conflict |
POST /agents/{agent_id}/stop | Running | Stopped |
POST /agents/{agent_id}/stop | Stopped or Error | 409 Conflict |
PATCH /agents/{agent_id} | Stopped or Error | Applies supported configuration |
PATCH /agents/{agent_id} | Running | 409 Conflict |
DELETE /agents/{agent_id} | Any non-deleted state | Retires the Agent |
There is no separate restart endpoint. Clients implement restart as two calls:
POST stop
POST start
Start
POST /api/v1/organizations/{organization_id}/agents/{agent_id}/start
Pause
The UI calls this operation when the user selects Pause:
POST /api/v1/organizations/{organization_id}/agents/{agent_id}/stop
Retire
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: