Class: Agentic::TaskResult
- Inherits:
-
Object
- Object
- Agentic::TaskResult
- Defined in:
- lib/agentic/task_result.rb
Overview
Represents the result of a task execution
Instance Attribute Summary collapse
-
#failure ⇒ TaskFailure?
readonly
The failure information, nil if successful.
-
#output ⇒ Hash?
readonly
The output produced by the task, nil if unsuccessful.
-
#success ⇒ Boolean
readonly
Whether the task execution was successful.
-
#task_id ⇒ String
readonly
The ID of the task that produced this result.
Instance Method Summary collapse
-
#failed? ⇒ Boolean
Checks if the task execution failed.
-
#initialize(task_id:, success:, output: nil, failure: nil) ⇒ TaskResult
constructor
Initializes a new task result.
-
#successful? ⇒ Boolean
Checks if the task execution was successful.
-
#to_h ⇒ Hash
Returns a serializable representation of the result.
Constructor Details
#initialize(task_id:, success:, output: nil, failure: nil) ⇒ TaskResult
Initializes a new task result
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
#failure ⇒ TaskFailure? (readonly)
The failure information, nil if successful
9 10 11 |
# File 'lib/agentic/task_result.rb', line 9 def failure @failure end |
#output ⇒ Hash? (readonly)
The output produced by the task, nil if unsuccessful
9 10 11 |
# File 'lib/agentic/task_result.rb', line 9 def output @output end |
#success ⇒ Boolean (readonly)
Whether the task execution was successful
9 10 11 |
# File 'lib/agentic/task_result.rb', line 9 def success @success end |
#task_id ⇒ String (readonly)
The ID of the task that produced this result
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
33 34 35 |
# File 'lib/agentic/task_result.rb', line 33 def failed? !@success end |
#successful? ⇒ Boolean
Checks if the task execution was successful
27 28 29 |
# File 'lib/agentic/task_result.rb', line 27 def successful? @success end |
#to_h ⇒ Hash
Returns a serializable representation of the result
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 |