Class: Riffer::Agent::Response
- Inherits:
-
Object
- Object
- Riffer::Agent::Response
- Defined in:
- lib/riffer/agent/response.rb
Overview
Wraps an agent generation response. When a guardrail blocks execution, content is empty and tripwire carries the block details.
response = agent.generate("Hello")
if response.blocked?
puts "Blocked: #{response.tripwire.reason}"
else
puts response.content
end
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
The response content.
-
#healed_tool_call_ids ⇒ Object
readonly
Call ids of tool_use blocks riffer filled with placeholder results this turn (when an interrupt left them unanswered and history healing is on).
-
#interrupt_reason ⇒ Object
readonly
The reason provided with the interrupt, if any.
-
#messages ⇒ Object
readonly
The full message history from the agent conversation.
-
#modifications ⇒ Object
readonly
The modifications made by guardrails during processing.
-
#structured_output ⇒ Object
readonly
The parsed structured output, if structured output was configured.
-
#tripwire ⇒ Object
readonly
The tripwire if execution was blocked.
Instance Method Summary collapse
-
#blocked? ⇒ Boolean
Returns true if the response was blocked by a guardrail.
- #initialize(content, tripwire: nil, modifications: [], interrupted: false, interrupt_reason: nil, structured_output: nil, messages: [], healed_tool_call_ids: []) ⇒ Response constructor
-
#interrupted? ⇒ Boolean
Returns true if the agent loop was interrupted by a callback via
throw :riffer_interrupt. -
#modified? ⇒ Boolean
Returns true if any guardrail modified data during processing.
Constructor Details
#initialize(content, tripwire: nil, modifications: [], interrupted: false, interrupt_reason: nil, structured_output: nil, messages: [], healed_tool_call_ids: []) ⇒ Response
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/riffer/agent/response.rb', line 40 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 = @healed_tool_call_ids = healed_tool_call_ids end |
Instance Attribute Details
#content ⇒ Object (readonly)
The response content.
17 18 19 |
# File 'lib/riffer/agent/response.rb', line 17 def content @content end |
#healed_tool_call_ids ⇒ Object (readonly)
Call ids of tool_use blocks riffer filled with placeholder results this turn (when an interrupt left them unanswered and history healing is on).
36 37 38 |
# File 'lib/riffer/agent/response.rb', line 36 def healed_tool_call_ids @healed_tool_call_ids end |
#interrupt_reason ⇒ Object (readonly)
The reason provided with the interrupt, if any.
26 27 28 |
# File 'lib/riffer/agent/response.rb', line 26 def interrupt_reason @interrupt_reason end |
#messages ⇒ Object (readonly)
The full message history from the agent conversation.
32 33 34 |
# File 'lib/riffer/agent/response.rb', line 32 def @messages end |
#modifications ⇒ Object (readonly)
The modifications made by guardrails during processing.
23 24 25 |
# File 'lib/riffer/agent/response.rb', line 23 def modifications @modifications end |
#structured_output ⇒ Object (readonly)
The parsed structured output, if structured output was configured.
29 30 31 |
# File 'lib/riffer/agent/response.rb', line 29 def structured_output @structured_output end |
#tripwire ⇒ Object (readonly)
The tripwire if execution was blocked.
20 21 22 |
# File 'lib/riffer/agent/response.rb', line 20 def tripwire @tripwire end |
Instance Method Details
#blocked? ⇒ Boolean
Returns true if the response was blocked by a guardrail.
– : () -> bool
55 56 57 |
# File 'lib/riffer/agent/response.rb', line 55 def blocked? !tripwire.nil? end |
#interrupted? ⇒ Boolean
Returns true if the agent loop was interrupted by a callback via throw :riffer_interrupt.
– : () -> bool
72 73 74 |
# File 'lib/riffer/agent/response.rb', line 72 def interrupted? @interrupted end |
#modified? ⇒ Boolean
Returns true if any guardrail modified data during processing.
– : () -> bool
63 64 65 |
# File 'lib/riffer/agent/response.rb', line 63 def modified? modifications.any? end |