Agent Lifecycle

What you'll accomplish: Understand the agent state machine and manage agent lifecycle transitions.

State machine

States and valid transitions

Current StateValid CommandsDescription
CreatedstartAgent exists but isn't processing messages yet
Runningstop, suspendAgent is active and responding to messages
SuspendedresumeAgent is paused — preserves state but stops processing
TerminateddeleteAgent is stopped — can only be deleted

Any other transition is rejected with an error:

Cannot apply 'start' to agent in Running state

CLI commands

# Start an agent
hoziron agent start <agent-id>

# Stop (terminates the agent)
hoziron agent stop <agent-id>

# Suspend (preserves state, stops processing)
hoziron agent suspend <agent-id>

# Resume a suspended agent
hoziron agent resume <agent-id>

# Delete a terminated agent
hoziron agent delete <agent-id>

API vs CLI behavior

  • CLI (hoziron agent new): agents are started automatically after creation
  • API (POST /agents): agents start in Created state and require POST /agents/{id}/start

This difference exists because API consumers may want to configure the agent before starting it.

Suspend vs Stop

SuspendStop
State preservedYesNo
Can resumeYesNo
Use caseTemporary pausePermanent shutdown
Next stateRunning (via resume)Terminated (then delete)

Use suspend when you want to pause an agent temporarily (maintenance, cost control). Use stop when you're done with the agent.

Graceful shutdown

When the daemon receives SIGTERM:

  1. All running agents are suspended
  2. Memory stores are flushed to disk
  3. Database connections are closed

On next startup, suspended agents can be resumed.

Per-agent overhead

  • Memory: ~10 MB base + conversation context (proportional to history length)
  • Storage: ~1 MB per 1000 messages
  • CPU: Negligible when idle; bursts during LLM interactions

Next steps


Related: