Back to Eliza

Autonomy API

packages/docs/rest/autonomy.md

2.0.13.2 KB
Original Source

The autonomy API controls whether the agent operates autonomously — proactively taking actions, posting, and engaging without user prompts. The autonomy state is managed by the AUTONOMY service in the agent runtime.

Architecture

The autonomy system is managed by the AUTONOMY service registered in the agent runtime. The service creates a recurring task that the runtime's TaskService picks up and executes on its 1-second polling interval.

Service Interface

The API layer interacts with the autonomy service through this interface:

MethodReturn TypeDescription
enableAutonomy()Promise<void>Start the autonomous operation loop
disableAutonomy()Promise<void>Stop the loop gracefully
isLoopRunning()booleanWhether the autonomy loop is currently executing a tick
getStatus(){ enabled?: boolean }Current enabled state

State Resolution

The enabled field in the response is resolved from the runtime flag runtime.enableAutonomy === true.

Trigger Integration

When autonomy is enabled, the triggers system checks runtime.enableAutonomy as a gate before creating trigger-based actions. The autonomy service also exposes:

  • getAutonomousRoomId() — returns the room UUID used for autonomous conversations
  • injectAutonomousInstruction(payload) — injects a one-time instruction into the next autonomy tick

Endpoints

GET /api/agent/autonomy

Get the current autonomy state.

Response

json
{
  "enabled": true
}
FieldTypeDescription
enabledbooleanWhether autonomous operation is currently enabled

POST /api/agent/autonomy

Enable or disable autonomous operation.

When enabling, the autonomy task fires its first tick immediately. When disabling, the loop is stopped gracefully after the current tick (if any) completes.

Request

json
{
  "enabled": true
}
ParameterTypeRequiredDescription
enabledbooleanYestrue to enable autonomy, false to disable

Response

json
{
  "enabled": true
}
FieldTypeDescription
enabledbooleanThe current autonomy enabled state after the operation

Behavior Notes

  • If the AUTONOMY service is not registered in the runtime, the enabled property is set directly on the runtime object
  • The enabled parameter must be a boolean; non-boolean values return a 400 error

Common Error Codes

StatusCodeDescription
400INVALID_REQUESTRequest body is malformed or missing required fields
401UNAUTHORIZEDMissing or invalid authentication token
404NOT_FOUNDRequested resource does not exist
503SERVICE_UNAVAILABLEAutonomy service is not available
500AUTONOMY_DISABLEDAutonomy feature is disabled in configuration
500INTERNAL_ERRORUnexpected server error