class LittleGhost::Harnesses::Result
The outcome of one Harnesses::Base#run.
status is one of:
:completed-
The tool finished its task.
:failed-
The tool reported an error or exited unsuccessfully.
:timed_out-
The request’s
timeoutelapsed and the process was stopped. :budget_exceeded-
The tool or the harness stopped because spending exceeded
budget_usd. :turns_exceeded-
The tool or the harness stopped because work exceeded
max_turns.
Any of text, session_id, cost_usd, turns, and stop_reason may be nil when the tool did not report them. A Result contains the tool’s output, which can include repository content; treat it as untrusted.
Attributes
Reported spend in US dollars, or nil when the tool does not report it.
Process exit status, or nil when the process was stopped by a signal.
Identifier of the harness that produced the result, such as :codex.
One of :completed, :failed, :timed_out, :budget_exceeded, or :turns_exceeded.
The last few kilobytes of standard error.
The tool’s own reason for stopping, as a String, or nil.
The tool’s final answer, or nil.
Number of agent turns, or nil.
Token counts as a LittleGhost::Usage.
Public Class Methods
# File lib/little_ghost/harnesses/result.rb, line 70 def initialize(harness:, status:, usage: Usage.new, text: nil, session_id: nil, cost_usd: nil, turns: nil, exit_code: nil, stop_reason: nil, stderr_tail: "") status = status.to_sym raise ArgumentError, "unknown harness result status: #{status}" unless STATUSES.include?(status) super( harness: harness.to_sym, status:, text: text&.dup&.freeze, session_id: session_id&.dup&.freeze, cost_usd:, usage:, turns:, exit_code:, stop_reason: stop_reason&.to_s&.dup&.freeze, stderr_tail: String(stderr_tail).dup.freeze ) end
Builds a result. Raises ArgumentError for an unknown status.
Public Instance Methods
Source
# File lib/little_ghost/harnesses/result.rb, line 90 def completed? = status == :completed
Whether the tool finished its task.
Source
# File lib/little_ghost/harnesses/result.rb, line 93 def to_h super.merge(usage: usage.to_h) end
Returns a JSON-compatible Hash with usage expanded.