Class: Assistant::TechnicalSupport::ResponseGroundingGate

Inherits:
Object
  • Object
show all
Includes:
Service
Defined in:
app/services/assistant/technical_support/response_grounding_gate.rb

Overview

Audits one persisted Sunny Technical Support turn against the successful
tool results still present in the live transcript. Shadow mode records the
decision on the assistant message without changing its already-streamed text.

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Methods included from Service

#attributes_used, #build_result, call, #logger

Methods included from Service::Initializer

#initialize

Instance Method Details

#callResult

Audits and persists one response, failing open on operational errors.

Returns:

  • (Result)

    gate applicability, status, and stored assessment



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/services/assistant/technical_support/response_grounding_gate.rb', line 40

def call
  return Result.new(applicable: false, status: 'not_applicable') unless applicable?

  @response_message = find_response_message
  return missing_response_result unless response_message

  assessment = assess_response
  result_for(persist(assessment))
rescue ResponseGroundingAnalyzer::InvalidResponse => e
  record_failure(status: 'inconclusive', reason: 'invalid_structured_response', error: e)
rescue StandardError => e
  record_failure(status: 'error', reason: 'assessment_failed', error: e)
end