class Riffer::Agent::Response
Wraps agent generation responses with optional tripwire information.
When guardrails block execution, the response will contain a tripwire with details about the block. The content will be empty for blocked responses.
response = agent.generate(โHelloโ) if response.blocked? puts โBlocked: #{response.tripwire.reason}โ else puts response.content end
Attributes
The response content.
The reason provided with the interrupt, if any.
The modifications made by guardrails during processing.
The parsed structured output, if structured output was configured.
The tripwire if execution was blocked.
Public Class Methods
Source
# File lib/riffer/agent/response.rb, line 41 def initialize(content, tripwire: nil, modifications: [], interrupted: false, interrupt_reason: nil, structured_output: nil) @content = content @tripwire = tripwire @modifications = modifications @interrupted = interrupted @interrupt_reason = interrupt_reason @structured_output = structured_output end
Creates a new response.
+content+ - the response content. +tripwire+ - optional tripwire for blocked responses. +modifications+ - guardrail modifications applied during processing. +interrupted+ - whether the agent loop was interrupted by a callback. +interrupt_reason+ - optional reason passed via +throw :riffer_interrupt, reason+. +structured_output+ - parsed structured output when structured output is configured.
: (String, ?tripwire: Riffer::Guardrails::Tripwire?, ?modifications: Array, ?interrupted: bool, ?interrupt_reason: (String | Symbol)?, ?structured_output: Hash[Symbol, untyped]?) -> void
Public Instance Methods
Source
# File lib/riffer/agent/response.rb, line 53 def blocked? !tripwire.nil? end
Returns true if the response was blocked by a guardrail.
: () -> bool
Source
# File lib/riffer/agent/response.rb, line 68 def interrupted? @interrupted end
Returns true if the agent loop was interrupted by a callback via +throw :riffer_interrupt+.
: () -> bool
Source
# File lib/riffer/agent/response.rb, line 60 def modified? modifications.any? end
Returns true if any guardrail modified data during processing.
: () -> bool