Tutorial 2 — Choose or Generate an Operator
An operator contains the execution logic — the HOW. LeastAction ships operators for PostgreSQL, AWS, Airflow, dbt, and more, and you can generate new ones with AI in seconds.
Option A — Use an existing operator
Browse the operators folder and select one, e.g. PostgresqlExecuteSQL.
Option B — Generate with AI
- Go to AI > Operator in the UI.
- Describe what you need in plain English.
- The AI generates the operator code, a sample connection, and a sample payload.
- Review, test, and save.
The operator contract
Every operator's main.py defines exactly four methods, called in order:
def initialize(least_action_task_object): # build the client/connection
def run(least_action_task_object, client): # do the work; return status + result
def check_completion(least_action_task_object, client, run_details): # poll async / pass through sync
def finish(least_action_task_object, client, completion_details, run_details): # cleanup
When saving, you also provide a bashblock (dependencies, e.g. pip install psycopg2-binary) and sample connection/payload JSON.
Full contract, rules, logging, and validation: the Operator concept and the Write an Operator guide. For AI generation specifics see Service AI.