From b7b6e67df79e2353945cf3b97fde7b9f631e17aa Mon Sep 17 00:00:00 2001
From: Petterson <58094725+hahuma@users.noreply.github.com>
Date: Tue, 14 Apr 2026 09:06:10 -0300
Subject: [PATCH] fix(captain): localize AI summary to account language
(#13790)
AI-generated summaries now respect the account's language setting.
Previously, summaries were always returned in English regardless of the
user's configured language, making section headings like "Customer
Intent" and "Action Items" appear in English even for non-English
accounts.
Previous behavior:
Current Behavior:
## What changed
- Added explicit account locale to the AI system prompt in
`Captain::SummaryService`
- Updated the summary prompt template to instruct the model to translate
section headings
## How to test
1. Configure an account with a non-English language (e.g., Portuguese)
2. Open a conversation with messages
3. Use the Copilot "Summarize" feature
4. Verify that section headings ("Customer Intent", "Conversation
Summary", etc.) appear in the account's language
---------
Co-authored-by: Aakash Bakhle <48802744+aakashb95@users.noreply.github.com>
---
lib/captain/summary_service.rb | 10 +++++++++-
lib/integrations/openai/openai_prompts/summary.liquid | 2 +-
spec/lib/captain/summary_service_spec.rb | 3 ++-
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lib/captain/summary_service.rb b/lib/captain/summary_service.rb
index 16ee57b51..030c0e510 100644
--- a/lib/captain/summary_service.rb
+++ b/lib/captain/summary_service.rb
@@ -5,7 +5,7 @@ class Captain::SummaryService < Captain::BaseTaskService
make_api_call(
model: GPT_MODEL,
messages: [
- { role: 'system', content: prompt_from_file('summary') },
+ { role: 'system', content: system_prompt },
{ role: 'user', content: conversation.to_llm_text(include_contact_details: false) }
]
)
@@ -13,6 +13,14 @@ class Captain::SummaryService < Captain::BaseTaskService
private
+ def system_prompt
+ <<~PROMPT
+ #{prompt_from_file('summary')}
+
+ Reply in #{account.locale_english_name}.
+ PROMPT
+ end
+
def event_name
'summarize'
end
diff --git a/lib/integrations/openai/openai_prompts/summary.liquid b/lib/integrations/openai/openai_prompts/summary.liquid
index 4ec5ffd5b..1ac05419a 100644
--- a/lib/integrations/openai/openai_prompts/summary.liquid
+++ b/lib/integrations/openai/openai_prompts/summary.liquid
@@ -17,7 +17,7 @@ Make sure you strongly adhere to the following rules when generating the summary
13. Do not insert your own opinions about the conversation.
-Reply in the user's language, as a markdown of the following format.
+Use markdown with the following format. Translate all section headings to match the reply language:
**Customer Intent**
diff --git a/spec/lib/captain/summary_service_spec.rb b/spec/lib/captain/summary_service_spec.rb
index 6da3f122b..c5ec50687 100644
--- a/spec/lib/captain/summary_service_spec.rb
+++ b/spec/lib/captain/summary_service_spec.rb
@@ -35,7 +35,8 @@ RSpec.describe Captain::SummaryService do
expect(service).to receive(:make_api_call) do |args|
expect(args[:messages].length).to eq(2)
expect(args[:messages][0][:role]).to eq('system')
- expect(args[:messages][0][:content]).to eq('Summarize this')
+ expect(args[:messages][0][:content]).to include('Summarize this')
+ expect(args[:messages][0][:content]).to include("Reply in #{account.locale_english_name}")
expect(args[:messages][1][:role]).to eq('user')
expect(args[:messages][1][:content]).to be_a(String)
{ message: 'Summary' }