Class: Agentic::ExecutionPlan

Inherits:
Object
  • Object
show all
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:

  1. TaskPlanner generates the core plan data

  2. ExecutionPlan serves as a structured value object to hold this data

  3. 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

Instance Method Summary collapse

Constructor Details

#initialize(tasks, expected_answer) ⇒ ExecutionPlan

Returns a new instance of ExecutionPlan.

Parameters:



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_answerExpectedAnswerFormat (readonly)

Returns The expected answer format.

Returns:



21
22
23
# File 'lib/agentic/execution_plan.rb', line 21

def expected_answer
  @expected_answer
end

#tasksArray<TaskDefinition> (readonly)

Returns The list of tasks to accomplish the goal.

Returns:

  • (Array<TaskDefinition>)

    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_hHash

Returns a hash representation of the execution plan

Returns:

  • (Hash)

    The execution plan as a hash



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_sString

Returns a formatted string representation of the execution plan

Returns:

  • (String)

    The formatted 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