Template Guidelines
States and Actions
Explains how to model a real-world process as states and actions, when to add a state, and how action availability is controlled.
At the heart of the Stubber Framework is a simple but powerful idea:
A process is modeled as a finite set of states, and change happens through actions.
This allows a process to be expressed in a structured, inspectable, and controllable way. Rather than thinking of a process as a long list of steps, the framework encourages thinking in terms of:
- the current situation the Stub is in,
- the meaningful changes that can happen,
- and the conditions under which those changes are allowed.
A Stub always exists in exactly one state at a time. Actions are the only way to change data, run automation, send notifications, or transition to another state.
Conceptual Model
A useful way to think about the framework is:
- States represent longer-lived phases or periods of the process.
- Actions represent moments where something happens.
- Transitions move the Stub from one state to another when appropriate.
This makes the process easier to reason about because it separates:
- where the process currently is from
- what can happen next
In practice, a Stub moves through a process by repeatedly:
- being in a state,
- exposing a set of available actions,
- having one of those actions triggered,
- executing that action,
- and optionally transitioning into a new state.
States
What a state represents
A state represents a meaningful phase in the life of the process.
A good state captures a period of time during which the process is:
- waiting for something,
- actively being worked on,
- under review,
- pending outside input,
- or otherwise in a stable, understandable phase.
States should be high-level. They are not intended to model every tiny step. Instead, they should capture the broader stage that matters to the business process.
For example, a state should reflect a process phase such as:
- work being in progress,
- customer input being awaited,
- approval being pending,
- verification being active
rather than a low-level technical or operational detail.
Why states matter
States provide structure to the process.
They help define:
- what the process is currently doing,
- what actions should be available,
- what automation should happen in a given phase,
- and how the process should progress over time.
Without states, all actions would exist in a flat list, making it difficult to control process flow. States create boundaries and guide the next valid moves.
They are especially useful when:
- different phases need different available actions,
- the process has natural waiting periods,
- the agent or user should behave differently in different phases,
- or the process needs stronger control over progression.
When to use states
Use states when the process has distinct phases that matter to how the Stub should behave.
A new state is usually appropriate when one or more of the following is true:
1. The available actions need to change
If the set of actions that should be possible is different before and after a milestone, that is a good sign that the process should move into a new state.
2. The process enters a meaningful waiting period
If the process is now awaiting customer input, external approval, a document, a payment, or some other outside event, a separate state is often useful.
3. The process enters a focused work phase
If a phase begins where a particular kind of work is now actively underway, a dedicated in-progress state can make the process clearer and easier to control.
4. Reporting or analytics need to distinguish phases
If the business wants to measure how long items spend in a certain stage, states are the correct abstraction.
5. The agent needs tighter guidance
If an LLM agent should only see a smaller set of relevant actions during a certain stage, splitting the process into states can improve behavior and reduce ambiguity.
When not to use more states
Not every step needs its own state.
Avoid creating a new state for:
- every field being collected,
- every internal system operation,
- every task that runs inside an action,
- or every micro-decision in the process.
If something happens instantly as part of a single event, it is often better modeled as part of an action rather than as its own state.
Too many states make a flow harder to understand and maintain. A good rule is:
Use states for meaningful periods of time, not for tiny implementation steps.
Breaking a process into stages
When designing a process, start by identifying the major business phases.
Ask questions like:
- What broad stages does this process move through?
- Where does the process pause and wait?
- Where does the nature of the work change?
- At what points should different actions become available?
- Which phases matter to users, operators, or reporting?
This usually leads to a small number of high-level stages such as:
- an initial active phase,
- one or more focused work phases,
- one or more waiting phases,
- and a completion phase.
The goal is not to model every detail. The goal is to create a process map that is:
- understandable,
- operationally useful,
- and aligned with how the business thinks about the process.
State naming
State names follow a strict naming convention and should reflect the nature of the period being modeled.
Future tense states
Use these when the process is primarily waiting for something external.
These typically:
- start with
awaiting- - start with
waiting-for- - or end with
-pending
Examples of the pattern:
awaiting-approvalwaiting-for-customer-responsereview-pending
Present tense states
Use these when the process is actively being worked on.
These typically end with:
-in-progress- or
-active
Examples of the pattern:
review-in-progressinvestigation-active
This naming convention helps the flow communicate whether the process is waiting or actively moving.
Actions
What an action represents
An action represents a point in time where something happens.
Actions are the only execution points in the framework. They are how the process changes.
When an action executes, it can:
- collect data,
- run tasks,
- send notifications,
- record metrics,
- and optionally transition the Stub to another state.
An action should represent a meaningful business event or process update.
Examples of action intent include:
- capturing information,
- confirming a decision,
- starting a phase of work,
- logging an outcome,
- escalating a case,
- or resolving a process item
Actions should remain conceptual and process-oriented. They should not be named after low-level technical implementation details.
How actions relate to states
States define the process phase. Actions define what can happen in that phase.
A state lists which actions are available while the Stub is in that state. This means the current state acts as the primary filter for what can be triggered.
This relationship is one of the most important ideas in the framework:
States shape availability. Actions create change.
A process therefore becomes a controlled loop:
- the Stub is in a state,
- that state exposes certain actions,
- an action is triggered,
- the action executes,
- and the Stub may remain in the same state or move to a new one.
Action chaining and progression
Actions move a process forward through state transitions, but chaining actions is the exception, not the way to build.
On agentic flows the LLM sequences the work: expose AI-enabled actions in a state and let the agent choose which to call and in what order. Do not wire actions together with sendactions tasks to force a sequence. That creates a hidden script that is rigid, hard to debug and invisible to the agent.
- If several things happen together as one business event, put them in one action with multiple tasks.
- If the agent should be able to do two things independently, make two AI-enabled actions.
- Use a state transition only when the process has clearly entered a new phase with a different set of available actions.
- Legitimate
sendactionsuses: the async execution technique, communication between stubs or contexts, and handing off to another stub.
A conversational flow with many non-AI actions, or with actions that trigger other actions, is a red flag. Go back to a few broad states with many AI-enabled actions.
Action Availability
An action is not automatically available everywhere.
Action availability is determined by a combination of:
- the current state of the Stub,
- the action’s
conditionsarray, - and whether the action is listed in the special
_allstate
These mechanisms work together to control when an action may be triggered.
Availability by state
The primary way to make an action available is to list it under one or more states.
This is the default and most important mechanism.
If an action appears in a state’s actions list, it is considered for availability when the Stub is in that state.
This keeps the process understandable because the current state directly determines the main set of possible next moves.
Availability by action.conditions
An action can also define a conditions array.
These conditions are used to determine whether the action is actually available in the current situation.
This allows action availability to depend not only on state, but also on data and logic.
Typical uses include:
- only allowing an action if certain data exists,
- hiding an action until a prerequisite is complete,
- preventing an action once a flag has been set,
- exposing an action only for certain categories or outcomes
This is important because two Stubs may be in the same state but still need different available actions depending on their data.
How to think about action.conditions
Use state to model the broad phase of the process.
Use action.conditions to model the finer decision logic within that phase.
In other words:
- State answers: “What stage are we in?”
- Conditions answer: “Given this specific Stub’s data, should this action be available right now?”
This separation helps keep flows clean and avoids creating unnecessary extra states for every small variation.
The _all state
The special _all state is used for actions that should be available regardless of the current state.
This is useful for actions that are truly global, such as:
- system-wide controls,
- universally available support actions,
- or framework-level behavior
Use _all carefully.
If an action is only relevant in certain phases, it is usually better to place it on those specific states rather than making it globally available.
A good principle is:
If an action is not genuinely appropriate everywhere, do not place it in
_all.
How to think about process design with states and actions
Start with the real-world process
Begin by asking:
- What real-world process is being modeled?
- What are the major phases it moves through?
- What events cause meaningful change?
- What information is collected at those change points?
- Where does the process wait?
- Where does it actively progress?
The framework works best when the process is modeled according to business meaning, not system architecture.
Think in phases, not screens or APIs
A common mistake is to design states and actions around:
- interface screens,
- integration calls,
- database operations,
- or implementation details
Instead, think in terms of:
- phases of work,
- moments of decision,
- waiting periods,
- and meaningful business updates
The technical work belongs inside tasks on actions. The flow itself should represent the business process.
Keep states few and meaningful
A well-designed flow usually has a modest number of states.
If the flow becomes crowded with many tiny states, it often means low-level steps have been modeled as process phases.
Prefer:
- fewer, clearer states
- with well-named, meaningful actions
Only add more states when it improves:
- process control,
- action availability,
- reporting,
- or agent behavior
Use actions for change, not states
States do not perform work. Actions do.
This means:
- data collection belongs on actions,
- automation belongs in action tasks,
- notifications belong on actions,
- metrics are recorded through actions,
- and transitions happen as part of actions
A state describes the current phase. An action is what actually moves the process forward.
Separate broad flow control from detailed logic
A strong design usually separates:
- broad process structure using states
- detailed decision logic using action conditions and task logic
This keeps the flow readable while still allowing precise behavior.
For example:
- use states to divide the process into major phases,
- use action conditions to expose or hide actions based on current data,
- and use tasks to perform the actual automation.
This layered approach is one of the key strengths of the framework.
Practical design guidance
A useful rule of thumb
When deciding whether something should be a state or an action, ask:
Make it a state if:
- it represents a period of time,
- the process is meaningfully “in” that phase,
- different actions should be available there,
- or time spent in that phase matters
Make it an action if:
- it represents a point-in-time event,
- it collects data or performs work,
- it updates the Stub,
- or it may transition the process onward
This distinction is central to designing clean flows.
Designing for agentic processes
In agentic flows, states and actions also help shape how the agent behaves.
Because available actions are derived from the current state and conditions:
- the agent sees a more relevant set of tools,
- the process becomes easier for the agent to navigate,
- and the flow can guide the agent through the intended progression
This means states are not only for process control; they are also useful for constraining and clarifying agent behavior.
A simple agentic process may use only one broad active state. A more structured one may introduce additional states when tighter guidance is needed.
The typical agentic shape is a few broad states with many AI-enabled actions. Many non-AI actions, or chains of actions triggering actions, signal a flowchart where an agent should be.
Summary
States and actions form the core process model of the Stubber Framework.
- States represent meaningful phases of the process.
- Actions represent the events that cause change.
- State availability determines which actions are relevant in a given phase.
action.conditionsrefine that availability based on data and logic.- Transitions allow the process to move from one phase to another.
A good flow is usually:
- high-level,
- business-oriented,
- easy to reason about,
- and careful not to confuse process phases with implementation steps.
The best way to model a process is to think in terms of:
- where the process is,
- what can happen next,
- and what should be allowed in that situation.
That is the essence of the Stubber Framework’s states-and-actions approach.