From c07d03e4e5cc0e4f443ea0f779ba0829ae4d4851 Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma <32020192+tds-1@users.noreply.github.com> Date: Tue, 11 Nov 2025 21:21:24 +0530 Subject: [PATCH] fix: hide pdf citations in captain faq responses (#12839) --- enterprise/lib/captain/tools/faq_lookup_tool.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/enterprise/lib/captain/tools/faq_lookup_tool.rb b/enterprise/lib/captain/tools/faq_lookup_tool.rb index d09b7c2d7..93dd90259 100644 --- a/enterprise/lib/captain/tools/faq_lookup_tool.rb +++ b/enterprise/lib/captain/tools/faq_lookup_tool.rb @@ -28,7 +28,7 @@ class Captain::Tools::FaqLookupTool < Captain::Tools::BasePublicTool Question: #{response.question} Answer: #{response.answer} " - if response.documentable.present? && response.documentable.try(:external_link) + if should_show_source?(response) formatted_response += " Source: #{response.documentable.external_link} " @@ -36,4 +36,13 @@ class Captain::Tools::FaqLookupTool < Captain::Tools::BasePublicTool formatted_response end + + def should_show_source?(response) + return false if response.documentable.blank? + return false unless response.documentable.try(:external_link) + + # Don't show source if it's a PDF placeholder + external_link = response.documentable.external_link + !external_link.start_with?('PDF:') + end end