Use goals and routines to run agents on a schedule or loop them until a job is done.
A goal is an objective you give an agent that it works toward over multiple turns. A routine is a recurring automated run — like a cron job for an agent.
Goals via the API:
- Create a session:
POST /api/v1/sessions. - Set a goal:
POST /api/v1/sessions/{id}/goalwith the objective text. - The agent works toward the goal, pausing to ask for input when needed.
- Listen for
goal.completed,goal.paused, orgoal.stoppedvia webhooks.
Goals can run indefinitely — there is no required iteration ceiling for long-running agents.
Routines via the CLI:
sky routine create --name "daily-report" --cron "0 9 * * *" --session <session-id>
Use sky routine runs to see past runs and sky routine list to manage your routines.
Assigning questions to a specific person:
When an agent needs human input, you can specify who must answer. The ask_user tool accepts a requiredUserId and a dueAt deadline — the right person gets notified and can respond from any surface.
Where: API (goals), CLI and API (routines)
Good to know: Webhook events goal.completed, goal.stopped, goal.paused, and goal.resumed fire for every goal state change. Related: What are automations?, Receive webhook events, Use the sky CLI.
