From c183b2aa803a0ceb7dc0a95087c19983cc8dd137 Mon Sep 17 00:00:00 2001 From: aakashb95 Date: Wed, 22 Jul 2026 13:36:19 +0530 Subject: [PATCH] fix(captain): allow FAQ answers across agent messages --- .../captain/llm/conversation_faq_prompts_service.rb | 2 +- .../llm/conversation_faq_prompts_service_spec.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 spec/enterprise/services/captain/llm/conversation_faq_prompts_service_spec.rb diff --git a/enterprise/app/services/captain/llm/conversation_faq_prompts_service.rb b/enterprise/app/services/captain/llm/conversation_faq_prompts_service.rb index 155e10a06..2e1c68670 100644 --- a/enterprise/app/services/captain/llm/conversation_faq_prompts_service.rb +++ b/enterprise/app/services/captain/llm/conversation_faq_prompts_service.rb @@ -11,7 +11,7 @@ class Captain::Llm::ConversationFaqPromptsService - Base every FAQ strictly on information stated in the human support agent messages. Do not infer, generalize, or add external knowledge. - A human support agent must state every fact used in the FAQ answer. Customer messages cannot supply missing answer facts. - The human support agent must provide the final answer. If the agent only greets, asks clarifying questions, asks for contact details, promises to check, shares an attachment, or transfers the conversation, return: `{"faqs":[]}`. - - For each FAQ, first identify the exact human support agent message that fully answers it. If no single human agent message gives a complete public answer, remove that FAQ. + - For each FAQ, identify the human support agent message or messages that together provide a complete public answer to the same question. Combine facts only across related agent messages; never combine separate questions or unrelated topics. If those messages do not provide a complete public answer, remove that FAQ. ## Decision gate Return `{"faqs":[]}` unless every generated FAQ can pass all of these checks: diff --git a/spec/enterprise/services/captain/llm/conversation_faq_prompts_service_spec.rb b/spec/enterprise/services/captain/llm/conversation_faq_prompts_service_spec.rb new file mode 100644 index 000000000..d1d5fcfb3 --- /dev/null +++ b/spec/enterprise/services/captain/llm/conversation_faq_prompts_service_spec.rb @@ -0,0 +1,13 @@ +require 'rails_helper' + +RSpec.describe Captain::Llm::ConversationFaqPromptsService do + describe '.generator' do + it 'allows a complete FAQ answer to use several related agent messages' do + prompt = described_class.generator + + expect(prompt).to include('message or messages that together provide a complete public answer') + expect(prompt).to include('Combine facts only across related agent messages') + expect(prompt).not_to include('no single human agent message') + end + end +end