Fallback

Fallback workflow pattern for resilient execution.

Classes

class arshai.workflows.patterns.fallback.FallbackWorkflow(primary, fallbacks, retry_primary=False, fallback_condition=None, debug_mode=False)[source]

Bases: BaseWorkflowOrchestrator

Workflow with fallback mechanism for resilience.

This pattern allows defining a primary workflow with one or more fallback workflows that execute if the primary fails.

Example

primary = ComplexAnalysisWorkflow() fallback = SimpleAnalysisWorkflow()

resilient = FallbackWorkflow(

primary=primary, fallbacks=[fallback], retry_primary=True

)

result = await resilient.execute(state)

__init__(primary, fallbacks, retry_primary=False, fallback_condition=None, debug_mode=False)[source]

Initialize fallback workflow.

Parameters:
async execute(state)[source]

Execute with fallback mechanism.

Parameters:

state (IWorkflowState) – Workflow state

Return type:

IWorkflowState

Returns:

Result from primary or fallback workflow

get_stats()[source]

Get statistics about the fallback workflow configuration.

Return type:

dict