Skip to content

Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬

feat(captain): move GPT-4 series and legacy transcription to GPT-6 Luna and gpt-transcribe (#16266)

Aakash Bakhle12955f13ab52
diff --git a/.gitignore b/.gitignore
index 511cb9bfd01..645b9b3c66f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -105,3 +105,6 @@ CLAUDE.local.md
local/
Procfile.worktree
.nodeterm/project.json
+
+# Cache that `rake ruby_llm:refresh_models` writes next to the model registry
+config/llm_models.json.published.json
diff --git a/app/jobs/migration/replace_retired_captain_models_job.rb b/app/jobs/migration/replace_retired_captain_models_job.rb
new file mode 100644
index 00000000000..a569379dd6e
--- /dev/null
+++ b/app/jobs/migration/replace_retired_captain_models_job.rb
@@ -0,0 +1,41 @@
+# OpenAI shuts down the GPT-4 series on January 14, 2027 (gpt-4.1-nano on October 23, 2026)
+# and its older transcription models on February 26, 2027.
+class Migration::ReplaceRetiredCaptainModelsJob < ApplicationJob
+ queue_as :async_database_migration
+
+ TEXT_MODEL = Llm::Config::DEFAULT_MODEL
+ TRANSCRIPTION_MODEL = 'gpt-transcribe'.freeze
+ RETIRED_MODELS = {
+ 'gpt-4.1' => TEXT_MODEL,
+ 'gpt-4.1-mini' => TEXT_MODEL,
+ 'gpt-4.1-nano' => TEXT_MODEL,
+ 'gpt-4o-mini-transcribe' => TRANSCRIPTION_MODEL,
+ 'whisper-1' => TRANSCRIPTION_MODEL
+ }.freeze
+
+ def perform
+ replace_installation_model
+ replace_account_models
+ end
+
+ private
+
+ def replace_installation_model
+ # A custom endpoint may serve its own deployment under a GPT-4 name, so leave that to the operator.
+ return unless Llm::FeatureRouter.standard_openai_endpoint?
+
+ config = InstallationConfig.find_by(name: 'CAPTAIN_OPEN_AI_MODEL')
+ config.update!(value: TEXT_MODEL) if config&.value.to_s.start_with?('gpt-4')
+ end
+
+ def replace_account_models
+ Account.find_each do |account|
+ models = account.captain_models
+ next unless models&.values&.any? { |model| RETIRED_MODELS.key?(model) }
+
+ account.update!(captain_models: models.transform_values { |model| RETIRED_MODELS.fetch(model, model) })
+ rescue ActiveRecord::RecordInvalid => e
+ Rails.logger.error("[retired-captain-models] account_id=#{account.id} #{e.record.errors.full_messages.to_sentence}")
+ end
+ end
+end
diff --git a/app/models/concerns/captain_featurable.rb b/app/models/concerns/captain_featurable.rb
index 16566eb259c..02e66baeff9 100644
--- a/app/models/concerns/captain_featurable.rb
+++ b/app/models/concerns/captain_featurable.rb
@@ -5,7 +5,8 @@ module CaptainFeaturable
included do
before_validation :normalize_captain_models
- validate :validate_captain_models
+ # A model removed from config/llm.yml stays saved until the account is remapped, so only check changed choices.
+ validate :validate_captain_models, if: :captain_models_changed?
# Dynamically define accessor methods for each captain feature
Llm::Models.feature_keys.each do |feature_key|
diff --git a/config/installation_config.yml b/config/installation_config.yml
index 75e3f61172f..384d5b47733 100644
--- a/config/installation_config.yml
+++ b/config/installation_config.yml
@@ -205,7 +205,7 @@
type: secret
- name: CAPTAIN_OPEN_AI_MODEL
display_title: 'OpenAI Model'
- description: 'The OpenAI model configured for use in Captain AI. Default: gpt-4.1-mini'
+ description: 'The OpenAI model configured for use in Captain AI. Default: gpt-6-luna'
locked: false
- name: CAPTAIN_OPEN_AI_ENDPOINT
display_title: 'OpenAI API Endpoint (optional)'
diff --git a/config/llm.yml b/config/llm.yml
index 805b686572b..2246e8c84b9 100644
--- a/config/llm.yml
+++ b/config/llm.yml
@@ -7,18 +7,6 @@ providers:
display_name: 'Gemini'
models:
- gpt-4.1:
- provider: openai
- display_name: 'GPT-4.1'
- credit_multiplier: 3
- gpt-4.1-mini:
- provider: openai
- display_name: 'GPT-4.1 Mini'
- credit_multiplier: 1
- gpt-4.1-nano:
- provider: openai
- display_name: 'GPT-4.1 Nano'
- credit_multiplier: 1
gpt-5.1:
provider: openai
display_name: 'GPT-5.1'
@@ -39,6 +27,9 @@ models:
provider: openai
display_name: 'GPT-6 Luna'
credit_multiplier: 1
+ reasoning_effort: none
+ # models.dev lists temperature as unsupported, but Luna accepts it at reasoning effort none.
+ temperature: true
gpt-6.1-sol:
provider: openai
display_name: 'GPT-6.1 Sol'
@@ -63,13 +54,9 @@ models:
display_name: 'Gemini 3 Pro'
coming_soon: true
credit_multiplier: 3
- whisper-1:
- provider: openai
- display_name: 'Whisper'
- credit_multiplier: 1
- gpt-4o-mini-transcribe:
+ gpt-transcribe:
provider: openai
- display_name: 'GPT-4o Mini Transcribe'
+ display_name: 'GPT Transcribe'
credit_multiplier: 1
gpt-4o-mini-tts-2025-12-15:
provider: openai
@@ -84,35 +71,31 @@ features:
conversation_completion:
models:
[
- gpt-4.1-mini,
+ gpt-6-luna,
gpt-5-mini,
- gpt-4.1,
gpt-5.1,
gpt-5.2,
]
- default: gpt-4.1
+ default: gpt-6-luna
internal: true
editor:
models:
[
- gpt-4.1-mini,
- gpt-4.1-nano,
+ gpt-6-luna,
gpt-5-mini,
- gpt-4.1,
gpt-5.1,
gpt-5.2,
claude-haiku-4.5,
gemini-3-flash,
gemini-3-pro,
]
- default: gpt-4.1-mini
+ default: gpt-6-luna
assistant:
reasoning_effort: none
models:
[
- gpt-4.1-mini,
+ gpt-6-luna,
gpt-5-mini,
- gpt-4.1,
gpt-5.1,
gpt-5.2,
claude-haiku-4.5,
@@ -120,14 +103,13 @@ features:
gemini-3-flash,
gemini-3-pro,
]
- default: gpt-4.1
+ default: gpt-6-luna
copilot:
reasoning_effort: none
models:
[
- gpt-4.1-mini,
+ gpt-6-luna,
gpt-5-mini,
- gpt-4.1,
gpt-5.1,
gpt-5.2,
claude-haiku-4.5,
@@ -135,13 +117,13 @@ features:
gemini-3-flash,
gemini-3-pro,
]
- default: gpt-4.1
+ default: gpt-5.2
document_faq_generation:
+ reasoning_effort: medium
models:
[
- gpt-4.1-mini,
+ gpt-6-luna,
gpt-5-mini,
- gpt-4.1,
gpt-5.1,
gpt-5.2,
claude-haiku-4.5,
@@ -149,13 +131,12 @@ features:
gemini-3-flash,
gemini-3-pro,
]
- default: gpt-4.1-mini
+ default: gpt-6-luna
conversation_faq_generation:
models:
[
- gpt-4.1-mini,
+ gpt-6-luna,
gpt-5-mini,
- gpt-4.1,
gpt-5.1,
gpt-5.2,
claude-haiku-4.5,
@@ -167,9 +148,8 @@ features:
conversation_faq_matching:
models:
[
- gpt-4.1-mini,
+ gpt-6-luna,
gpt-5-mini,
- gpt-4.1,
gpt-5.1,
gpt-5.2,
claude-haiku-4.5,
@@ -177,16 +157,15 @@ features:
gemini-3-flash,
gemini-3-pro,
]
- default: gpt-4.1-mini
+ default: gpt-6-luna
pdf_faq_generation:
- models: [gpt-4.1-mini, gpt-5-mini, gpt-4.1, gpt-5.1, gpt-5.2]
- default: gpt-4.1-mini
+ models: [gpt-6-luna, gpt-5-mini, gpt-5.1, gpt-5.2]
+ default: gpt-6-luna
help_center_article_generation:
models:
[
- gpt-4.1-mini,
+ gpt-6-luna,
gpt-5-mini,
- gpt-4.1,
gpt-5.1,
gpt-5.2,
claude-haiku-4.5,
@@ -197,20 +176,20 @@ features:
default: gpt-5.2
onboarding_content_generation:
models:
- [gpt-4.1, gpt-4.1-mini, gpt-5-mini, gpt-5.1, gpt-5.2]
- default: gpt-4.1
+ [gpt-6-luna, gpt-5-mini, gpt-5.1, gpt-5.2]
+ default: gpt-6-luna
help_center_query_translation:
- models: [gpt-4.1-nano, gpt-4.1-mini, gpt-5-mini]
- default: gpt-4.1-nano
+ models: [gpt-6-luna, gpt-5-mini]
+ default: gpt-6-luna
message_translation:
- models: [gpt-6-luna, gpt-6.1-sol, gpt-5.2, gpt-5-mini, gpt-4.1-mini]
+ models: [gpt-6-luna, gpt-6.1-sol, gpt-5.2, gpt-5-mini]
default: gpt-6-luna
language_detection:
models: [gpt-5-mini, gpt-5-nano]
default: gpt-5-mini
audio_transcription:
- models: [gpt-4o-mini-transcribe, whisper-1]
- default: gpt-4o-mini-transcribe
+ models: [gpt-transcribe]
+ default: gpt-transcribe
call_announcement:
models: [gpt-4o-mini-tts-2025-12-15]
default: gpt-4o-mini-tts-2025-12-15
diff --git a/db/migrate/20261015063804_replace_retired_captain_models.rb b/db/migrate/20261015063804_replace_retired_captain_models.rb
new file mode 100644
index 00000000000..2abb0ea1933
--- /dev/null
+++ b/db/migrate/20261015063804_replace_retired_captain_models.rb
@@ -0,0 +1,8 @@
+class ReplaceRetiredCaptainModels < ActiveRecord::Migration[7.2]
+ # Runs inline because a queued job can reach Sidekiq workers still on the previous release, which don't have the job class yet.
+ def up
+ Migration::ReplaceRetiredCaptainModelsJob.perform_now
+ end
+
+ def down; end
+end
diff --git a/enterprise/app/models/enterprise/concerns/article.rb b/enterprise/app/models/enterprise/concerns/article.rb
index 6be262fef7d..8164aee3f04 100644
--- a/enterprise/app/models/enterprise/concerns/article.rb
+++ b/enterprise/app/models/enterprise/concerns/article.rb
@@ -68,7 +68,7 @@ module Enterprise::Concerns::Article
{ role: 'user', content: "title: #{title} \n description: #{description} \n content: #{content}" }
]
headers = { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{openai_api_key}" }
- body = { model: 'gpt-4o', messages: messages, response_format: { type: 'json_object' } }.to_json
+ body = { model: 'gpt-6-luna', reasoning_effort: 'none', messages: messages, response_format: { type: 'json_object' } }.to_json
Rails.logger.info "Requesting Chat GPT with body: #{body}"
response = HTTParty.post(openai_api_url, headers: headers, body: body)
Rails.logger.info "Chat GPT response: #{response.body}"
diff --git a/enterprise/app/services/captain/copilot/chat_service.rb b/enterprise/app/services/captain/copilot/chat_service.rb
index 4de66483a4b..8b85164fc30 100644
--- a/enterprise/app/services/captain/copilot/chat_service.rb
+++ b/enterprise/app/services/captain/copilot/chat_service.rb
@@ -5,7 +5,7 @@ class Captain::Copilot::ChatService < Llm::BaseAiService
attr_reader :assistant, :account, :user, :copilot_thread, :previous_history, :messages
def initialize(assistant, config)
- super(feature: 'copilot', account: assistant.account)
+ super(feature: 'copilot', account: assistant.account, fallback_model: Llm::Models.default_model_for('copilot'))
@assistant = assistant
@account = assistant.account
diff --git a/enterprise/app/services/captain/llm/help_center_curation_service.rb b/enterprise/app/services/captain/llm/help_center_curation_service.rb
index 37056dc2562..f6e6188490e 100644
--- a/enterprise/app/services/captain/llm/help_center_curation_service.rb
+++ b/enterprise/app/services/captain/llm/help_center_curation_service.rb
@@ -2,14 +2,11 @@ class Captain::Llm::HelpCenterCurationService < Captain::BaseTaskService
RESPONSE_SCHEMA = Captain::Llm::HelpCenterCurationSchema
MAX_LINKS_IN_PROMPT = 50
IGNORED_URL_PATTERN = /\.(?:pdf|jpe?g|png|gif|webp|svg|ico|bmp|tiff?|avif|heic)(?:\?|#|$)/i
- # This model consistently outperforms 5.2 in generating tighter and more
- # accurate curations.
- CURATION_MODEL = 'gpt-4.1'.freeze
pattr_initialize [:account!, :links!]
def perform
- response = make_api_call(feature: 'onboarding_content_generation', model: CURATION_MODEL, messages: messages, schema: RESPONSE_SCHEMA)
+ response = make_api_call(feature: 'onboarding_content_generation', messages: messages, schema: RESPONSE_SCHEMA)
return response if response[:error]
response.merge(message: extract_payload(response[:message]))
diff --git a/enterprise/app/services/captain/llm/paginated_faq_generator_service.rb b/enterprise/app/services/captain/llm/paginated_faq_generator_service.rb
index 3e3a12af325..8e6741419c6 100644
--- a/enterprise/app/services/captain/llm/paginated_faq_generator_service.rb
+++ b/enterprise/app/services/captain/llm/paginated_faq_generator_service.rb
@@ -111,7 +111,9 @@ class Captain::Llm::PaginatedFaqGeneratorService < Llm::LegacyBaseOpenAiService
message.merge(content: content)
end
# RubyLLM's Responses requests send store: false; this hand-built request must too, or OpenAI keeps the document.
- { model: @model, input: input, store: false, **format_options }
+ params = { model: @model, input: input, store: false, **format_options }
+ params[:reasoning] = request_options[:thinking] if request_options[:thinking]
+ params
end
def request_completion(params)
diff --git a/enterprise/app/services/captain/llm/system_prompts_service.rb b/enterprise/app/services/captain/llm/system_prompts_service.rb
index d93001f1563..8b3da4e1b10 100644
--- a/enterprise/app/services/captain/llm/system_prompts_service.rb
+++ b/enterprise/app/services/captain/llm/system_prompts_service.rb
@@ -155,7 +155,8 @@ class Captain::Llm::SystemPromptsService
Process the content starting from approximately page #{start_page} and continuing for about #{end_page - start_page + 1} pages worth of content.
IMPORTANT:#{' '}
- • If you encounter the end of the document before reaching the expected page count, set "has_content" to false
+ • Generate FAQs for all content that exists in this range, even if the document ends before the expected page count
+ • Set "has_content" to false when the document ends within this range, so no later range is requested
• DO NOT include page numbers in questions or answers
• DO NOT reference page numbers at all in the output
• Focus on the actual content, not pagination
@@ -170,7 +171,7 @@ class Captain::Llm::SystemPromptsService
• Extract ALL information that could generate FAQs from this section
• Target 5-10 FAQs per page equivalent of rich content
• Cover every topic, feature, specification, and detail
- • If there's no more content in the document, return empty FAQs with has_content: false
+ • If this range has no content at all because the document already ended, return empty FAQs with has_content: false
2. **Question Types to Generate**
• What is/are...? (definitions, components, features)
diff --git a/enterprise/app/services/captain/llm/widget_tagline_service.rb b/enterprise/app/services/captain/llm/widget_tagline_service.rb
index 155b1039648..97911ac5055 100644
--- a/enterprise/app/services/captain/llm/widget_tagline_service.rb
+++ b/enterprise/app/services/captain/llm/widget_tagline_service.rb
@@ -28,6 +28,7 @@ class Captain::Llm::WidgetTaglineService < Captain::BaseTaskService
<<~PROMPT
You write a short marketing tagline for a company's customer-support chat widget.
Use the provided company context to make the tagline specific and on-brand.
+ Keep it under 45 characters, and avoid generic phrasing that could fit any company.
PROMPT
end
diff --git a/enterprise/app/services/llm/legacy_base_open_ai_service.rb b/enterprise/app/services/llm/legacy_base_open_ai_service.rb
index db441a77914..fbaac8f7c2c 100644
--- a/enterprise/app/services/llm/legacy_base_open_ai_service.rb
+++ b/enterprise/app/services/llm/legacy_base_open_ai_service.rb
@@ -9,7 +9,7 @@
#
# For all other LLM operations, use Llm::BaseAiService with RubyLLM instead.
class Llm::LegacyBaseOpenAiService
- DEFAULT_MODEL = 'gpt-4.1-mini'
+ DEFAULT_MODEL = Llm::Config::DEFAULT_MODEL
attr_reader :client, :model
diff --git a/enterprise/lib/captain/prompts/assistant_overview_summary.liquid b/enterprise/lib/captain/prompts/assistant_overview_summary.liquid
index b9a66291738..54408abd8a7 100644
--- a/enterprise/lib/captain/prompts/assistant_overview_summary.liquid
+++ b/enterprise/lib/captain/prompts/assistant_overview_summary.liquid
@@ -7,7 +7,7 @@ Requirements for every point:
- Cite the rounded value and comparison that make it notable. Use exact reporting-period or bucket dates when time is relevant.
- Explain why the signal matters operationally, but never invent a cause, customer intent, or recommendation that the data does not support.
- Cover one distinct theme. Do not repeat the same metric or rephrase another point.
-- Aim for 180–220 characters per point, including spaces, and never exceed 220 characters. Keep points similar in length; do not add filler to reach the target.
+- Keep every point at 220 characters or fewer, including spaces. If a point would run longer, drop the least important detail instead of exceeding the limit. Keep points similar in length; do not add filler.
- Write each point as a single paragraph without line breaks.
Prioritize these signals:
diff --git a/enterprise/lib/captain/prompts/conversation_completion.liquid b/enterprise/lib/captain/prompts/conversation_completion.liquid
index e039f60b0ab..fc2dbdd6f10 100644
--- a/enterprise/lib/captain/prompts/conversation_completion.liquid
+++ b/enterprise/lib/captain/prompts/conversation_completion.liquid
@@ -40,3 +40,5 @@ Analyze the conversation and respond with ONLY a JSON object (no other text):
{"complete": true, "reason": "brief explanation"}
or
{"complete": false, "reason": "brief explanation"}
+
+Write the reason in English.
diff --git a/lib/captain/base_task_service.rb b/lib/captain/base_task_service.rb
index 56e41867cbb..9116f80394f 100644
--- a/lib/captain/base_task_service.rb
+++ b/lib/captain/base_task_service.rb
@@ -3,7 +3,7 @@ class Captain::BaseTaskService
include Captain::ToolInstrumentation
include Llm::ExceptionTrackable
- # gpt-4o-mini supports 128,000 tokens
+ # Sized for a 128,000-token context window
# 1 token is approx 4 characters
# sticking with 120000 to be safe
# 120000 * 4 = 480,000 characters (rounding off downwards to 400,000 to be safe)
@@ -86,6 +86,7 @@ class Captain::BaseTaskService
tools = request.fetch(:tools, [])
options = Captain::ResponsesConfig.options(model: model, temperature: nil, feature: request[:feature])
chat = context.chat(model: model, **options.slice(:protocol))
+ chat.with_thinking(**options[:thinking]) if options[:thinking]
system_msg = messages.find { |m| m[:role] == 'system' }
chat.with_instructions(system_msg[:content]) if system_msg
chat.with_schema(request[:schema]) if request[:schema]
diff --git a/lib/captain/follow_up_service.rb b/lib/captain/follow_up_service.rb
index 9304aa4524b..26f0138157f 100644
--- a/lib/captain/follow_up_service.rb
+++ b/lib/captain/follow_up_service.rb
@@ -47,6 +47,8 @@ class Captain::FollowUpService < Captain::BaseTaskService
You just performed a #{action_context} action for a customer support agent.
Your job now is to help them refine the result based on their feedback.
Be concise and focused on their specific request.
+ Change only what the agent asks for. Keep all other content, facts, and any signature exactly as in the previous result.
+ Do not shorten, summarize, or drop sentences unless the agent asks.
Output only the reply, no preamble, tags, or explanation.
PROMPT
end
diff --git a/lib/integrations/llm_base_service.rb b/lib/integrations/llm_base_service.rb
index 3f1d13c2f14..c9786b666e7 100644
--- a/lib/integrations/llm_base_service.rb
+++ b/lib/integrations/llm_base_service.rb
@@ -2,7 +2,7 @@ class Integrations::LlmBaseService
include Integrations::LlmInstrumentation
include Llm::ExceptionTrackable
- # gpt-4o-mini supports 128,000 tokens
+ # Sized for a 128,000-token context window
# 1 token is approx 4 characters
# sticking with 120000 to be safe
# 120000 * 4 = 480,000 characters (rounding off downwards to 400,000 to be safe)
diff --git a/lib/integrations/llm_instrumentation_completion_helpers.rb b/lib/integrations/llm_instrumentation_completion_helpers.rb
index f8c1e36b842..5d5ec9fd71c 100644
--- a/lib/integrations/llm_instrumentation_completion_helpers.rb
+++ b/lib/integrations/llm_instrumentation_completion_helpers.rb
@@ -14,7 +14,7 @@ module Integrations::LlmInstrumentationCompletionHelpers
def set_audio_transcription_span_attributes(span, params)
span.set_attribute(ATTR_GEN_AI_PROVIDER, 'openai')
- span.set_attribute(ATTR_GEN_AI_REQUEST_MODEL, params[:model] || 'whisper-1')
+ span.set_attribute(ATTR_GEN_AI_REQUEST_MODEL, params[:model])
span.set_attribute('audio.duration_seconds', params[:duration]) if params[:duration]
span.set_attribute(ATTR_LANGFUSE_OBSERVATION_INPUT, params[:file_path].to_s) if params[:file_path]
end
diff --git a/lib/integrations/openai/openai_prompts/tone_rewrite.liquid b/lib/integrations/openai/openai_prompts/tone_rewrite.liquid
index 6b62617f0ef..526a8e30439 100644
--- a/lib/integrations/openai/openai_prompts/tone_rewrite.liquid
+++ b/lib/integrations/openai/openai_prompts/tone_rewrite.liquid
@@ -21,6 +21,7 @@ Warm, approachable, and personable. Use conversational language, positive words,
Your task is to rewrite the message according to the specified tone instructions.
Important guidelines:
+- Apply the tone clearly, so the rewritten message reads noticeably different in tone from the original
- Preserve the core meaning and all important information from the original message
- Keep the rewritten message concise and appropriate for customer support
- Maintain helpfulness and respect regardless of tone
diff --git a/lib/llm/config.rb b/lib/llm/config.rb
index 26158fce953..afd67a02660 100644
--- a/lib/llm/config.rb
+++ b/lib/llm/config.rb
@@ -1,7 +1,7 @@
require 'ruby_llm'
module Llm::Config
- DEFAULT_MODEL = 'gpt-4.1-mini'.freeze
+ DEFAULT_MODEL = 'gpt-6-luna'.freeze
class << self
def initialized?
diff --git a/lib/llm/feature_router.rb b/lib/llm/feature_router.rb
index 284c1f6c214..6fc571a2b1c 100644
--- a/lib/llm/feature_router.rb
+++ b/lib/llm/feature_router.rb
@@ -21,7 +21,7 @@ module Llm::FeatureRouter
def reasoning_effort(feature:, model:)
return unless Llm::Models.provider_for(model) == 'openai' && standard_openai_endpoint?
- effort = Llm::Models.features.dig(feature.to_s, 'reasoning_effort')
+ effort = Llm::Models.features.dig(feature.to_s, 'reasoning_effort') || Llm::Models.model_config(model)&.dig('reasoning_effort')
effort.to_sym if RubyLLM.models.find(model).reasoning_option_values(:effort).include?(effort)
end
diff --git a/lib/llm/models.rb b/lib/llm/models.rb
index 1c8b812b9e7..7d83837f299 100644
--- a/lib/llm/models.rb
+++ b/lib/llm/models.rb
@@ -37,8 +37,11 @@ module Llm::Models
model_config(model_name)&.dig('provider')
end
+ # config/llm.yml can override the registry, which `rake ruby_llm:refresh_models` regenerates.
def temperature_for(model_name, temperature)
- temperature unless RubyLLM.models.find(model_name).metadata[:temperature] == false
+ supported = model_config(model_name)&.dig('temperature')
+ supported = RubyLLM.models.find(model_name).metadata[:temperature] if supported.nil?
+ temperature unless supported == false
end
def feature_config(feature_key)
diff --git a/lib/llm_constants.rb b/lib/llm_constants.rb
index 241f3ccba66..328f1528c03 100644
--- a/lib/llm_constants.rb
+++ b/lib/llm_constants.rb
@@ -1,9 +1,8 @@
# frozen_string_literal: true
module LlmConstants
- DEFAULT_MODEL = 'gpt-4.1'
+ DEFAULT_MODEL = 'gpt-6-luna'
DEFAULT_EMBEDDING_MODEL = 'text-embedding-3-small'
- PDF_PROCESSING_MODEL = 'gpt-4.1-mini'
OPENAI_API_ENDPOINT = 'https://api.openai.com'
diff --git a/lib/tasks/ruby_llm.rake b/lib/tasks/llm_models.rake
similarity index 76%
rename from lib/tasks/ruby_llm.rake
rename to lib/tasks/llm_models.rake
index e12accebeec..8cea7c3bce3 100644
--- a/lib/tasks/ruby_llm.rake
+++ b/lib/tasks/llm_models.rake
@@ -9,6 +9,9 @@ namespace :ruby_llm do
desc 'Refresh RubyLLM model registry from models.dev'
task refresh_models: :environment do
registry_path = Rails.root.join('config/llm_models.json').to_s
+ # RubyLLM 2.0's Rails integration points the registry at a ruby_llm_models table, which Chatwoot does not use.
+ RubyLLM.config.model_registry_store = nil
+ RubyLLM.config.model_registry_file = registry_path
puts 'Refreshing RubyLLM model registry...'
RubyLLM.models.refresh
RubyLLM.models.save_to_json(registry_path)
diff --git a/spec/controllers/api/v1/accounts/captain/preferences_controller_spec.rb b/spec/controllers/api/v1/accounts/captain/preferences_controller_spec.rb
index 8b61a8b5e86..010f3a31938 100644
--- a/spec/controllers/api/v1/accounts/captain/preferences_controller_spec.rb
+++ b/spec/controllers/api/v1/accounts/captain/preferences_controller_spec.rb
@@ -48,7 +48,7 @@ RSpec.describe 'Api::V1::Accounts::Captain::Preferences', type: :request do
end
it 'returns effective model provider and source for each feature' do
- account.update!(captain_models: { 'editor' => 'gpt-4.1' })
+ account.update!(captain_models: { 'editor' => 'gpt-5.1' })
get "/api/v1/accounts/#{account.id}/captain/preferences",
headers: admin.create_new_auth_token,
@@ -56,8 +56,8 @@ RSpec.describe 'Api::V1::Accounts::Captain::Preferences', type: :request do
expect(response).to have_http_status(:success)
expect(json_response.dig(:features, :editor)).to include(
- model: 'gpt-4.1',
- selected: 'gpt-4.1',
+ model: 'gpt-5.1',
+ selected: 'gpt-5.1',
provider: 'openai',
source: 'account_override'
)
@@ -119,7 +119,7 @@ RSpec.describe 'Api::V1::Accounts::Captain::Preferences', type: :request do
context 'when it is an unauthenticated user' do
it 'returns unauthorized' do
put "/api/v1/accounts/#{account.id}/captain/preferences",
- params: { captain_models: { editor: 'gpt-4.1-mini' } },
+ params: { captain_models: { editor: 'gpt-5-mini' } },
as: :json
expect(response).to have_http_status(:unauthorized)
@@ -130,7 +130,7 @@ RSpec.describe 'Api::V1::Accounts::Captain::Preferences', type: :request do
it 'returns forbidden' do
put "/api/v1/accounts/#{account.id}/captain/preferences",
headers: agent.create_new_auth_token,
- params: { captain_models: { editor: 'gpt-4.1-mini' } },
+ params: { captain_models: { editor: 'gpt-5-mini' } },
as: :json
expect(response).to have_http_status(:unauthorized)
@@ -141,14 +141,14 @@ RSpec.describe 'Api::V1::Accounts::Captain::Preferences', type: :request do
it 'updates captain_models' do
put "/api/v1/accounts/#{account.id}/captain/preferences",
headers: admin.create_new_auth_token,
- params: { captain_models: { editor: 'gpt-4.1-mini' } },
+ params: { captain_models: { editor: 'gpt-5-mini' } },
as: :json
expect(response).to have_http_status(:success)
expect(json_response).to have_key(:providers)
expect(json_response).to have_key(:models)
expect(json_response).to have_key(:features)
- expect(account.reload.captain_models['editor']).to eq('gpt-4.1-mini')
+ expect(account.reload.captain_models['editor']).to eq('gpt-5-mini')
end
it 'does not persist unknown or internal captain model feature keys' do
@@ -156,15 +156,15 @@ RSpec.describe 'Api::V1::Accounts::Captain::Preferences', type: :request do
headers: admin.create_new_auth_token,
params: {
captain_models: {
- editor: 'gpt-4.1-mini',
- unknown_feature: 'gpt-4.1',
- conversation_completion: 'gpt-4.1'
+ editor: 'gpt-5-mini',
+ unknown_feature: 'gpt-5.1',
+ conversation_completion: 'gpt-5.1'
}
},
as: :json
expect(response).to have_http_status(:success)
- expect(account.reload.captain_models).to eq('editor' => 'gpt-4.1-mini')
+ expect(account.reload.captain_models).to eq('editor' => 'gpt-5-mini')
expect(json_response[:features]).not_to have_key(:conversation_completion)
end
@@ -180,7 +180,7 @@ RSpec.describe 'Api::V1::Accounts::Captain::Preferences', type: :request do
end
it 'removes blank captain model overrides' do
- account.update!(captain_models: { 'editor' => 'gpt-4.1' })
+ account.update!(captain_models: { 'editor' => 'gpt-5.1' })
put "/api/v1/accounts/#{account.id}/captain/preferences",
headers: admin.create_new_auth_token,
@@ -209,12 +209,12 @@ RSpec.describe 'Api::V1::Accounts::Captain::Preferences', type: :request do
it 'updates captain_models for conversation FAQ generation' do
put "/api/v1/accounts/#{account.id}/captain/preferences",
headers: admin.create_new_auth_token,
- params: { captain_models: { conversation_faq_generation: 'gpt-4.1-mini' } },
+ params: { captain_models: { conversation_faq_generation: 'gpt-5-mini' } },
as: :json
expect(response).to have_http_status(:success)
- expect(json_response.dig(:features, :conversation_faq_generation, :selected)).to eq('gpt-4.1-mini')
- expect(account.reload.captain_models['conversation_faq_generation']).to eq('gpt-4.1-mini')
+ expect(json_response.dig(:features, :conversation_faq_generation, :selected)).to eq('gpt-5-mini')
+ expect(account.reload.captain_models['conversation_faq_generation']).to eq('gpt-5-mini')
end
it 'updates captain_models for PDF FAQ generation' do
@@ -242,11 +242,11 @@ RSpec.describe 'Api::V1::Accounts::Captain::Preferences', type: :request do
end
it 'merges with existing captain_models' do
- account.update!(captain_models: { 'editor' => 'gpt-4.1-mini', 'assistant' => 'gpt-5.1' })
+ account.update!(captain_models: { 'editor' => 'gpt-5-mini', 'assistant' => 'gpt-5.1' })
put "/api/v1/accounts/#{account.id}/captain/preferences",
headers: admin.create_new_auth_token,
- params: { captain_models: { editor: 'gpt-4.1' } },
+ params: { captain_models: { editor: 'gpt-5.1' } },
as: :json
expect(response).to have_http_status(:success)
@@ -254,7 +254,7 @@ RSpec.describe 'Api::V1::Accounts::Captain::Preferences', type: :request do
expect(json_response).to have_key(:models)
expect(json_response).to have_key(:features)
models = account.reload.captain_models
- expect(models['editor']).to eq('gpt-4.1')
+ expect(models['editor']).to eq('gpt-5.1')
expect(models['assistant']).to eq('gpt-5.1') # Preserved
end
@@ -279,7 +279,7 @@ RSpec.describe 'Api::V1::Accounts::Captain::Preferences', type: :request do
put "/api/v1/accounts/#{account.id}/captain/preferences",
headers: admin.create_new_auth_token,
params: {
- captain_models: { editor: 'gpt-4.1-mini' },
+ captain_models: { editor: 'gpt-5-mini' },
captain_features: { editor: true }
},
as: :json
@@ -289,7 +289,7 @@ RSpec.describe 'Api::V1::Accounts::Captain::Preferences', type: :request do
expect(json_response).to have_key(:models)
expect(json_response).to have_key(:features)
account.reload
- expect(account.captain_models['editor']).to eq('gpt-4.1-mini')
+ expect(account.captain_models['editor']).to eq('gpt-5-mini')
expect(account.captain_features['editor']).to be true
end
end
diff --git a/spec/controllers/super_admin/accounts_controller_spec.rb b/spec/controllers/super_admin/accounts_controller_spec.rb
index 9a72d15a9f9..35ec59f3a9c 100644
--- a/spec/controllers/super_admin/accounts_controller_spec.rb
+++ b/spec/controllers/super_admin/accounts_controller_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe 'Super Admin accounts API', type: :request do
describe 'GET /super_admin/accounts/{account_id}' do
context 'when it is an authenticated user' do
it 'shows effective Captain model routing', if: ChatwootApp.enterprise? do
- account.update!(captain_models: { 'editor' => 'gpt-4.1', 'conversation_completion' => 'gpt-5.2' })
+ account.update!(captain_models: { 'editor' => 'gpt-5.1', 'conversation_completion' => 'gpt-5.2' })
sign_in(super_admin, scope: :super_admin)
get "/super_admin/accounts/#{account.id}"
@@ -43,7 +43,7 @@ RSpec.describe 'Super Admin accounts API', type: :request do
expect(summaries).not_to include('All features', 'Captain models')
expect(routing_panel.text.squish).to include('Customer features', 'Internal features')
expect(completion_card.text.squish).to include('Inactive conversation completion evaluator', 'GPT-5.2', 'Account override')
- expect(response.body).to include('Editor', 'OpenAI', 'openai', 'gpt-4.1', 'Help center query translation', 'Default')
+ expect(response.body).to include('Editor', 'OpenAI', 'openai', 'gpt-5.1', 'Help center query translation', 'Default')
end
it 'shows the installation model for internal routing on self-hosted Enterprise', if: ChatwootApp.enterprise? do
@@ -71,7 +71,7 @@ RSpec.describe 'Super Admin accounts API', type: :request do
it 'renders separate Captain model selectors for customer and internal AI features', if: ChatwootApp.enterprise? do
allow(ChatwootApp).to receive(:self_hosted_paid?).and_return(true)
InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_MODEL').update!(value: 'gpt-5.1')
- account.update!(captain_models: { 'editor' => 'gpt-4.1' })
+ account.update!(captain_models: { 'editor' => 'gpt-5.1' })
sign_in(super_admin, scope: :super_admin)
get "/super_admin/accounts/#{account.id}/edit"
@@ -126,7 +126,7 @@ RSpec.describe 'Super Admin accounts API', type: :request do
context 'when it is an authenticated user' do
it 'updates Captain model overrides without changing unrelated settings' do
account.update!(
- captain_models: { 'editor' => 'gpt-4.1' },
+ captain_models: { 'editor' => 'gpt-5.1' },
keep_pending_on_bot_failure: true
)
sign_in(super_admin, scope: :super_admin)
diff --git a/spec/enterprise/lib/captain/conversation_completion_service_spec.rb b/spec/enterprise/lib/captain/conversation_completion_service_spec.rb
index d7c62ad782e..9e9d76e0398 100644
--- a/spec/enterprise/lib/captain/conversation_completion_service_spec.rb
+++ b/spec/enterprise/lib/captain/conversation_completion_service_spec.rb
@@ -13,6 +13,7 @@ RSpec.describe Captain::ConversationCompletionService do
allow(Llm::Config).to receive(:with_api_key).and_yield(mock_context)
allow(mock_chat).to receive(:with_instructions)
allow(mock_chat).to receive(:with_schema).and_return(mock_chat)
+ allow(mock_chat).to receive(:with_thinking).and_return(mock_chat)
allow(mock_chat).to receive(:with_model).and_return(mock_chat)
allow(account).to receive(:feature_enabled?).and_call_original
allow(account).to receive(:feature_enabled?).with('captain_tasks').and_return(true)
@@ -23,7 +24,7 @@ RSpec.describe Captain::ConversationCompletionService do
let(:context) { RubyLLM.context { |config| config.openai_api_key = 'test-key' } }
let(:messages) { [{ role: 'system', content: 'Evaluate the conversation.' }, { role: 'user', content: 'Customer: Thanks!' }] }
- %w[gpt-4.1 gpt-5.2].each do |model|
+ %w[gpt-5-mini gpt-5.2].each do |model|
it "renders a Responses schema request for #{model} without specifying effort" do
chat = service.send(:build_chat, context, model: model, messages: messages, schema: described_class::RESPONSE_SCHEMA)
chat.add_message(role: :user, content: messages.last[:content])
@@ -40,12 +41,12 @@ RSpec.describe Captain::ConversationCompletionService do
it 'retains Chat Completions for a custom OpenAI endpoint' do
InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_ENDPOINT').update!(value: 'https://custom.example')
context.config.openai_protocol = :chat_completions
- chat = service.send(:build_chat, context, model: 'gpt-4.1', messages: messages, schema: described_class::RESPONSE_SCHEMA)
+ chat = service.send(:build_chat, context, model: 'gpt-6-luna', messages: messages, schema: described_class::RESPONSE_SCHEMA)
chat.add_message(role: :user, content: messages.last[:content])
expect(chat.render).to include(messages: an_instance_of(Array), response_format: include(type: 'json_schema'))
expect(chat.render).not_to have_key(:input)
- expect(service.send(:build_instrumentation_params, 'gpt-4.1', messages)[:metadata]).to include(api_protocol: 'chat_completions')
+ expect(service.send(:build_instrumentation_params, 'gpt-6-luna', messages)[:metadata]).to include(api_protocol: 'chat_completions')
end
end
@@ -60,11 +61,11 @@ RSpec.describe Captain::ConversationCompletionService do
allow(mock_chat).to receive(:ask).and_return(mock_response)
end
- it 'uses the internal GPT-4.1 route on Chatwoot Cloud' do
+ it 'uses the internal GPT-6 Luna route on Chatwoot Cloud' do
allow(ChatwootApp).to receive(:self_hosted_paid?).and_return(false)
InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_MODEL').update!(value: 'gpt-5.1')
account.enable_features!('captain_integration')
- allow(mock_context).to receive(:chat).with(model: 'gpt-4.1').and_return(mock_chat)
+ allow(mock_context).to receive(:chat).with(model: 'gpt-6-luna').and_return(mock_chat)
expect(service.perform).to include(complete: true)
end
@@ -86,10 +87,10 @@ RSpec.describe Captain::ConversationCompletionService do
expect(service.perform).to include(complete: true)
end
- it 'falls back to the internal GPT-4.1 route when the self-hosted installation model is blank' do
+ it 'falls back to the internal GPT-6 Luna route when the self-hosted installation model is blank' do
allow(ChatwootApp).to receive(:self_hosted_paid?).and_return(true)
InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_MODEL').update!(value: '')
- allow(mock_context).to receive(:chat).with(model: 'gpt-4.1').and_return(mock_chat)
+ allow(mock_context).to receive(:chat).with(model: 'gpt-6-luna').and_return(mock_chat)
expect(service.perform).to include(complete: true)
end
diff --git a/spec/enterprise/lib/captain/responses_config_spec.rb b/spec/enterprise/lib/captain/responses_config_spec.rb
index 797c06705ba..05b3ed5733d 100644
--- a/spec/enterprise/lib/captain/responses_config_spec.rb
+++ b/spec/enterprise/lib/captain/responses_config_spec.rb
@@ -41,13 +41,13 @@ RSpec.describe Captain::ResponsesConfig do
it 'keeps custom endpoints on their existing protocol without forced reasoning' do
InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_ENDPOINT').update!(value: 'https://custom.example')
- expect(described_class.options(model: 'gpt-4.1', temperature: 0.7, feature: 'copilot')).to eq(temperature: 0.7)
+ expect(described_class.options(model: 'gpt-6-luna', temperature: 0.7, feature: 'copilot')).to eq(temperature: 0.7)
expect(described_class.options(model: 'gpt-5-mini', temperature: 0.7, feature: 'copilot')).to eq(temperature: nil)
end
it 'reports Chat Completions and omits effort when thinking is not configured' do
context.config.openai_protocol = :chat_completions
- chat = context.chat(model: 'gpt-4.1')
+ chat = context.chat(model: 'gpt-6-luna')
expect(described_class.metadata(chat)).to eq(api_protocol: :chat_completions)
end
diff --git a/spec/enterprise/models/concerns/agentable_spec.rb b/spec/enterprise/models/concerns/agentable_spec.rb
index c68531a4117..7858be8b778 100644
--- a/spec/enterprise/models/concerns/agentable_spec.rb
+++ b/spec/enterprise/models/concerns/agentable_spec.rb
@@ -179,20 +179,20 @@ RSpec.describe Concerns::Agentable do
end
it 'returns account override model when present' do
- create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-4.1-nano')
+ create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-5-mini')
account.update!(captain_models: { 'assistant' => 'gpt-5.2' })
expect(dummy_instance.send(:agent_model)).to eq('gpt-5.2')
end
it 'returns the installation model when account override is absent' do
- create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-4.1-nano')
+ create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-5-mini')
- expect(dummy_instance.send(:agent_model)).to eq('gpt-4.1-nano')
+ expect(dummy_instance.send(:agent_model)).to eq('gpt-5-mini')
end
it 'returns the Captain V2 default when Captain V2 is enabled' do
- create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-4.1-nano')
+ create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-5-mini')
account.enable_features!('captain_integration')
expect(dummy_instance.send(:agent_model)).to eq('gpt-5.2')
diff --git a/spec/enterprise/services/captain/copilot/chat_service_spec.rb b/spec/enterprise/services/captain/copilot/chat_service_spec.rb
index 9d69cb9710d..c75ea54dd95 100644
--- a/spec/enterprise/services/captain/copilot/chat_service_spec.rb
+++ b/spec/enterprise/services/captain/copilot/chat_service_spec.rb
@@ -64,11 +64,26 @@ RSpec.describe Captain::Copilot::ChatService do
expect(messages.second[:role]).to eq('system')
expect(messages.second[:content]).to include(account.id.to_s)
end
+
+ it 'uses the account model ahead of the Copilot default and installation model' do
+ InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_MODEL').update!(value: 'gpt-6-luna')
+ account.update!(captain_models: { 'copilot' => 'gpt-5-mini' })
+
+ expect(described_class.new(assistant, config).model).to eq('gpt-5-mini')
+ end
end
describe '#generate_response' do
let(:service) { described_class.new(assistant, config) }
+ it 'uses the Copilot default ahead of the installation model' do
+ InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_MODEL').update!(value: 'gpt-6-luna')
+
+ expect(RubyLLM).to receive(:chat).with(model: 'gpt-5.2', protocol: :responses).and_return(mock_chat)
+
+ service.generate_response('Hello')
+ end
+
it 'uses the copilot feature model' do
account.update!(captain_models: { 'copilot' => 'gpt-5.2' })
@@ -114,6 +129,12 @@ RSpec.describe Captain::Copilot::ChatService do
allow(ChatwootApp).to receive(:chatwoot_cloud?).and_return(false)
end
+ it 'uses the Copilot default ahead of the installation model' do
+ InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_MODEL').update!(value: 'gpt-6-luna')
+
+ expect(service.model).to eq('gpt-5.2')
+ end
+
it 'does not increment response usage' do
expect do
service.generate_response('Hello')
diff --git a/spec/enterprise/services/captain/llm/article_translation_service_spec.rb b/spec/enterprise/services/captain/llm/article_translation_service_spec.rb
index c31846f68b1..d081b820a77 100644
--- a/spec/enterprise/services/captain/llm/article_translation_service_spec.rb
+++ b/spec/enterprise/services/captain/llm/article_translation_service_spec.rb
@@ -30,12 +30,12 @@ RSpec.describe Captain::Llm::ArticleTranslationService do
end
it 'uses the installation model when no account override is configured' do
- create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-4.1-nano')
+ create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-5-mini')
expect(service).to receive(:make_api_call).with(
hash_including(
feature: 'help_center_article_generation',
- model: 'gpt-4.1-nano'
+ model: 'gpt-5-mini'
)
).and_return(message: 'Primeros pasos')
diff --git a/spec/enterprise/services/captain/llm/conversation_faq_service_spec.rb b/spec/enterprise/services/captain/llm/conversation_faq_service_spec.rb
index 83ada949f48..2e3b4968bf8 100644
--- a/spec/enterprise/services/captain/llm/conversation_faq_service_spec.rb
+++ b/spec/enterprise/services/captain/llm/conversation_faq_service_spec.rb
@@ -23,6 +23,7 @@ RSpec.describe Captain::Llm::ConversationFaqService do
allow(Captain::Llm::EmbeddingService).to receive(:new).and_return(embedding_service)
allow(RubyLLM).to receive(:chat).and_return(mock_chat)
allow(mock_chat).to receive(:with_temperature).and_return(mock_chat)
+ allow(mock_chat).to receive(:with_thinking).and_return(mock_chat)
allow(mock_chat).to receive(:with_provider_options).and_return(mock_chat)
allow(mock_chat).to receive(:add_message).with(role: :user, content: 'Respond with valid JSON.')
allow(mock_chat).to receive(:with_instructions).and_return(mock_chat)
@@ -44,7 +45,7 @@ RSpec.describe Captain::Llm::ConversationFaqService do
end
it 'uses the conversation FAQ default ahead of the legacy global installation model' do
- InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_MODEL').update!(value: 'gpt-4.1-mini')
+ InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_MODEL').update!(value: 'gpt-5-mini')
expect(RubyLLM).to receive(:chat).with(
model: Llm::Models.default_model_for('conversation_faq_generation'), protocol: :responses
@@ -54,10 +55,10 @@ RSpec.describe Captain::Llm::ConversationFaqService do
end
it 'keeps account conversation FAQ model overrides ahead of the feature default' do
- InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_MODEL').update!(value: 'gpt-4.1')
- conversation.account.update!(captain_models: { 'conversation_faq_generation' => 'gpt-4.1-mini' })
+ InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_MODEL').update!(value: 'gpt-5.1')
+ conversation.account.update!(captain_models: { 'conversation_faq_generation' => 'gpt-5-mini' })
- expect(RubyLLM).to receive(:chat).with(model: 'gpt-4.1-mini', protocol: :responses).and_return(mock_chat)
+ expect(RubyLLM).to receive(:chat).with(model: 'gpt-5-mini', protocol: :responses).and_return(mock_chat)
described_class.new(captain_assistant, conversation).generate_suggestions
end
diff --git a/spec/enterprise/services/captain/llm/faq_generator_service_spec.rb b/spec/enterprise/services/captain/llm/faq_generator_service_spec.rb
index 5e1d24d0e12..a93f57cfc3b 100644
--- a/spec/enterprise/services/captain/llm/faq_generator_service_spec.rb
+++ b/spec/enterprise/services/captain/llm/faq_generator_service_spec.rb
@@ -19,6 +19,7 @@ RSpec.describe Captain::Llm::FaqGeneratorService do
InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_API_KEY').update!(value: 'test-key')
allow(RubyLLM).to receive(:chat).and_return(mock_chat)
allow(mock_chat).to receive(:with_temperature).and_return(mock_chat)
+ allow(mock_chat).to receive(:with_thinking).and_return(mock_chat)
allow(mock_chat).to receive(:with_provider_options).and_return(mock_chat)
allow(mock_chat).to receive(:add_message).with(role: :user, content: 'Respond with valid JSON.')
allow(mock_chat).to receive(:with_instructions).and_return(mock_chat)
diff --git a/spec/enterprise/services/captain/onboarding/website_analyzer_service_spec.rb b/spec/enterprise/services/captain/onboarding/website_analyzer_service_spec.rb
index b37e26f54ff..f462b8bcbdd 100644
--- a/spec/enterprise/services/captain/onboarding/website_analyzer_service_spec.rb
+++ b/spec/enterprise/services/captain/onboarding/website_analyzer_service_spec.rb
@@ -21,6 +21,7 @@ RSpec.describe Captain::Onboarding::WebsiteAnalyzerService do
allow(Captain::Tools::SimplePageCrawlService).to receive(:new).and_return(mock_crawler)
allow(RubyLLM).to receive(:chat).and_return(mock_chat)
allow(mock_chat).to receive(:with_temperature).and_return(mock_chat)
+ allow(mock_chat).to receive(:with_thinking).and_return(mock_chat)
allow(mock_chat).to receive(:with_provider_options).and_return(mock_chat)
allow(mock_chat).to receive(:add_message).with(role: :user, content: 'Respond with valid JSON.')
allow(mock_chat).to receive(:with_max_output_tokens).and_return(mock_chat)
diff --git a/spec/enterprise/services/llm/base_ai_service_spec.rb b/spec/enterprise/services/llm/base_ai_service_spec.rb
index 4f8c1cfb871..cb3e717fc0b 100644
--- a/spec/enterprise/services/llm/base_ai_service_spec.rb
+++ b/spec/enterprise/services/llm/base_ai_service_spec.rb
@@ -12,26 +12,26 @@ RSpec.describe Llm::BaseAiService do
describe '#initialize' do
it 'uses the installation model when no feature is provided' do
- create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-4.1-nano')
+ create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-5-mini')
- expect(described_class.new.model).to eq('gpt-4.1-nano')
+ expect(described_class.new.model).to eq('gpt-5-mini')
end
it 'uses the account override when feature context is provided' do
- create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-4.1-nano')
+ create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-5-mini')
account.update!(captain_models: { 'assistant' => 'gpt-5.2' })
expect(described_class.new(feature: 'assistant', account: account).model).to eq('gpt-5.2')
end
it 'uses the installation model when feature context has no account override' do
- create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-4.1-nano')
+ create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-5-mini')
- expect(described_class.new(feature: 'assistant', account: account).model).to eq('gpt-4.1-nano')
+ expect(described_class.new(feature: 'assistant', account: account).model).to eq('gpt-5-mini')
end
it 'uses the Captain V2 assistant default ahead of the installation model' do
- create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-4.1-nano')
+ create(:installation_config, name: 'CAPTAIN_OPEN_AI_MODEL', value: 'gpt-5-mini')
account.enable_features!('captain_integration')
expect(described_class.new(feature: 'assistant', account: account).model).to eq('gpt-5.2')
@@ -58,7 +58,7 @@ RSpec.describe Llm::BaseAiService do
it 'retains the existing JSON format and protocol on custom endpoints' do
InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_ENDPOINT').update!(value: 'https://custom.example')
- chat = described_class.new(feature: 'document_faq_generation', account: account).json_chat(model: 'gpt-4.1')
+ chat = described_class.new(feature: 'document_faq_generation', account: account).json_chat(model: 'gpt-6-luna')
chat.add_message(role: :user, content: 'Generate JSON FAQs.')
expect(chat.render).to include(messages: an_instance_of(Array), response_format: { type: 'json_object' })
@@ -107,10 +107,11 @@ RSpec.describe Llm::BaseAiService do
it 'sets temperature when the model registry marks it supported' do
llm_chat = instance_double(RubyLLM::Chat)
configured_chat = instance_double(RubyLLM::Chat)
- allow(RubyLLM).to receive(:chat).with(model: 'gpt-4.1-mini', protocol: :responses).and_return(llm_chat)
+ allow(RubyLLM).to receive(:chat).with(model: 'gpt-6-luna', protocol: :responses).and_return(llm_chat)
+ allow(llm_chat).to receive(:with_thinking).with(effort: :none).and_return(llm_chat)
allow(llm_chat).to receive(:with_temperature).with(0.7).and_return(configured_chat)
- expect(service.chat(model: 'gpt-4.1-mini', temperature: 0.7)).to eq(configured_chat)
+ expect(service.chat(model: 'gpt-6-luna', temperature: 0.7)).to eq(configured_chat)
end
end
end
diff --git a/spec/enterprise/services/llm/speech_to_text_service_spec.rb b/spec/enterprise/services/llm/speech_to_text_service_spec.rb
index ebf7518da9c..512115999d5 100644
--- a/spec/enterprise/services/llm/speech_to_text_service_spec.rb
+++ b/spec/enterprise/services/llm/speech_to_text_service_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Llm::SpeechToTextService, type: :service do
before do
InstallationConfig.find_or_create_by!(name: 'CAPTAIN_OPEN_AI_API_KEY') { |config| config.value = 'test-api-key' }
- InstallationConfig.find_or_create_by!(name: 'CAPTAIN_OPEN_AI_MODEL') { |config| config.value = 'gpt-4o-mini' }
+ InstallationConfig.find_or_create_by!(name: 'CAPTAIN_OPEN_AI_MODEL') { |config| config.value = 'gpt-6-luna' }
attachment.file.attach(
io: File.open(Rails.public_path.join('audio/widget/ding.mp3')),
@@ -108,7 +108,7 @@ RSpec.describe Llm::SpeechToTextService, type: :service do
it 'uses the audio transcription feature model' do
expect(audio_api).to receive(:transcribe).with(
- parameters: hash_including(model: 'gpt-4o-mini-transcribe', temperature: 0.0)
+ parameters: hash_including(model: 'gpt-transcribe', temperature: 0.0)
).and_return({ 'text' => 'Audio transcript' })
expect(service.perform).to eq('Audio transcript')
diff --git a/spec/enterprise/services/messages/audio_transcription_service_spec.rb b/spec/enterprise/services/messages/audio_transcription_service_spec.rb
index b2d18b7bb2b..a3fac875152 100644
--- a/spec/enterprise/services/messages/audio_transcription_service_spec.rb
+++ b/spec/enterprise/services/messages/audio_transcription_service_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe Messages::AudioTranscriptionService, type: :service do
before do
# Create required installation configs
InstallationConfig.find_or_create_by!(name: 'CAPTAIN_OPEN_AI_API_KEY') { |config| config.value = 'test-api-key' }
- InstallationConfig.find_or_create_by!(name: 'CAPTAIN_OPEN_AI_MODEL') { |config| config.value = 'gpt-4o-mini' }
+ InstallationConfig.find_or_create_by!(name: 'CAPTAIN_OPEN_AI_MODEL') { |config| config.value = 'gpt-6-luna' }
# Mock usage limits for transcription to be available
allow(account).to receive(:usage_limits).and_return(
diff --git a/spec/lib/captain/base_task_service_spec.rb b/spec/lib/captain/base_task_service_spec.rb
index 2b5890f035a..ba040f6ce5c 100644
--- a/spec/lib/captain/base_task_service_spec.rb
+++ b/spec/lib/captain/base_task_service_spec.rb
@@ -113,7 +113,7 @@ RSpec.describe Captain::BaseTaskService do
end
describe '#make_api_call' do
- let(:model) { 'gpt-4' }
+ let(:model) { 'gpt-5.2' }
let(:messages) { [{ role: 'system', content: 'Test' }, { role: 'user', content: 'Hello' }] }
let(:mock_chat) { instance_double(RubyLLM::Chat) }
let(:mock_context) { instance_double(RubyLLM::Context, chat: mock_chat) }
@@ -122,6 +122,7 @@ RSpec.describe Captain::BaseTaskService do
before do
allow(Llm::Config).to receive(:with_api_key).and_yield(mock_context)
allow(mock_chat).to receive(:with_instructions)
+ allow(mock_chat).to receive(:with_thinking).and_return(mock_chat)
allow(mock_chat).to receive(:ask).and_return(mock_response)
end
@@ -169,11 +170,11 @@ RSpec.describe Captain::BaseTaskService do
end
it 'uses the resolved feature model for the request and instrumentation' do
- account.update!(captain_models: { 'editor' => 'gpt-4.1' })
+ account.update!(captain_models: { 'editor' => 'gpt-5.1' })
- expect(mock_context).to receive(:chat).with(model: 'gpt-4.1', protocol: :responses).and_return(mock_chat)
+ expect(mock_context).to receive(:chat).with(model: 'gpt-5.1', protocol: :responses).and_return(mock_chat)
expect(service).to receive(:instrument_llm_call).with(
- hash_including(model: 'gpt-4.1', feature_name: 'test_event')
+ hash_including(model: 'gpt-5.1', feature_name: 'test_event')
).and_call_original
service.send(:make_api_call, feature: 'editor', messages: messages)
@@ -192,9 +193,9 @@ RSpec.describe Captain::BaseTaskService do
end
it 'prefers account overrides over supplied feature fallback models' do
- account.update!(captain_models: { 'help_center_article_generation' => 'gpt-4.1' })
+ account.update!(captain_models: { 'help_center_article_generation' => 'gpt-5.1' })
- expect(mock_context).to receive(:chat).with(model: 'gpt-4.1', protocol: :responses).and_return(mock_chat)
+ expect(mock_context).to receive(:chat).with(model: 'gpt-5.1', protocol: :responses).and_return(mock_chat)
service.send(:make_api_call, feature: 'help_center_article_generation', model: 'gpt-5.2', messages: messages)
end
@@ -228,7 +229,7 @@ RSpec.describe Captain::BaseTaskService do
end
describe 'chat setup' do
- let(:model) { 'gpt-4' }
+ let(:model) { 'gpt-5.2' }
let(:mock_chat) { instance_double(RubyLLM::Chat) }
let(:mock_context) { instance_double(RubyLLM::Context, chat: mock_chat) }
let(:mock_response) { instance_double(RubyLLM::Message, content: 'Response', tokens: RubyLLM::Tokens.new(input: 10, output: 20)) }
@@ -282,7 +283,7 @@ RSpec.describe Captain::BaseTaskService do
end
describe 'error handling' do
- let(:model) { 'gpt-4' }
+ let(:model) { 'gpt-5.2' }
let(:messages) { [{ role: 'user', content: 'Hello' }] }
let(:error) { StandardError.new('API Error') }
let(:exception_tracker) { instance_double(ChatwootExceptionTracker) }
diff --git a/spec/lib/captain/reply_suggestion_service_spec.rb b/spec/lib/captain/reply_suggestion_service_spec.rb
index 0874ab27b1f..2bcfdfc6c10 100644
--- a/spec/lib/captain/reply_suggestion_service_spec.rb
+++ b/spec/lib/captain/reply_suggestion_service_spec.rb
@@ -23,6 +23,7 @@ RSpec.describe Captain::ReplySuggestionService do
allow(mock_chat).to receive(:with_tools).and_return(mock_chat)
allow(mock_chat).to receive(:after_message).and_return(mock_chat)
allow(mock_chat).to receive(:with_instructions) { |msg| captured_messages << { role: 'system', content: msg } }
+ allow(mock_chat).to receive(:with_thinking).and_return(mock_chat)
allow(mock_chat).to receive(:add_message) { |args| captured_messages << args }
allow(mock_chat).to receive(:ask) do |msg|
captured_messages << { role: 'user', content: msg }
diff --git a/spec/lib/captain/rewrite_service_spec.rb b/spec/lib/captain/rewrite_service_spec.rb
index 41d879fbac8..7fdf4255ee1 100644
--- a/spec/lib/captain/rewrite_service_spec.rb
+++ b/spec/lib/captain/rewrite_service_spec.rb
@@ -15,6 +15,7 @@ RSpec.describe Captain::RewriteService do
InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_API_KEY').update!(value: 'test-key')
allow(Llm::Config).to receive(:with_api_key).and_yield(mock_context)
allow(mock_chat).to receive(:with_instructions)
+ allow(mock_chat).to receive(:with_thinking).and_return(mock_chat)
allow(mock_chat).to receive(:ask).and_return(mock_response)
# Stub captain enabled check to allow specs to test base functionality
# without enterprise module interference
diff --git a/spec/lib/captain/summary_service_spec.rb b/spec/lib/captain/summary_service_spec.rb
index 0d98128be1b..ba9959707ff 100644
--- a/spec/lib/captain/summary_service_spec.rb
+++ b/spec/lib/captain/summary_service_spec.rb
@@ -13,6 +13,7 @@ RSpec.describe Captain::SummaryService do
InstallationConfig.find_or_initialize_by(name: 'CAPTAIN_OPEN_AI_API_KEY').update!(value: 'test-key')
allow(Llm::Config).to receive(:with_api_key).and_yield(mock_context)
allow(mock_chat).to receive(:with_instructions)
+ allow(mock_chat).to receive(:with_thinking).and_return(mock_chat)
allow(mock_chat).to receive(:ask).and_return(mock_response)
# Stub captain enabled check to allow specs to test base functionality
# without enterprise module interference
diff --git a/spec/lib/integrations/llm_base_service_spec.rb b/spec/lib/integrations/llm_base_service_spec.rb
index 8f50156503a..9ca46f4109a 100644
--- a/spec/lib/integrations/llm_base_service_spec.rb
+++ b/spec/lib/integrations/llm_base_service_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Integrations::LlmBaseService do
let(:event) { { 'name' => 'summarize', 'data' => { 'conversation_display_id' => conversation.display_id } } }
let(:service) { described_class.new(hook: hook, event: event) }
let(:error) { StandardError.new('API Error') }
- let(:body) { { model: 'gpt-4', messages: [{ role: 'user', content: 'Hello' }] }.to_json }
+ let(:body) { { model: 'gpt-6-luna', messages: [{ role: 'user', content: 'Hello' }] }.to_json }
before { allow(Integrations::Openai::KeyValidator).to receive(:valid?).and_return(true) }
diff --git a/spec/lib/integrations/llm_instrumentation_spec.rb b/spec/lib/integrations/llm_instrumentation_spec.rb
index 031d6e47e1f..2d65547afbd 100644
--- a/spec/lib/integrations/llm_instrumentation_spec.rb
+++ b/spec/lib/integrations/llm_instrumentation_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe Integrations::LlmInstrumentation do
account_id: 123,
conversation_id: 456,
feature_name: 'reply_suggestion',
- model: 'gpt-4o-mini',
+ model: 'gpt-6-luna',
messages: [{ 'role' => 'user', 'content' => 'Hello' }],
temperature: 0.7
}
@@ -141,7 +141,7 @@ RSpec.describe Integrations::LlmInstrumentation do
instance.instrument_llm_call(params) { 'result' }
expect(mock_span).to have_received(:set_attribute).with('gen_ai.provider.name', 'openai')
- expect(mock_span).to have_received(:set_attribute).with('gen_ai.request.model', 'gpt-4o-mini')
+ expect(mock_span).to have_received(:set_attribute).with('gen_ai.request.model', 'gpt-6-luna')
expect(mock_span).to have_received(:set_attribute).with('gen_ai.request.temperature', 0.7)
end
diff --git a/spec/lib/llm/feature_router_spec.rb b/spec/lib/llm/feature_router_spec.rb
index f6fdff2cbbc..0b2dde938ca 100644
--- a/spec/lib/llm/feature_router_spec.rb
+++ b/spec/lib/llm/feature_router_spec.rb
@@ -16,20 +16,20 @@ RSpec.describe Llm::FeatureRouter do
expect(resolved).to eq(
feature: 'editor',
provider: 'openai',
- model: 'gpt-4.1-mini',
+ model: 'gpt-6-luna',
source: :default
)
end
it 'uses a valid account model override' do
- account.update!(captain_models: { 'editor' => 'gpt-4.1' })
+ account.update!(captain_models: { 'editor' => 'gpt-5.1' })
resolved = described_class.resolve(feature: 'editor', account: account)
expect(resolved).to include(
feature: 'editor',
provider: 'openai',
- model: 'gpt-4.1',
+ model: 'gpt-5.1',
source: :account_override
)
end
@@ -119,7 +119,7 @@ RSpec.describe Llm::FeatureRouter do
resolved = described_class.resolve(feature: 'editor', account: account)
expect(resolved).to include(
- model: 'gpt-4.1-mini',
+ model: 'gpt-6-luna',
source: :default
)
end
@@ -130,7 +130,7 @@ RSpec.describe Llm::FeatureRouter do
resolved = described_class.resolve(feature: 'editor', account: account)
expect(resolved).to include(
- model: 'gpt-4.1-mini',
+ model: 'gpt-6-luna',
source: :default
)
end
diff --git a/spec/lib/llm/models_spec.rb b/spec/lib/llm/models_spec.rb
index 522407da226..751418cd693 100644
--- a/spec/lib/llm/models_spec.rb
+++ b/spec/lib/llm/models_spec.rb
@@ -27,14 +27,14 @@ RSpec.describe Llm::Models do
end
it 'routes each FAQ operation independently' do
- expect(described_class.default_model_for('document_faq_generation')).to eq('gpt-4.1-mini')
+ expect(described_class.default_model_for('document_faq_generation')).to eq('gpt-6-luna')
expect(described_class.default_model_for('conversation_faq_generation')).to eq('gpt-5.2')
- expect(described_class.default_model_for('conversation_faq_matching')).to eq('gpt-4.1-mini')
+ expect(described_class.default_model_for('conversation_faq_matching')).to eq('gpt-6-luna')
end
it 'offers only supported OpenAI models for conversation completion' do
expect(described_class.models_for('conversation_completion')).to eq(
- %w[gpt-4.1-mini gpt-5-mini gpt-4.1 gpt-5.1 gpt-5.2]
+ %w[gpt-6-luna gpt-5-mini gpt-5.1 gpt-5.2]
)
end
end
@@ -56,10 +56,10 @@ RSpec.describe Llm::Models do
it 'returns model metadata for a feature' do
config = described_class.feature_config('editor')
- expect(config[:default]).to eq('gpt-4.1-mini')
+ expect(config[:default]).to eq('gpt-6-luna')
expect(config[:models].first).to include(
- id: 'gpt-4.1-mini',
- display_name: 'GPT-4.1 Mini',
+ id: 'gpt-6-luna',
+ display_name: 'GPT-6 Luna',
provider: 'openai',
credit_multiplier: 1
)
diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb
index bff67193c43..4107bab759b 100644
--- a/spec/models/account_spec.rb
+++ b/spec/models/account_spec.rb
@@ -495,11 +495,11 @@ RSpec.describe Account do
describe 'with saved model preferences' do
it 'returns saved preferences merged with defaults' do
- account.update!(captain_models: { 'editor' => 'gpt-4.1-mini', 'assistant' => 'gpt-5.2' })
+ account.update!(captain_models: { 'editor' => 'gpt-5-mini', 'assistant' => 'gpt-5.2' })
prefs = account.captain_preferences
- expect(prefs[:models]['editor']).to eq('gpt-4.1-mini')
+ expect(prefs[:models]['editor']).to eq('gpt-5-mini')
expect(prefs[:models]['assistant']).to eq('gpt-5.2')
expect(prefs[:models]['copilot']).to eq(Llm::Models.default_model_for('copilot'))
end
@@ -526,13 +526,13 @@ RSpec.describe Account do
end
it 'accepts valid model for a feature' do
- account.captain_models = { 'editor' => 'gpt-4.1-mini', 'help_center_query_translation' => 'gpt-4.1-nano' }
+ account.captain_models = { 'editor' => 'gpt-5-mini', 'help_center_query_translation' => 'gpt-5-mini' }
expect(account).to be_valid
end
it 'rejects unknown feature keys' do
- account.captain_models = { 'unknown_feature' => 'gpt-4.1' }
+ account.captain_models = { 'unknown_feature' => 'gpt-5.1' }
expect(account).not_to be_valid
expect(account.errors[:captain_models]).to include("'unknown_feature' is not a known feature")
diff --git a/spec/models/concerns/captain_featurable_spec.rb b/spec/models/concerns/captain_featurable_spec.rb
index 62206aee70a..2a05a492f1c 100644
--- a/spec/models/concerns/captain_featurable_spec.rb
+++ b/spec/models/concerns/captain_featurable_spec.rb
@@ -61,16 +61,16 @@ RSpec.describe CaptainFeaturable do
context 'when models are explicitly configured' do
before do
account.update!(captain_models: {
- 'editor' => 'gpt-4.1-mini',
+ 'editor' => 'gpt-5-mini',
'assistant' => 'gpt-5.1',
- 'help_center_query_translation' => 'gpt-4.1-mini'
+ 'help_center_query_translation' => 'gpt-5-mini'
})
end
it 'returns configured models for configured features' do
- expect(account.captain_editor_model).to eq('gpt-4.1-mini')
+ expect(account.captain_editor_model).to eq('gpt-5-mini')
expect(account.captain_assistant_model).to eq('gpt-5.1')
- expect(account.captain_help_center_query_translation_model).to eq('gpt-4.1-mini')
+ expect(account.captain_help_center_query_translation_model).to eq('gpt-5-mini')
end
it 'returns default models for unconfigured features' do
@@ -87,6 +87,13 @@ RSpec.describe CaptainFeaturable do
it 'falls back to default model' do
expect(account.captain_editor_model).to eq(Llm::Models.default_model_for('editor'))
end
+
+ it 'rejects the change but still saves other attributes once stored' do
+ expect(account).not_to be_valid
+
+ account.save(validate: false)
+ expect(account.reload.update(name: 'Renamed')).to be(true)
+ end
end
context 'when captain_models is nil' do
@@ -114,7 +121,7 @@ RSpec.describe CaptainFeaturable do
end
it 'model methods use the same logic as captain_preferences[:models]' do
- account.update!(captain_models: { 'editor' => 'gpt-4.1-mini', 'assistant' => 'gpt-5.2' })
+ account.update!(captain_models: { 'editor' => 'gpt-5-mini', 'assistant' => 'gpt-5.2' })
prefs = account.captain_preferences
Llm::Models.feature_keys.each do |feature_key|