Skip to content

@Action

The @Action decorator defines a deterministic code node (actions/*.action.ts) in a @Workflow graph that runs without calling an LLM. Actions read typed DTOs from the workflow’s Path Scope, inject @Injectable services and ExecutionContext through their constructor, and either return a new DTO to the path (.returns(OutputDto)) or perform a side effect (Promise<void>) before transitioning to the next node.

Complete @Action examples (value-producing and side-effect-only)

Section titled “Complete @Action examples (value-producing and side-effect-only)”

Every @Action class name ends with Action and its name option ends with -action:

Option Type Required Description
name string Yes Unique kebab-case identifier ending with -action (e.g., "send-offer-action").
description string Yes Human-readable summary of what the action does for Studio graphs and logs.
input InputFields No Map of DTOs read from the workflow’s Path Scope ({ draft: OfferDraftDto, approval: optional(DraftApprovedDto) }).
output OutputShape No DTO class, listOf(Dto), or oneOf(A, B) returned by execute(). Omit output for side-effect-only actions returning Promise<void>.
compensateWith Type<ActionHandler> No Deterministic @Action class that reverses this action’s external side effect on error paths (verified by agboss check via [flow.uncompensated-action]) and automatically in LIFO order on app.cancel, FailFast, quorum Surplus, or @Budget abort.
committedBy Type<ActionHandler> No Optional downstream @Action class that finalizes the side effect so subsequent errors or cancellations no longer trigger compensateWith.
deps readonly Token[] No Constructor dependencies (ExecutionContext, SpendRecorder, Clock, @Injectable services) verified against constructor parameters at compile time.
Related Entity Import Path Purpose
ActionHandler<Self> "@agboss/core" Interface implemented by every @Action class (execute(input: InputOf<Self>): Promise<OutputOf<Self>>).
InputOf<Self> & OutputOf<Self> "@agboss/core" Type helpers generated by agboss check (.agboss/types.d.ts) that type execute(input) from the decorator’s input and output.
.toAction(ActionClass) & action(ActionClass) "@agboss/core" HarnessDSL (HDSL) flow methods for chaining an action on a path or starting a shared continuation path from an action.
testAction(ActionClass, options?) "@agboss/core/testing" Isolated unit runner that executes an @Action directly with mocked overrides and custom executionContext without booting the workflow.
mockAction(ActionClass) "@agboss/core/testing" Spies on or overrides an @Action inside a testWith(Application) workflow test.