Class: Agentic::TaskResult

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

Overview

Represents the result of a task execution

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task_id:, success:, output: nil, failure: nil) ⇒ TaskResult

Initializes a new task result

Parameters:

  • task_id (String)

    The ID of the task that produced this result

  • success (Boolean)

    Whether the task execution was successful

  • output (Hash, nil) (defaults to: nil)

    The output produced by the task

  • failure (TaskFailure, nil) (defaults to: nil)

    The failure information



18
19
20
21
22
23
# File 'lib/agentic/task_result.rb', line 18

def initialize(task_id:, success:, output: nil, failure: nil)
  @task_id = task_id
  @success = success
  @output = output
  @failure = failure
end

Instance Attribute Details

#failureTaskFailure? (readonly)

The failure information, nil if successful

Returns:



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

def failure
  @failure
end

#outputHash? (readonly)

The output produced by the task, nil if unsuccessful

Returns:

  • (Hash, nil)

    the current value of output



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

def output
  @output
end

#successBoolean (readonly)

Whether the task execution was successful

Returns:

  • (Boolean)

    the current value of success



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

def success
  @success
end

#task_idString (readonly)

The ID of the task that produced this result

Returns:

  • (String)

    the current value of task_id



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

def task_id
  @task_id
end

Instance Method Details

#failed?Boolean

Checks if the task execution failed

Returns:

  • (Boolean)

    True if failed, false otherwise



33
34
35
# File 'lib/agentic/task_result.rb', line 33

def failed?
  !@success
end

#successful?Boolean

Checks if the task execution was successful

Returns:

  • (Boolean)

    True if successful, false otherwise



27
28
29
# File 'lib/agentic/task_result.rb', line 27

def successful?
  @success
end

#to_hHash

Returns a serializable representation of the result

Returns:

  • (Hash)

    The result as a hash



39
40
41
42
43
44
45
46
# File 'lib/agentic/task_result.rb', line 39

def to_h
  {
    task_id: @task_id,
    success: @success,
    output: @output,
    failure: @failure&.to_h
  }
end