Action execution and throttling
Action execution is the part of Keep automation that turns workflow data into provider calls while limiting repeated side effects. It uses one runtime abstraction for data-gathering steps and external actions, then applies conditions, input rendering, retries, result storage, and throttles before a call can reach a provider. This page is a child of Automation primitives; expression gates are covered in Rule evaluation and expression functions, provider boundaries in Provider implementation and dispatch, and run orchestration in Workflow execution engine.
Runtime item model
The runtime treats a workflow step and a workflow action as two uses of the same work item. A step reads or prepares data through a provider query. An action sends a notification or change through a provider notification call.
Steps
Steps prepare the context that later work uses. Their provider output becomes available under the step name, so a later condition or action can use the result without receiving a separate argument.
Steps can also process a collection with foreach. Each item gets its own current value in the workflow context, and successful outputs are collected for later use. A step can stop the ordered work after success or allow the workflow to continue after an error.
References: keep/…/step.py• L14-65 keep/…/step.py• L110-160 keep/…/contextmanager.py• L151-188 keep/…/contextmanager.py• L259-275
Actions
Actions create the external effect of a workflow after its data is ready. They use a provider configuration and provider inputs to notify a remote service, such as a messaging or ticket system.
An action definition can be selected by name with use and combined with a reusable definition from the action context. The parser turns the merged definition into the same runtime item as a step, but marks it as an action so dispatch uses the provider notification path. Tenant action records provide one source for reusable definitions and keep names unique within a tenant and use.
References: keep/…/parser.py• L565-586 keep/…/parser.py• L623-702 keep/…/parser.py• L733-741 keep/…/action.py• L8-18
Dispatch contract
Dispatch connects a runtime item to one provider operation. It first decides if the item is eligible, then prepares provider inputs from the shared workflow context, calls the operation, and records the result for the rest of the run.
Dispatch inputs
Provider inputs combine fixed values with values rendered from the workflow context. The context can hold the source event, incident data, provider data, prior step results, workflow inputs, constants, variables, aliases, and secrets. A parameter can also define a safe lookup or a default value for optional context data.
The provider type and configuration select the external system. The with values provide the operation inputs. For a step, the runtime sends them to provider.query; for an action, it sends them to provider.notify.
References: keep/…/parser.py• L463-486 keep/…/step_provider_parameter.py• L4-7 keep/…/contextmanager.py• L151-188 keep/…/step.py• L303-368
Dispatch sequence
The dispatch sequence places workflow controls before the external side effect and places context updates after a successful provider call.
flowchart LR
A[Step or action] --> B[Evaluate conditions]
B -->|not allowed| C[Skip provider call]
B -->|allowed| D[Render provider inputs]
D --> E{Throttle allows call?}
E -->|no| C
E -->|yes| F{Runtime item type}
F -->|Step| G[provider.query]
F -->|Action| H[provider.notify]
G --> I[Store provider result]
H --> I
The item evaluates its named conditions first. If no explicit if expression exists, all configured conditions must pass. A false decision skips the provider call and returns no successful-run signal. An allowed item then checks its throttle before it renders and sends the provider request.
References: keep/…/step.py• L162-303 keep/…/step.py• L315-368 keep/…/condition_factory.py• L7-21
Execution outcomes
The runtime exposes a small set of outcomes to the workflow that owns the item:
- Skipped: A condition or throttle blocks the item. No provider call occurs.
- Succeeded: The provider returns a value. The runtime stores the value under the item name and returns a successful-run signal.
- Retried: A provider error causes the same call to run again when the item has retry settings.
- Failed: All allowed attempts fail. The item raises an execution error, and the surrounding workflow decides whether to continue or report the error.
For an action, a failure is collected as an action error unless continue_on_error allows the workflow to treat it as non-blocking. A successful action with continue set to false stops later actions. A skipped action does not activate that stop rule because it did not run successfully.
References: keep/…/step.py• L73-93 keep/…/step.py• L353-397 keep/…/workflow.py• L110-171
Throttling
Throttling is a decision gate that prevents an otherwise eligible item from repeating an external effect. A workflow item declares a throttle type and its optional configuration. The throttle receives the action name, workflow identity, event identity, and the current workflow context so it can compare the current run with prior state.
Throttle policy
The throttle factory resolves the declared type to a policy object. Each policy returns a Boolean decision: true means the item is throttled and must not call the provider; false means dispatch may continue.
The check runs after the condition decision and before provider input rendering and the provider call. Therefore, a throttled item has no new provider result and does not count as a successful action for later stop behavior.
References: keep/…/step.py• L95-108 keep/…/step.py• L273-342 keep/…/base_throttle.py• L10-35 keep/…/throttle_factory.py• L6-13
One-until-resolved behavior
The one_until_resolved policy limits repeated work for an alert that is still firing. It looks at the last workflow run, finds the alert linked to that run, and checks the alert status. It allows the item when there is no prior linked run or alert, or when that alert is resolved. It throttles the item while the linked alert remains unresolved.
This policy is based on the last workflow run and its alert link rather than on a general time window or a global action count. Its purpose is to let an automation notify or update once during an unresolved alert, then permit a new effect after resolution.
References: keep/…/one_until_resolved_throttle.py• L18-38 keep/…/contextmanager.py• L20-37 keep/…/db.py• L681-700 keep/…/db.py• L1962-1982
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to the runtime item type must preserve the parser mapping between
steps,actions,provider.query, andprovider.notify. - Changes to provider input rendering must preserve context paths, optional parameter defaults, and the keyword shape accepted by provider operations.
- Changes to result or error handling must preserve the distinction between a skipped item, a successful item, and an action error reported by the workflow.
- Changes to reusable action loading must keep
usenames aligned across workflow definitions, file actions, tenant records, and merged provider settings. - Changes to throttle identity or alert links must preserve the relation between the last workflow execution and the alert status used by
one_until_resolved. - Adding a throttle type must keep its declared name aligned with the factory module and policy class lookup.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A required provider input cannot be rendered | The provider call fails before the intended side effect can run. | Use valid context paths and safe or default parameter forms for optional values. |
| A provider call fails after all configured retries | The item raises an execution error; an action can add an error to the workflow result. | Set retry count and delay for failures that are safe to repeat. |
| A throttle type does not map to a supported policy | Throttle creation fails before dispatch. | Keep the workflow throttle name aligned with a registered throttle module and class. |
| The last workflow run has an unresolved linked alert | one_until_resolved skips the item, so no new provider side effect occurs. | Resolve the source alert before expecting another effect from that policy. |
continue_on_error is false for a failed step | The step phase raises and later workflow work does not receive the expected step result. | Enable continuation only when later work does not depend on the failed output. |
Key files
| File | Why to read it |
|---|---|
| keep/…/step.py | Defines the shared step and action runtime, condition gate, throttle gate, provider call, retry loop, and result signal. |
| keep/…/parser.py | Shows how workflow steps and reusable actions become runtime items with provider inputs. |
| keep/…/workflow.py | Shows ordered step and action execution plus continuation and stop behavior. |
| keep/…/contextmanager.py | Defines the shared data that supplies rendered inputs and receives item results. |
| keep/…/base_throttle.py | Defines the contract for a throttle decision. |
| keep/…/throttle_factory.py | Resolves a workflow throttle name to its policy. |
| keep/…/one_until_resolved_throttle.py | Shows the current unresolved-alert throttle behavior. |
| keep/…/base_provider.py | Defines the provider query and notification boundary used by runtime items. |
| keep/…/action.py | Defines tenant-scoped stored action identity used by reusable action loading. |