Class: Agentic::ExecutionResult
- Inherits:
-
Object
- Object
- Agentic::ExecutionResult
- Defined in:
- lib/agentic/execution_result.rb
Overview
Value object representing the results of plan execution
Instance Attribute Summary collapse
-
#execution_time ⇒ Float
readonly
The total execution time in seconds.
-
#plan_id ⇒ String
readonly
The ID of the plan.
-
#results ⇒ Hash
readonly
The results of the tasks, keyed by task ID.
-
#status ⇒ Symbol
readonly
The status of the execution (:completed, :partial_failure, :failed).
-
#tasks ⇒ Hash
readonly
The tasks that were executed, keyed by ID.
Instance Method Summary collapse
-
#failed? ⇒ Boolean
Checks if the execution completely failed.
-
#initialize(plan_id:, status:, execution_time:, tasks:, results:) ⇒ ExecutionResult
constructor
Initializes a new execution result.
-
#partial_failure? ⇒ Boolean
Checks if the execution partially failed.
-
#successful? ⇒ Boolean
Checks if the execution was fully successful.
-
#summary ⇒ Hash
Returns a summary of the execution result.
-
#task_result(task_id) ⇒ TaskResult?
Returns the result for a specific task.
-
#to_h ⇒ Hash
Returns a hash representation of the execution result.
Constructor Details
#initialize(plan_id:, status:, execution_time:, tasks:, results:) ⇒ ExecutionResult
Initializes a new execution result
27 28 29 30 31 32 33 |
# File 'lib/agentic/execution_result.rb', line 27 def initialize(plan_id:, status:, execution_time:, tasks:, results:) @plan_id = plan_id @status = status @execution_time = execution_time @tasks = tasks @results = results end |
Instance Attribute Details
#execution_time ⇒ Float (readonly)
Returns The total execution time in seconds.
13 14 15 |
# File 'lib/agentic/execution_result.rb', line 13 def execution_time @execution_time end |
#plan_id ⇒ String (readonly)
Returns The ID of the plan.
7 8 9 |
# File 'lib/agentic/execution_result.rb', line 7 def plan_id @plan_id end |
#results ⇒ Hash (readonly)
Returns The results of the tasks, keyed by task ID.
19 20 21 |
# File 'lib/agentic/execution_result.rb', line 19 def results @results end |
#status ⇒ Symbol (readonly)
Returns The status of the execution (:completed, :partial_failure, :failed).
10 11 12 |
# File 'lib/agentic/execution_result.rb', line 10 def status @status end |
#tasks ⇒ Hash (readonly)
Returns The tasks that were executed, keyed by ID.
16 17 18 |
# File 'lib/agentic/execution_result.rb', line 16 def tasks @tasks end |
Instance Method Details
#failed? ⇒ Boolean
Checks if the execution completely failed
56 57 58 |
# File 'lib/agentic/execution_result.rb', line 56 def failed? @status == :failed end |
#partial_failure? ⇒ Boolean
Checks if the execution partially failed
50 51 52 |
# File 'lib/agentic/execution_result.rb', line 50 def partial_failure? @status == :partial_failure end |
#successful? ⇒ Boolean
Checks if the execution was fully successful
44 45 46 |
# File 'lib/agentic/execution_result.rb', line 44 def successful? @status == :completed end |
#summary ⇒ Hash
Returns a summary of the execution result
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/agentic/execution_result.rb', line 74 def summary total_tasks = @tasks.size successful_tasks = @results.count { |_, result| result.successful? } failed_tasks = @results.count { |_, result| result.failed? } { plan_id: @plan_id, status: @status, execution_time: @execution_time, task_counts: { total: total_tasks, successful: successful_tasks, failed: failed_tasks } } end |
#task_result(task_id) ⇒ TaskResult?
Returns the result for a specific task
38 39 40 |
# File 'lib/agentic/execution_result.rb', line 38 def task_result(task_id) @results[task_id] end |
#to_h ⇒ Hash
Returns a hash representation of the execution result
62 63 64 65 66 67 68 69 70 |
# File 'lib/agentic/execution_result.rb', line 62 def to_h { plan_id: @plan_id, status: @status, execution_time: @execution_time, tasks: @tasks.transform_values { |task| task.is_a?(Task) ? task.to_h : task }, results: @results.transform_values { |result| result.is_a?(TaskResult) ? result.to_h : result } } end |