Class: Agentic::ExecutionPlan
- Inherits:
-
Object
- Object
- Agentic::ExecutionPlan
- Defined in:
- lib/agentic/execution_plan.rb
Overview
Value object representing an execution plan with tasks and expected answer
This class is part of the data-presentation separation pattern:
-
TaskPlanner generates the core plan data
-
ExecutionPlan serves as a structured value object to hold this data
-
The to_s method provides presentation capabilities when needed
Using a value object instead of raw hashes provides:
-
Type safety
-
Domain-specific methods
-
Encapsulation of presentation logic
-
Clearer interfaces between components
Instance Attribute Summary collapse
-
#expected_answer ⇒ ExpectedAnswerFormat
readonly
The expected answer format.
-
#tasks ⇒ Array<TaskDefinition>
readonly
The list of tasks to accomplish the goal.
Instance Method Summary collapse
-
#initialize(tasks, expected_answer) ⇒ ExecutionPlan
constructor
A new instance of ExecutionPlan.
-
#to_h ⇒ Hash
Returns a hash representation of the execution plan.
-
#to_s ⇒ String
Returns a formatted string representation of the execution plan.
Constructor Details
#initialize(tasks, expected_answer) ⇒ ExecutionPlan
Returns a new instance of ExecutionPlan.
25 26 27 28 |
# File 'lib/agentic/execution_plan.rb', line 25 def initialize(tasks, expected_answer) @tasks = tasks @expected_answer = expected_answer end |
Instance Attribute Details
#expected_answer ⇒ ExpectedAnswerFormat (readonly)
Returns The expected answer format.
21 22 23 |
# File 'lib/agentic/execution_plan.rb', line 21 def expected_answer @expected_answer end |
#tasks ⇒ Array<TaskDefinition> (readonly)
Returns The list of tasks to accomplish the goal.
18 19 20 |
# File 'lib/agentic/execution_plan.rb', line 18 def tasks @tasks end |
Instance Method Details
#to_h ⇒ Hash
Returns a hash representation of the execution plan
32 33 34 35 36 37 |
# File 'lib/agentic/execution_plan.rb', line 32 def to_h { tasks: @tasks.map(&:to_h), expected_answer: @expected_answer.to_h } end |
#to_s ⇒ String
Returns a formatted string representation of the execution plan
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/agentic/execution_plan.rb', line 41 def to_s plan = "Execution Plan:\n\n" @tasks.each_with_index do |task, index| plan += "#{index + 1}. #{task.description} (Agent: #{task.agent.name})\n" end plan += "\nExpected Answer:\n" plan += "Format: #{@expected_answer.format}\n" plan += "Sections: #{@expected_answer.sections.join(", ")}\n" plan += "Length: #{@expected_answer.length}\n" plan end |