Class: RobotLab::Task
- Inherits:
-
Object
- Object
- RobotLab::Task
- Defined in:
- lib/robot_lab/task.rb
Overview
Wraps a Robot for use as a pipeline step with per-task configuration
Task provides a way to pass step-specific context, MCP servers, tools, and memory to individual robots within a network pipeline. The task’s context is deep-merged with the network’s run parameters.
Instance Attribute Summary collapse
-
#name ⇒ Symbol
readonly
The task/step name.
-
#robot ⇒ Object
readonly
Returns the value of attribute robot.
Instance Method Summary collapse
-
#call(result) ⇒ SimpleFlow::Result
SimpleFlow step interface.
-
#initialize(name:, robot:, context: {}, mcp: :none, tools: :none, memory: nil, config: nil) ⇒ Task
constructor
Creates a new Task instance.
-
#to_h ⇒ Hash
Converts the task to a hash representation.
Constructor Details
#initialize(name:, robot:, context: {}, mcp: :none, tools: :none, memory: nil, config: nil) ⇒ Task
Creates a new Task instance.
42 43 44 45 46 47 48 49 50 |
# File 'lib/robot_lab/task.rb', line 42 def initialize(name:, robot:, context: {}, mcp: :none, tools: :none, memory: nil, config: nil) @name = name.to_sym @robot = robot @context = context @mcp = mcp @tools = tools @memory = memory @config = config end |
Instance Attribute Details
#name ⇒ Symbol (readonly)
Returns the task/step name.
31 32 33 |
# File 'lib/robot_lab/task.rb', line 31 def name @name end |
#robot ⇒ Object (readonly)
Returns the value of attribute robot.
31 |
# File 'lib/robot_lab/task.rb', line 31 attr_reader :name, :robot |
Instance Method Details
#call(result) ⇒ SimpleFlow::Result
SimpleFlow step interface
Enhances the result’s run_params with task-specific configuration before delegating to the wrapped robot.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/robot_lab/task.rb', line 60 def call(result) # Get current run params and deep merge with task context run_params = deep_merge( result.context[:run_params] || {}, @context ) # Add task-specific robot config run_params[:mcp] = @mcp unless @mcp == :none run_params[:tools] = @tools unless @tools == :none run_params[:memory] = @memory if @memory # Merge task's config on top of network's config if @config network_rc = run_params[:network_config] run_params[:network_config] = network_rc ? network_rc.merge(@config) : @config end # Create enhanced result with merged params enhanced_result = result.with_context(:run_params, run_params) # Delegate to robot @robot.call(enhanced_result) end |
#to_h ⇒ Hash
Converts the task to a hash representation.
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/robot_lab/task.rb', line 89 def to_h { name: @name, robot: @robot.name, context: @context, mcp: @mcp, tools: @tools, memory: @memory ? true : nil }.compact end |