Exception: Agentic::Errors::LlmRefusalError

Inherits:
LlmError
  • Object
show all
Defined in:
lib/agentic/errors/llm_error.rb

Overview

Error raised when the LLM refuses to respond

Instance Attribute Summary collapse

Attributes inherited from LlmError

#context, #response

Instance Method Summary collapse

Constructor Details

#initialize(refusal_message, refusal_category: nil, response: nil, context: nil) ⇒ LlmRefusalError



35
36
37
38
39
# File 'lib/agentic/errors/llm_error.rb', line 35

def initialize(refusal_message, refusal_category: nil, response: nil, context: nil)
  super("LLM refused to respond: #{refusal_message}", response: response, context: context)
  @refusal_message = refusal_message
  @refusal_category = refusal_category || determine_refusal_category(refusal_message)
end

Instance Attribute Details

#refusal_categorySymbol (readonly)



29
30
31
# File 'lib/agentic/errors/llm_error.rb', line 29

def refusal_category
  @refusal_category
end

#refusal_messageString (readonly)



26
27
28
# File 'lib/agentic/errors/llm_error.rb', line 26

def refusal_message
  @refusal_message
end

Instance Method Details

#retryable_with_modifications?Boolean

Determines whether this refusal is retryable with modifications



43
44
45
# File 'lib/agentic/errors/llm_error.rb', line 43

def retryable_with_modifications?
  [:unclear_instructions, :needs_clarification, :ambiguous_request, :format_error].include?(@refusal_category)
end