#10889·skypilot

[Docs] event_callback is undocumented

Author: Riemann-defCreated Sep 27, 2026Updated Sep 27, 2026

What is missing

event_callback is an accepted task YAML field (sky/utils/schemas.py, 'event_callback': {'type': 'string'}), but the only prose describing it is the sky.Task docstring:

event_callback: A bash script that will be executed when the task changes state.

That is surfaced in the Python SDK reference and nowhere else. Specifically, it is absent from:

That last one is the part worth fixing first. A reader wanting to run something when a job changes state searches the docs, finds Lifecycle hooks, and gets config.hooks — which fires on stop/preemption/down and runs on the head node. For reacting to a job failing, that is the wrong mechanism: the head node is what died. Nothing on that page points to event_callback, and nothing distinguishes the two.

Why it matters

event_callback runs on the jobs controller, so it is the only hook that outlives the worker. That makes it the right answer for "tell my service when a job dies", and it is currently only findable by reading sky/jobs/utils.py.

Because it is undocumented, nothing upstream promises the status names are stable, so downstream code either pins a SkyPilot version or guesses.

Suggested content

All of the following is determined from the source and from observing real managed jobs on 0.13.0. Documenting it would make the feature usable without reading the implementation.

Where it runs. On the jobs controller, in the controller's own environment — not on the worker. It therefore has no access to the task's workdir or file_mounts, and it survives the worker being lost.

Which statuses fire it. Observed: SUBMITTED, STARTING, STARTED, RECOVERING, RECOVERED, SUCCEEDED, FAILED, CANCELLING, CANCELLED. PENDING did not fire. (Call sites: event_callback_func in sky/jobs/utils.py.)

Environment provided (sky/jobs/utils.py, callback_func): JOB_STATUS, JOB_ID, TASK_ID, TASK_NAME, CLUSTER_NAME, SKYPILOT_TASK_ID, SKYPILOT_TASK_IDS, EVENT_TYPE.

task.envs is merged; task.secrets is not. This is the single most useful line to add. The callback's environment is built with env_vars = task.envs.copy(), and secrets is never merged, so a callback cannot read a credential declared under secrets: — while the same task's setup: and run: can. Anyone using the callback to notify an authenticated endpoint hits this and has no way to know it is intended. (Related: #5474, #5475 added task.envs.)

Delivery is at-least-once, not deduplicated. A real cancellation delivered CANCELLING twice, so callbacks should be idempotent.

Where its output goes. ~/.sky/logs/managed_job_event/jobs-callback-<job_id>-<task_id>.log. Worth stating, since a callback that fails is otherwise silent.

Scope

Documentation only. The secrets exclusion in particular looks deliberate, and documenting it is more useful than changing it.