Class: SwarmSDK::Workflow::Executor
- Inherits:
-
Object
- Object
- SwarmSDK::Workflow::Executor
- Defined in:
- lib/swarm_sdk/workflow/executor.rb
Overview
Handles workflow execution orchestration
Extracted from Workflow#execute to reduce complexity and improve maintainability. Orchestrates node execution, transformer handling, and control flow.
Defined Under Namespace
Classes: ExecutionState, OutputTransformerContext
Instance Method Summary collapse
-
#initialize(workflow) ⇒ Executor
constructor
A new instance of Executor.
-
#run(prompt, inherit_subscriptions: true) {|Hash| ... } ⇒ Result
Execute the workflow with a prompt.
Constructor Details
#initialize(workflow) ⇒ Executor
Returns a new instance of Executor.
39 40 41 |
# File 'lib/swarm_sdk/workflow/executor.rb', line 39 def initialize(workflow) @workflow = workflow end |
Instance Method Details
#run(prompt, inherit_subscriptions: true) {|Hash| ... } ⇒ Result
Execute the workflow with a prompt
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/swarm_sdk/workflow/executor.rb', line 49 def run(prompt, inherit_subscriptions: true, &block) @parent_subscriptions = capture_parent_subscriptions if inherit_subscriptions setup_logging(inherit_subscriptions: inherit_subscriptions, &block) setup_fiber_context @workflow.original_prompt = prompt state = ExecutionState.new( current_input: prompt, results: {}, last_result: nil, execution_index: 0, logs: [], ) execute_nodes(state) ensure cleanup_fiber_context reset_logging end |