Introducing a new way to review your PRs.

Read the announcement

dagster-io / dagster

An orchestration platform for the development, production, and observation of data assets.

View on GitHub

19 documents · Updated Nov 23, 2026

docs / schedules-sensors-and-automation

Schedules, sensors, and automation

Schedules, sensors, and automation are run instigators: they decide when defined work should start. A schedule checks time-based opportunities. A sensor checks events or state on a repeating loop. Declarative automation checks asset and check state. Each path records its progress and sends a run request to the execution system instead of doing the work itself. See Definitions and automation for the wider definition model.

Evaluation model

Run instigators

A run instigator is a definition that can cause a job, asset selection, or asset check selection to run. The instigator has a target and a default state. Persisted state records whether it is active and preserves the information needed to continue evaluation after a daemon restart. InstigatorState

The three main decision sources use different inputs:

SourceEvaluation inputTypical reason to request work
ScheduleA scheduled time from a cron expressionA time window has arrived
SensorExternal events, run state, or other current stateNew state needs a response
Automation conditionAsset graph state and prior condition stateAn asset or check condition is true

References: python_modules/…/instigation.py• L30-55 python_modules/…/instigation.py• L203-295

Evaluation results

An evaluation produces a decision, not execution. A run request describes the work to launch. A skip result records that the check ran and found no work. A sensor result can also carry a cursor, partition changes, runless asset events, or automation evaluation data. RunRequest and SensorResult, SensorResult

The handoff follows this path:

flowchart LR
    A[Definition and persisted state] --> B[Evaluation context]
    B --> C{Decision}
    C -->|work needed| D[Run request]
    C -->|no work| E[Skip result]
    D --> F[Run or backfill submission]
    F --> G[Run and asset state]
    G --> B
    E --> H[Tick and cursor state]
    H --> B

The target resolves the request into a concrete job and selection before launch. Configuration and tags can be fixed or computed at evaluation time. Partition keys add the context needed to select a partition and resolve its run settings. ScheduleDefinition, SensorDefinition

References: python_modules/…/run_request.py• L66-98 python_modules/…/run_request.py• L298-379 python_modules/…/sensor_definition.py• L1018-1048

Scheduled evaluation

Schedule definitions

A schedule binds a cron time to a job or asset selection. At each eligible time, it evaluates its rule with the scheduled execution time and then returns a run request or a skip reason. The rule may provide run configuration and tags that depend on that time. ScheduleDefinition, ScheduleDefinition

The schedule may also apply a should_execute check. A false result stops that scheduled opportunity without starting a run. This keeps time selection separate from the choice to act on a particular occurrence. ScheduleDefinition

References: python_modules/…/schedule_definition.py• L485-537 python_modules/…/schedule_definition.py• L735-779 python_modules/…/schedule_definition.py• L972-1049

Schedule timing

The scheduler daemon checks active schedules and finds cron occurrences up to the current time. It creates a tick for each occurrence that it must evaluate. If the daemon falls behind, partitioned schedules can catch up within a configured limit. A schedule without a partition set evaluates only its latest due occurrence rather than replaying every missed time. Scheduler daemon loop, schedule timing

The scheduler stores a last-iteration checkpoint. This checkpoint limits the search after a restart or a cron change, so an old schedule definition does not cause an unbounded replay of past occurrences. ScheduleInstigatorData, schedule checkpoints

References: python_modules/…/scheduler.py• L158-191 python_modules/…/scheduler.py• L548-649 python_modules/…/instigation.py• L151-183

Event-driven evaluation

Sensor definitions

A sensor is a repeating rule that can inspect current state and decide whether to start work. It can target one job, several jobs, or an asset selection. It can return one or more run requests, a skip reason, or a reaction to an existing run. SensorDefinition, SensorDefinition

Sensors use their evaluation context to read the instance, resources, prior cursor, and timing data. The context makes the prior evaluation visible to the rule. That link lets a sensor process new input without treating all past input as new on every tick. SensorEvaluationContext, SensorEvaluationContext

References: python_modules/…/sensor_definition.py• L77-100 python_modules/…/sensor_definition.py• L109-136 python_modules/…/sensor_definition.py• L924-1048

Sensor polling

The sensor daemon polls active sensors on a short loop. Each sensor's minimum interval controls how often its rule may run. The daemon also allows only one evaluation for a given sensor at a time. These limits protect user code and prevent overlapping evaluations from producing duplicate decisions. Sensor daemon loop, sensor selection and polling

The daemon creates or resumes a tick for each evaluation. It passes the stored last tick time, last run key, and cursor to the code location. A successful evaluation records its result and makes the new cursor available to the next tick. Sensor tick processing, sensor execution data

The polling loop now spaces checks by the sensor's configured minimum interval while using a short daemon loop. It also distributes sensors across code locations in round-robin order. This prevents one location with many sensors from consistently delaying sensors in other locations. Sensor iteration loop, sensor selection and polling

References: python_modules/…/sensor.py• L352-400 python_modules/…/sensor.py• L423-505 python_modules/…/sensor.py• L515-649 python_modules/…/sensor.py• L828-926

Run status reactions

Run status sensors are event-driven sensors that react to a change in an existing run rather than create work from an external event alone. Their context includes the run and the event that caused the evaluation. A reaction can report success or failure back to the source run while the sensor cursor prevents the same event from being acted on again. RunStatusSensorContext, RunStatusSensorCursor

References: python_modules/…/run_status_sensor_definition.py• L84-121 python_modules/…/run_status_sensor_definition.py• L124-172 python_modules/…/sensor.py• L1001-1043

Run request coordination

Request identity

A run key is an optional identity for a requested run. For sensors, the key makes a request idempotent across sensor evaluations. For schedules, it makes a request unique within a scheduled tick and its recovery attempts. A request without a key means that the system may create a run on each evaluation. RunRequest

Before a sensor launch, the daemon checks stored runs that match the sensor and run key. If a prior request already created and launched a run, the daemon skips creation. If a prior run exists but was not launched, the daemon can continue the launch. This protects against duplicate runs when the daemon stops between run creation and tick update. Sensor run submission, sensor run identity

References: python_modules/…/run_request.py• L66-98 python_modules/…/sensor.py• L714-772 python_modules/…/sensor.py• L1362-1445

Request submission

The daemon reserves an ID for each request before it submits the work. It records the request and its reserved ID in the tick first. Then it submits a normal run or a backfill request. This order gives recovery a durable list of work to finish if the daemon stops during submission. Sensor request handling

Asset selections may resolve to one run or to a backfill. A backfill request represents a group of asset partitions for the backfill daemon. The run request remains the common decision format even when a different worker owns the later execution. RunRequest backfill form, backfill submission

Deployments with a run-size limit filter requests before they are written to sensor tick history. Launchable requests still submit. Oversized requests are omitted from the tick and cause the tick to fail with a short description of the affected job, run key, or partition. This keeps a large configuration or tag payload from expanding tick storage and recovery reads. Run request size handling, request reservation

Because the tick fails when an oversized request is dropped, its cursor normally does not advance. The sensor can therefore yield the request again after its configuration or tags are made small enough to launch. Sensor state write, oversized request handling

References: python_modules/…/sensor.py• L1081-1121 python_modules/…/sensor.py• L1124-1195 python_modules/…/sensor.py• L1198-1326 python_modules/…/sensor.py• L239-287

Queued run launch

The queued run coordinator is the handoff between a submitted run and its run worker. It selects queued runs only when the run queue has capacity and the runs meet priority, tag, operation, and code-location limits. This lets evaluation create work without forcing every request to start at once. QueuedRunCoordinatorDaemon, queue selection

The coordinator launches eligible runs and keeps their state in the run store. If user code cannot be reached, it pauses that code location for a short period and can return the run to the queue within the configured retry limit. Other launch errors mark the run as failed. Queued run launch

References: python_modules/…/queued_run_coordinator_daemon.py• L43-104 python_modules/…/queued_run_coordinator_daemon.py• L196-348 python_modules/…/queued_run_coordinator_daemon.py• L371-500

Run lifecycle monitoring

Run health monitoring

Run monitoring is the daemon-side safety loop for runs that have been submitted. It checks whether a run starts and cancels within their time limits. It also checks worker health after start and can resume a run with a new worker a limited number of times before it marks the run as failed. Run monitoring iteration

The same loop enforces a maximum run time. A run can use the instance default or a run tag that sets its own limit. When the limit is reached, the monitor asks the launcher to terminate the run and records failure even if the worker does not complete cleanup. Run timeout handling

References: python_modules/…/run_monitoring.py• L28-184 python_modules/…/run_monitoring.py• L187-245 python_modules/…/run_monitoring.py• L247-310

Cursor state

Sensor cursors

A sensor cursor is opaque state owned by the sensor rule. The rule reads it at the start of an evaluation and returns a new value when it has advanced its view of the source. The daemon stores the cursor with instigator state after a completed tick. SensorEvaluationContext, SensorResult, SensorInstigatorData

The cursor is separate from the run key. A run key identifies one requested run. A cursor identifies the sensor's position in the source or state stream. A sensor can use both: the cursor moves the scan forward, while run keys protect each emitted request. SensorEvaluationContext, RunRequest

References: python_modules/…/sensor_definition.py• L109-136 python_modules/…/sensor_definition.py• L171-213 python_modules/…/instigation.py• L92-135

Tick recovery

A tick is the recorded unit of one evaluation attempt. It contains its status, errors, skip reason, cursor, and requested work. If a sensor tick stops with unsubmitted requests, the daemon resumes that tick before it evaluates the sensor again. Failed ticks can be retried within the recovery rules. Sensor tick selection, SensorLaunchContext

The daemon updates the main sensor state from the finished tick. Successful or skipped ticks advance the cursor. A failed tick normally preserves the prior cursor so the rule can retry the same source state. Some reactions opt to advance the cursor on failure because repeating their side effect would be unsafe. SensorLaunchContext state write, run reaction handling

References: python_modules/…/sensor.py• L515-589 python_modules/…/sensor.py• L120-339 python_modules/…/sensor.py• L239-287 python_modules/…/sensor.py• L1001-1043

Declarative automation

Automation conditions

An automation condition states when an asset or asset check should be requested. It evaluates against the current asset graph and run history. Conditions can describe missing work, new updates, changed code or data, freshness state, dependency state, and run state. They can be combined with boolean operators and time-based rules. AutomationCondition, built-in conditions

The condition is policy, not a direct run call. The evaluator returns the asset or check partitions whose conditions are true. The automation layer then groups those results into run requests that fit the asset graph and partition model. AutomationCondition evaluation contract, automation tick evaluation

Common policy shapes include:

  • eager: request missing or newly enabled work after dependencies update, while waiting for missing or in-progress dependencies.
  • on_cron: request work after a cron point when all required dependencies have updated since that point.
  • on_missing: request newly missing target partitions when their dependencies are available.
  • Composed conditions: combine state checks with &, |, inversion, and since history.

References: python_modules/…/automation_condition.py• L341-379 python_modules/…/automation_condition.py• L673-796 python_modules/…/automation_condition.py• L926-984 python_modules/…/automation_tick_evaluation_context.py• L150-189

Automation sensor

An automation condition sensor evaluates conditions for a selected set of assets and checks. It converts true condition results into materialization or observation requests. The sensor can use a default condition for selected entities that do not define one. AutomationConditionSensorDefinition, automation sensor evaluation

The automation evaluation keeps a structured cursor. The cursor stores condition state and evaluation timing so a condition such as newly_updated or since has meaning across ticks. The evaluation also records changed condition results and links them to the run IDs that later satisfy them. AutomationTickEvaluationContext, automation request handling

References: python_modules/…/automation_condition_sensor_definition.py• L71-114 python_modules/…/automation_condition_sensor_definition.py• L133-161 python_modules/…/automation_tick_evaluation_context.py• L158-189 python_modules/…/sensor.py• L1124-1294

Asset daemon coordination

The daemon controller gives schedules and sensors long-lived loops that can heartbeat and recover. Standard sensors use the sensor daemon. Automation sensors that are handled by the asset daemon use the asset daemon's evaluation path. Both paths preserve the same decision boundary: evaluate state, create requests, and submit work. Daemon controller, daemon types, sensor type routing

Automation can emit a normal asset run or a backfill when many partitions are requested. The asset daemon uses the condition result and asset graph to choose the request shape. This lets one automation policy scale from a single asset partition to a larger partition range without changing the condition itself. Automation request construction, run request construction

References: python_modules/…/daemon.py• L65-145 python_modules/…/daemon.py• L268-345 python_modules/…/sensor.py• L430-437 python_modules/…/automation_tick_evaluation_context.py• L340-408

Change checklist

When these files or sections are changed, remember to consider these:

  • When a schedule or sensor target changes, check that its run requests still resolve to the intended job or asset selection.
  • When a sensor's cursor format or meaning changes, plan for old stored cursors and for the effect on duplicate or missed events.
  • When run request identity changes, check both the request key and the scope used to find existing runs. A key that is not scoped to the sensor can suppress unrelated work.
  • When tick submission order changes, preserve the durable reservation step before run launch so daemon recovery can finish unsubmitted work.
  • When a run-size limit or request filtering rule changes, check that launchable requests are stored and submitted while oversized payloads stay out of tick history. Also check that the failure leaves the cursor at the intended retry position.
  • When an automation condition changes its target scope or partition behavior, check the grouping of condition results into runs and backfills.
  • When daemon routing changes, check that the selected daemon evaluates the sensor type and that its state format matches the path that writes it.
  • When queue limits or priority rules change, check that tag limits, operation limits, active run counts, and code-location pauses still produce the intended launch order.
  • When run monitoring limits or resume rules change, check the interaction between worker recovery, run cancellation, and the final run status.

Important failure modes

TriggerConsequenceGuard
A sensor returns a run request without a valid targetEvaluation fails instead of creating a runDefine a job, multiple jobs, or an asset selection that matches every request
A sensor emits the same run key for work that is not the same logical eventA prior run can suppress a new runBuild keys from the event identity and keep their scope local to the sensor
The daemon stops after run creation but before tick completionRecovery sees an incomplete tickThe daemon records reserved request IDs before submission and resumes unsubmitted work
A sensor evaluation fails after consuming source stateThe same source state can be evaluated againAdvance the cursor only when the rule can safely treat the source state as handled
A run request exceeds the deployment run-size limitThe request is omitted from tick history and the tick fails; smaller requests in the same tick can still launchReduce run configuration or tag payloads and let the sensor retry from its unchanged cursor
An automation condition targets too many entities for its evaluation modeThe automation tick is rejectedSplit the selection or use the daemon-supported evaluation mode
A schedule falls behind its due timesOnly the allowed catch-up set is launchedUse partitioned schedules for replayable time units and set a suitable catch-up limit
The user code location is unavailable during sensor evaluationThe tick fails and work waits for the location to returnRestore the code location; the daemon keeps the state needed to retry
Queue capacity or a concurrency limit blocks a queued runThe run stays queued until capacity becomes availableReview active run counts and tag or operation limits before changing queue settings
User code cannot be reached during run launchThe run is requeued or fails after the retry limitKeep the code location available and set a retry policy that matches its recovery time
A run worker does not start or becomes unhealthyThe run fails or receives a bounded number of resume attemptsSet start and resume limits that match the run launcher and worker behavior
A run exceeds its global or per-run runtime limitThe monitor requests termination and marks the run failedSet the runtime tag or instance limit with enough time for expected work

Key files

FileWhy to read it
python_modules/…/schedule_definition.pyDefines the time-based decision contract and scheduled evaluation result.
python_modules/…/scheduler.pyShows how due cron times become ticks and scheduled run submissions.
python_modules/…/sensor_definition.pyDefines sensor targets, contexts, result handling, and request resolution.
python_modules/…/sensor.pyShows polling, fair sensor coordination, tick recovery, cursor writes, request size checks, idempotent submission, and run reactions.
python_modules/…/run_request.pyDefines the common handoff from evaluation to execution.
python_modules/…/instigation.pyDefines persisted instigator state for schedules and sensors.
python_modules/…/queued_run_coordinator_daemon.pyShows how submitted runs wait for capacity and move from the queue to a run worker.
python_modules/…/run_monitoring.pyShows how the daemon detects stalled, unhealthy, canceled, or overlong runs.
python_modules/…/automation_condition.pyDefines the policy language for asset and check automation.
python_modules/…/automation_condition_sensor_definition.pyConnects selected assets and conditions to sensor evaluation.
python_modules/…/automation_tick_evaluation_context.pyConnects condition results and structured cursor state to run requests.
python_modules/…/daemon.pyShows the long-lived daemon roles and heartbeat model.

See also Software-defined assets, Ops, jobs, and graphs, and Run planning and execution for asset state and the execution targets that receive these requests.