Class: Agentic::ExecutionResult

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

Overview

Value object representing the results of plan execution

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initializes a new execution result

Parameters:

  • plan_id (String)

    The ID of the plan

  • status (Symbol)

    The status of the execution

  • execution_time (Float)

    The total execution time in seconds

  • tasks (Hash)

    The tasks that were executed, keyed by ID

  • results (Hash)

    The results of the tasks, keyed by task ID



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

Returns The total execution time in seconds.

Returns:

  • (Float)

    The total execution time in seconds



13
14
15
# File 'lib/agentic/execution_result.rb', line 13

def execution_time
  @execution_time
end

#plan_idString (readonly)

Returns The ID of the plan.

Returns:

  • (String)

    The ID of the plan



7
8
9
# File 'lib/agentic/execution_result.rb', line 7

def plan_id
  @plan_id
end

#resultsHash (readonly)

Returns The results of the tasks, keyed by task ID.

Returns:

  • (Hash)

    The results of the tasks, keyed by task ID



19
20
21
# File 'lib/agentic/execution_result.rb', line 19

def results
  @results
end

#statusSymbol (readonly)

Returns The status of the execution (:completed, :partial_failure, :failed).

Returns:

  • (Symbol)

    The status of the execution (:completed, :partial_failure, :failed)



10
11
12
# File 'lib/agentic/execution_result.rb', line 10

def status
  @status
end

#tasksHash (readonly)

Returns The tasks that were executed, keyed by ID.

Returns:

  • (Hash)

    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

Returns:

  • (Boolean)

    True if the plan failed to complete



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

Returns:

  • (Boolean)

    True if some tasks failed but the plan completed



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

Returns:

  • (Boolean)

    True if all tasks succeeded



44
45
46
# File 'lib/agentic/execution_result.rb', line 44

def successful?
  @status == :completed
end

#summaryHash

Returns a summary of the execution result

Returns:

  • (Hash)

    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

Parameters:

  • task_id (String)

    The ID of the task

Returns:

  • (TaskResult, nil)

    The result of the task, or nil if not found



38
39
40
# File 'lib/agentic/execution_result.rb', line 38

def task_result(task_id)
  @results[task_id]
end

#to_hHash

Returns a hash representation of the execution result

Returns:

  • (Hash)

    The execution result as a hash



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