Class: Agentic::PlanExecutionResult

Inherits:
Object
  • Object
show all
Defined in:
lib/agentic/plan_execution_result.rb

Overview

Value object representing the execution result of a plan

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plan_id:, status:, execution_time:, tasks:, results:) ⇒ PlanExecutionResult

Initializes a new plan execution result

Parameters:

  • plan_id (String)

    The unique identifier for the plan

  • status (Symbol)

    The overall status of the plan

  • execution_time (Float)

    The execution time in seconds

  • tasks (Hash)

    Map of task ids to serialized Task objects

  • results (Hash)

    Map of task ids to raw execution results



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

Returns The execution time in seconds.

Returns:

  • (Float)

    The execution time in seconds



15
16
17
# File 'lib/agentic/plan_execution_result.rb', line 15

def execution_time
  @execution_time
end

#plan_idString (readonly)

Returns The unique identifier for the plan.

Returns:

  • (String)

    The unique identifier for the plan



9
10
11
# File 'lib/agentic/plan_execution_result.rb', line 9

def plan_id
  @plan_id
end

#resultsHash<String, TaskExecutionResult> (readonly)

Returns The execution results for each task.

Returns:



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

def results
  @results
end

#statusSymbol (readonly)

Returns The overall status of the plan (:completed, :in_progress, :partial_failure).

Returns:

  • (Symbol)

    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

#tasksHash (readonly)

Returns Map of task ids to serialized Task objects.

Returns:

  • (Hash)

    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

Parameters:

  • hash (Hash)

    The hash representation of a plan execution result

Returns:



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_countInteger

Gets the number of completed tasks

Returns:

  • (Integer)

    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_resultsHash<String, TaskExecutionResult>

Gets the failed task results

Returns:



102
103
104
# File 'lib/agentic/plan_execution_result.rb', line 102

def failed_task_results
  @results.select { |_, result| result.failed? }
end

#failed_tasks_countInteger

Gets the number of failed tasks

Returns:

  • (Integer)

    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

Returns:

  • (Boolean)

    True if in progress, false otherwise



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

Returns:

  • (Boolean)

    True if partially failed, false otherwise



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

Returns:

  • (Boolean)

    True if successful, false otherwise



52
53
54
# File 'lib/agentic/plan_execution_result.rb', line 52

def successful?
  @status == :completed
end

#successful_task_resultsHash<String, TaskExecutionResult>

Gets the successful task results

Returns:



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

Parameters:

  • task_id (String)

    The ID of the task

Returns:

  • (Hash, nil)

    The serialized task data, or nil if not found



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

Parameters:

  • task_id (String)

    The ID of the task

Returns:



71
72
73
# File 'lib/agentic/plan_execution_result.rb', line 71

def task_result(task_id)
  @results[task_id]
end

#to_hHash

Returns a hash representation of the plan execution result

Returns:

  • (Hash)

    The plan execution result as a hash



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