Class: Prescient::Agent::ErrorSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/prescient/agent/error_serializer.rb

Overview

Converts provider and tool failures into bounded, safe agent data.

Constant Summary collapse

CATEGORY_MAP =

Returns Provider/tool error categories.

Returns:

  • (Array<Array<Class, String>>)

    Provider/tool error categories

[
  [Prescient::AuthenticationError, "authentication_failed"],
  [Prescient::ConnectionError, "provider_unavailable"],
  [Prescient::RateLimitError, "rate_limited"],
  [Prescient::ModelNotAvailableError, "model_unavailable"],
  [Prescient::InvalidResponseError, "invalid_provider_response"],
  [Prescient::ProviderError, "provider_failure"],
  [Prescient::ToolConfigurationError, "tool_configuration_error"],
  [Prescient::ToolConnectionError, "tool_unavailable"],
  [Prescient::ToolInvalidResponseError, "invalid_tool_response"],
  [Prescient::ToolError, "tool_failure"]
].freeze

Class Method Summary collapse

Class Method Details

.serialize(error) ⇒ Hash

Returns Safe error envelope.

Parameters:

  • error (Exception)

    Failure to serialize

Returns:

  • (Hash)

    Safe error envelope



24
25
26
27
28
29
30
31
# File 'lib/prescient/agent/error_serializer.rb', line 24

def serialize(error)
  {
    error: {
      category: category_for(error),
      message: safe_message(error)
    }
  }
end