class Riffer::Agent::Outcome
How a run ended โ the single place to read whether the agent completed normally and, if not, why. detail carries the specifics when there are any: the tripwire reason, the interrupt reason, the providerโs raw finish value, or the structured output parse/validation error.
response = agent.generate("Analyze this") case response.outcome.reason when :completed then puts response.structured_output when :invalid_structured_output then warn response.outcome.detail end
Constants
- NORMAL_FINISH_REASONS
-
Finish reasons that end a turn normally; every other finish reason means the provider cut the turn short and surfaces as the runโs outcome verbatim.
- PROVIDER_STOP_REASONS
-
Derived from the provider vocabulary so a new finish reason becomes an outcome without a second list to update.
- VALUES
-
The vocabulary every run ends in.
Attributes
Human-readable specifics for reason, when there are any.
Why the run ended.
Public Class Methods
Source
# File lib/riffer/agent/outcome.rb, line 36 def initialize(reason:, detail: nil) unless VALUES.include?(reason) raise Riffer::ArgumentError, "reason must be one of #{VALUES.inspect}, got #{reason.inspect}" end @reason = reason @detail = detail end
Raises Riffer::ArgumentError when reason is outside VALUES.
Public Instance Methods
Source
# File lib/riffer/agent/outcome.rb, line 49 def success? reason == :completed end
Returns true when the run completed normally.