Class: Agentic::PlanExecutionResult
- Inherits:
-
Object
- Object
- Agentic::PlanExecutionResult
- Defined in:
- lib/agentic/plan_execution_result.rb
Overview
Value object representing the execution result of a plan
Instance Attribute Summary collapse
-
#execution_time ⇒ Float
readonly
The execution time in seconds.
-
#plan_id ⇒ String
readonly
The unique identifier for the plan.
-
#results ⇒ Hash<String, TaskExecutionResult>
readonly
The execution results for each task.
-
#status ⇒ Symbol
readonly
The overall status of the plan (:completed, :in_progress, :partial_failure).
-
#tasks ⇒ Hash
readonly
Map of task ids to serialized Task objects.
Class Method Summary collapse
-
.from_hash(hash) ⇒ PlanExecutionResult
Creates a plan execution result from a hash.
Instance Method Summary collapse
-
#completed_tasks_count ⇒ Integer
Gets the number of completed tasks.
-
#failed_task_results ⇒ Hash<String, TaskExecutionResult>
Gets the failed task results.
-
#failed_tasks_count ⇒ Integer
Gets the number of failed tasks.
-
#in_progress? ⇒ Boolean
Checks if the plan execution is still in progress.
-
#initialize(plan_id:, status:, execution_time:, tasks:, results:) ⇒ PlanExecutionResult
constructor
Initializes a new plan execution result.
-
#partial_failure? ⇒ Boolean
Checks if the plan execution failed partially.
-
#successful? ⇒ Boolean
Checks if the plan execution was successful.
-
#successful_task_results ⇒ Hash<String, TaskExecutionResult>
Gets the successful task results.
-
#task_data(task_id) ⇒ Hash?
Gets the serialized task data for a specific task.
-
#task_result(task_id) ⇒ TaskExecutionResult?
Gets the result for a specific task.
-
#to_h ⇒ Hash
Returns a hash representation of the plan execution result.
Constructor Details
#initialize(plan_id:, status:, execution_time:, tasks:, results:) ⇒ PlanExecutionResult
Initializes a new plan execution result
29 30 31 32 33 34 35 |
# File 'lib/agentic/plan_execution_result.rb', line 29 def initialize(plan_id:, status:, execution_time:, tasks:, results:) @plan_id = plan_id @status = status @execution_time = execution_time @tasks = tasks @results = convert_raw_results(results) end |
Instance Attribute Details
#execution_time ⇒ Float (readonly)
Returns The execution time in seconds.
15 16 17 |
# File 'lib/agentic/plan_execution_result.rb', line 15 def execution_time @execution_time end |
#plan_id ⇒ String (readonly)
Returns The unique identifier for the plan.
9 10 11 |
# File 'lib/agentic/plan_execution_result.rb', line 9 def plan_id @plan_id end |
#results ⇒ Hash<String, TaskExecutionResult> (readonly)
Returns The execution results for each task.
21 22 23 |
# File 'lib/agentic/plan_execution_result.rb', line 21 def results @results end |
#status ⇒ Symbol (readonly)
Returns The overall status of the plan (:completed, :in_progress, :partial_failure).
12 13 14 |
# File 'lib/agentic/plan_execution_result.rb', line 12 def status @status end |
#tasks ⇒ Hash (readonly)
Returns Map of task ids to serialized Task objects.
18 19 20 |
# File 'lib/agentic/plan_execution_result.rb', line 18 def tasks @tasks end |
Class Method Details
.from_hash(hash) ⇒ PlanExecutionResult
Creates a plan execution result from a hash
40 41 42 43 44 45 46 47 48 |
# File 'lib/agentic/plan_execution_result.rb', line 40 def self.from_hash(hash) new( plan_id: hash[:plan_id], status: hash[:status], execution_time: hash[:execution_time], tasks: hash[:tasks], results: hash[:results] ) end |
Instance Method Details
#completed_tasks_count ⇒ Integer
Gets the number of completed tasks
84 85 86 |
# File 'lib/agentic/plan_execution_result.rb', line 84 def completed_tasks_count @results.count { |_, result| result.successful? } end |
#failed_task_results ⇒ Hash<String, TaskExecutionResult>
Gets the failed task results
102 103 104 |
# File 'lib/agentic/plan_execution_result.rb', line 102 def failed_task_results @results.select { |_, result| result.failed? } end |
#failed_tasks_count ⇒ Integer
Gets the number of failed tasks
90 91 92 |
# File 'lib/agentic/plan_execution_result.rb', line 90 def failed_tasks_count @results.count { |_, result| result.failed? } end |
#in_progress? ⇒ Boolean
Checks if the plan execution is still in progress
64 65 66 |
# File 'lib/agentic/plan_execution_result.rb', line 64 def in_progress? @status == :in_progress end |
#partial_failure? ⇒ Boolean
Checks if the plan execution failed partially
58 59 60 |
# File 'lib/agentic/plan_execution_result.rb', line 58 def partial_failure? @status == :partial_failure end |
#successful? ⇒ Boolean
Checks if the plan execution was successful
52 53 54 |
# File 'lib/agentic/plan_execution_result.rb', line 52 def successful? @status == :completed end |
#successful_task_results ⇒ Hash<String, TaskExecutionResult>
Gets the successful task results
96 97 98 |
# File 'lib/agentic/plan_execution_result.rb', line 96 def successful_task_results @results.select { |_, result| result.successful? } end |
#task_data(task_id) ⇒ Hash?
Gets the serialized task data for a specific task
78 79 80 |
# File 'lib/agentic/plan_execution_result.rb', line 78 def task_data(task_id) @tasks[task_id] end |
#task_result(task_id) ⇒ TaskExecutionResult?
Gets the result for a specific task
71 72 73 |
# File 'lib/agentic/plan_execution_result.rb', line 71 def task_result(task_id) @results[task_id] end |
#to_h ⇒ Hash
Returns a hash representation of the plan execution result
108 109 110 111 112 113 114 115 116 |
# File 'lib/agentic/plan_execution_result.rb', line 108 def to_h { plan_id: @plan_id, status: @status, execution_time: @execution_time, tasks: @tasks, results: @results.transform_values(&:to_h) } end |