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.
Call ids of tool_use blocks that riffer filled with placeholder results during this turn — populated when an interrupt left them unanswered and Riffer.config.experimental_history_healing is on. Empty otherwise.
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 56 def initialize(content, tripwire: nil, modifications: [], interrupted: false, interrupt_reason: nil, structured_output: nil, messages: [], healed_tool_call_ids: []) @content = content @tripwire = tripwire @modifications = modifications @interrupted = interrupted @interrupt_reason = interrupt_reason @structured_output = structured_output @messages = messages @healed_tool_call_ids = healed_tool_call_ids 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.
healed_tool_call_ids-
call ids filled with placeholder tool results
when history healing is enabled.
Public Instance Methods
Source
# File lib/riffer/agent/response.rb, line 71 def blocked? !tripwire.nil? end
Returns true if the response was blocked by a guardrail.
Source
# File lib/riffer/agent/response.rb, line 88 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 79 def modified? modifications.any? end
Returns true if any guardrail modified data during processing.