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 full message history from the agent conversation.
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 46 def initialize(content, tripwire: nil, modifications: [], interrupted: false, interrupt_reason: nil, structured_output: nil, messages: []) @content = content @tripwire = tripwire @modifications = modifications @interrupted = interrupted @interrupt_reason = interrupt_reason @structured_output = structured_output @messages = messages 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.
- messages
-
the full message history from the agent conversation.
Public Instance Methods
Source
# File lib/riffer/agent/response.rb, line 60 def blocked? !tripwire.nil? end
Returns true if the response was blocked by a guardrail.
Source
# File lib/riffer/agent/response.rb, line 77 def interrupted? @interrupted end
Returns true if the agent loop was interrupted by a callback via throw :riffer_interrupt.
Source
# File lib/riffer/agent/response.rb, line 68 def modified? modifications.any? end
Returns true if any guardrail modified data during processing.