Thin integration layer for calling ASM from workflow/DAG engines.
WorkflowBridge adapts AgentSessionManager's API into workflow-friendly primitives: step execution, normalized results, error classification, and multi-run session lifecycle management.
This module does NOT depend on any external workflow library. It produces data shapes that any workflow engine (Jido, Broadway, custom) can consume.
Summary
Functions
Classify an ASM error for workflow routing decisions.
Complete or fail a shared workflow session.
Create and activate a shared session for a multi-step workflow.
Execute a single workflow step via ASM.
Normalize a raw ASM result map into a StepResult struct.
Types
@type adapter() :: AgentSessionManager.SessionManager.adapter()
@type step_params() :: %{ :input => map(), optional(:session_id) => String.t(), optional(:agent_id) => String.t(), optional(:context) => map(), optional(:metadata) => map(), optional(:tags) => [String.t()], optional(:continuation) => :auto | :replay | false, optional(:continuation_opts) => keyword(), optional(:adapter_opts) => keyword(), optional(:policy) => map(), optional(:workspace) => keyword(), optional(:event_callback) => (map() -> any()) }
@type store() :: AgentSessionManager.SessionManager.store()
Functions
@spec classify_error(AgentSessionManager.Core.Error.t()) :: AgentSessionManager.WorkflowBridge.ErrorClassification.t()
Classify an ASM error for workflow routing decisions.
Returns an ErrorClassification struct with:
retryable- whether the error is retryablecategory- error category atomrecommended_action- :retry, :failover, :wait_and_retry, :abort, or :cancel
@spec complete_workflow_session(store(), String.t(), keyword()) :: :ok | {:error, AgentSessionManager.Core.Error.t()}
Complete or fail a shared workflow session.
With default opts, completes the session. Pass status: :failed and
optionally error: %Error{} to fail it.
Returns :ok or {:error, Error.t()}.
@spec setup_workflow_session(store(), adapter(), map()) :: {:ok, String.t()} | {:error, AgentSessionManager.Core.Error.t()}
Create and activate a shared session for a multi-step workflow.
Returns {:ok, session_id} or {:error, Error.t()}.
@spec step_execute(store(), adapter(), step_params()) :: {:ok, AgentSessionManager.WorkflowBridge.StepResult.t()} | {:error, AgentSessionManager.Core.Error.t()}
Execute a single workflow step via ASM.
When params.session_id is provided, executes within an existing session
(multi-run mode). Otherwise, creates a standalone one-shot session.
Returns {:ok, StepResult.t()} or {:error, Error.t()}.
@spec step_result( map(), keyword() ) :: AgentSessionManager.WorkflowBridge.StepResult.t()
Normalize a raw ASM result map into a StepResult struct.
Accepts either a run_once result (has session_id, run_id) or
an execute_run result (no session_id/run_id) plus optional
session_id and run_id overrides.