Automation
BindAI Automation provides the foundation for building event-driven applications and workflows. Automation allows an application to react when something happens, such as an agent event, tool execution, workflow event, or another event published through BindAI’s event system. The current automation package provides primitives for:- Automation definitions
- Automation execution state
- Automation run history
- Event triggers
- Trigger management
- Background automation workers
Automation Architecture
The current architecture separates automation definitions, execution state, historical records, and event triggers:Automation Package
The automation package is provided by:Automation Definitions
AutomationDefinition describes an automation and the executable target it invokes.
id— unique automation definition identifiername— human-readable automation nameversion— definition version, starting at1target— thebindai-coreexecutable invoked by the automationmetadata— optional application-defined metadata
Automation Runs
AutomationRun represents one execution of an automation definition.
id— unique execution identifierdefinition_id— automation definition identifierdefinition_version— definition version used for the executionstatus— execution state such aspending,running,completed, orfailedinput— optional execution inputoutput— execution outputerror— failure information when execution failscreated_at— run creation timestampstarted_at— execution start timestampcompleted_at— execution completion timestamp
Automation State
AutomationStateStore defines the persistence contract for automation runs.
AutomationRun.
This allows execution state to be stored in memory or backed by another persistence system without coupling the run model to a specific storage implementation.
The state store represents the current state of an automation run.
In-Memory State Store
MemoryAutomationStateStore provides an in-memory implementation of the automation state store.
Automation Run History
AutomationRunHistory defines the history contract for recording and retrieving automation runs.
AutomationStateStore.
The state store answers:
Where is the current execution state of this run?Run history answers:
What automation runs have been recorded?This separation allows current execution state and historical records to evolve independently. The history contract provides:
record(run)— record an automation runget(run_id)— retrieve a historical run by IDlist()— retrieve recorded runs in insertion order
In-Memory Run History
MemoryAutomationRunHistory provides an in-memory implementation of AutomationRunHistory.
AutomationRun do not modify the historical record:
Background Automation Workers
AutomationWorker executes automation definitions and manages the lifecycle of their AutomationRun objects.
It supports both synchronous execution and background submission:
- creates an
AutomationRun - persists the current run state through
AutomationStateStore - executes the automation definition
- updates the run lifecycle
- records the completed or failed run through
AutomationRunHistory
EventTrigger.
Event triggers determine when an event should invoke application logic, while AutomationWorker provides background execution and run lifecycle management for automation definitions.
The resulting architecture is:
Trigger
Trigger is the base abstraction for automation triggers.
enabledenable()disable()attach()detach()
Enabling and Disabling Triggers
Triggers can be temporarily disabled without removing them from their event source.Event Triggers
EventTrigger connects a BindAI EventBus to a target callable.
- an event bus
- an event name
- a target callable
Attaching an Event Trigger
AnEventTrigger must be attached to begin receiving events.
EventBus are passed to the target.
attach() multiple times does not create duplicate subscriptions.
Detaching an Event Trigger
An attached trigger can be removed from its event source:detach() when the trigger is already detached is safe.
A typical lifecycle is:
Event Matching
EventTrigger subscribes to a specific event name.
For example:
name matches the configured event name are delivered to the trigger by the underlying event bus subscription.
The event itself is passed unchanged to the target callable.
Agent Events
BindAI agents expose anEventBus through:
Tool Execution Events
Agent tool execution publishesToolExecutedEvent through the agent’s event bus.
An automation trigger can subscribe to the corresponding event name.
Conceptually:
Targets
AnEventTrigger accepts a callable target:
Trigger State
Triggers have two independent lifecycle concepts:Trigger Registry
TriggerRegistry provides a registry for trigger instances.
Registry Operations
TriggerRegistry provides operations for managing registered triggers.
Example
A simple event-driven automation setup can look like this:Multiple Triggers
An application can create multiple triggers for different events.Automation and Workflows
Automation triggers can be used as an integration boundary around workflows. Conceptually:Automation and Agents
Agents can act as event sources for automation. For example:Automation and Connections
Automation can also be combined with BindAI Connections. For example:Error Handling
The underlying BindAIEventBus isolates exceptions raised by individual event handlers.
This means an exception raised while processing one event handler is logged by the event bus rather than preventing other subscribed handlers from being invoked.
An EventTrigger itself does not introduce a separate retry or error-management system.
Applications that require retries, persistence, or failure recovery should implement those concerns at the appropriate higher-level automation or workflow layer.
Synchronous Execution
The currentEventBus implementation is synchronous.
Therefore, an event handler is invoked as part of event publication.
Conceptually:
EventTrigger does not create background workers or persistent automation jobs.
For automation definitions that need background execution, BindAI provides AutomationWorker.
The worker executes AutomationDefinition instances in a thread pool while managing AutomationRun, state-store, and run-history lifecycle.
Therefore, event-driven triggering and background execution remain separate concerns.
Trigger Lifecycle
A recommended lifecycle is:Testing Automation
Automation components should be tested independently from the external services they eventually control. Useful tests include:- Trigger construction
- Enable/disable behavior
- Attach behavior
- Detach behavior
- Event matching
- Target invocation
- Duplicate attachment protection
- Registry operations
- Handler failure behavior
- Automation run lifecycle
- State-store operations
- Run-history recording
- Run-history retrieval
- Run-history snapshot isolation
- Background worker execution
- Background worker state persistence
- Background worker run-history recording
- Worker shutdown behavior
Security Considerations
Automation can cause actions to occur automatically in response to events. Applications should therefore consider:- Which events can trigger automation
- Which targets can be invoked
- Whether the target performs external side effects
- Credential and secret handling
- Authorization boundaries
- Input validation
- Audit requirements
Current Scope
The current BindAI Automation package provides:Automation
AutomationDefinitionAutomationRunAutomationStateStoreMemoryAutomationStateStoreAutomationRunHistoryMemoryAutomationRunHistoryAutomationWorker
Event integration
TriggerEventTrigger- BindAI
EventBus - Named event subscriptions
- Event-driven callable targets
- Enable/disable lifecycle
- Attach/detach lifecycle
Registry support
TriggerRegistry- Trigger registration
- Trigger lookup
- Trigger removal
- Trigger enumeration
- Registry clearing
Future Automation Capabilities
The broader BindAI automation roadmap includes additional capabilities such as:- Advanced event routing
- More trigger types
- More advanced scheduling and execution policies
- Persistent database-backed automation state
- Persistent database-backed run history
- Broader automation orchestration
Design Principles
BindAI Automation follows several principles:- Keep triggers small and composable.
- Reuse the existing event system.
- Separate event detection from automation actions.
- Make trigger lifecycle explicit.
- Avoid hidden background execution.
- Keep external-service concerns outside the trigger abstraction.
- Allow future trigger types without changing existing event infrastructure.
- Keep automation state and persistence separate from basic event subscription.
- Keep current execution state separate from historical run records.
- Keep the initial history API small so persistent backends can be added later.
- Keep background execution explicit through
AutomationWorker.
API Accuracy
The current automation documentation intentionally describes only APIs implemented by the currentbindai-automation package.
The current automation package provides:
AutomationRunHistory contract and its in-memory implementation, MemoryAutomationRunHistory.
Persistent database-backed history remains future infrastructure.
Background execution is currently available through AutomationWorker, which executes automation definitions using a thread pool and manages run state and history.
Advanced event routing, persistent storage backends, and broader automation orchestration remain future infrastructure.
Summary
BindAI Automation provides a lightweight foundation for stateful and event-driven automation. The current architecture separates automation definitions, execution state, historical records, and event triggers:EventTrigger connects BindAI’s existing EventBus system to application-defined callable targets, while TriggerRegistry provides centralized trigger management.
AutomationRun provides execution state, AutomationStateStore provides current-state persistence, and AutomationRunHistory provides a separate interface for historical execution records.
AutomationWorker provides explicit background execution for automation definitions using a thread pool while coordinating run state and history.
The current in-memory implementations provide the foundation for future persistent storage, advanced event routing, and broader automation orchestration.