From 84fda8a3236e16c466316f6c82d0ed5408b706b0 Mon Sep 17 00:00:00 2001 From: Aakash Bakhle <48802744+aakashb95@users.noreply.github.com> Date: Tue, 23 Jun 2026 16:55:42 +0530 Subject: [PATCH] fix(captain): move false promise harness setting to account (#14823) # Pull Request Template ## Description moves the harness to account settings rather than assistant settings ## Type of change refactor ## How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration. locally and specs ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] Any dependent changes have been merged and published in downstream modules --- app/models/account.rb | 2 +- app/models/concerns/account_settings_schema.rb | 1 + .../jobs/captain/conversation/v1_false_promise_handler.rb | 2 +- .../jobs/captain/conversation/response_builder_job_spec.rb | 6 +++--- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/models/account.rb b/app/models/account.rb index 667058a2f..0fa3e6659 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -54,7 +54,7 @@ class Account < ApplicationRecord store_accessor :settings, :captain_models, :captain_features store_accessor :settings, :reporting_timezone store_accessor :settings, :keep_pending_on_bot_failure - store_accessor :settings, :captain_auto_resolve_mode + store_accessor :settings, :captain_auto_resolve_mode, :captain_false_promise_harness_enabled include AccountCaptainAutoResolve has_many :account_users, dependent: :destroy_async diff --git a/app/models/concerns/account_settings_schema.rb b/app/models/concerns/account_settings_schema.rb index 52e1c2811..c3242fa30 100644 --- a/app/models/concerns/account_settings_schema.rb +++ b/app/models/concerns/account_settings_schema.rb @@ -12,6 +12,7 @@ module AccountSettingsSchema 'auto_resolve_label': { 'type': %w[string null] }, 'keep_pending_on_bot_failure': { 'type': %w[boolean null] }, 'captain_auto_resolve_mode': { 'type': %w[string null], 'enum': ['evaluated', 'legacy', 'disabled', nil] }, + 'captain_false_promise_harness_enabled': { 'type': %w[boolean null] }, 'conversation_required_attributes': { 'type': %w[array null], 'items': { 'type': 'string' } diff --git a/enterprise/app/jobs/captain/conversation/v1_false_promise_handler.rb b/enterprise/app/jobs/captain/conversation/v1_false_promise_handler.rb index d3c99a73c..9e56fc207 100644 --- a/enterprise/app/jobs/captain/conversation/v1_false_promise_handler.rb +++ b/enterprise/app/jobs/captain/conversation/v1_false_promise_handler.rb @@ -80,7 +80,7 @@ module Captain::Conversation::V1FalsePromiseHandler end def v1_false_promise_harness_enabled? - ActiveModel::Type::Boolean.new.cast(@assistant.config['false_promise_harness_enabled']) + ActiveModel::Type::Boolean.new.cast(account.captain_false_promise_harness_enabled) end def log_v1_false_promise_detection(detection) diff --git a/spec/enterprise/jobs/captain/conversation/response_builder_job_spec.rb b/spec/enterprise/jobs/captain/conversation/response_builder_job_spec.rb index c671edd2a..3cb6958f5 100644 --- a/spec/enterprise/jobs/captain/conversation/response_builder_job_spec.rb +++ b/spec/enterprise/jobs/captain/conversation/response_builder_job_spec.rb @@ -62,7 +62,7 @@ RSpec.describe Captain::Conversation::ResponseBuilderJob, type: :job do expect(conversation.messages.last.content).to eq('Hey, welcome to Captain Specs') end - it 'does not run the false promise harness when the assistant setting is disabled' do + it 'does not run the false promise harness when the account setting is disabled' do expect(Captain::Llm::AssistantFalsePromiseService).not_to receive(:new) described_class.perform_now(conversation, assistant) @@ -70,9 +70,9 @@ RSpec.describe Captain::Conversation::ResponseBuilderJob, type: :job do expect(conversation.messages.last.content).to eq('Hey, welcome to Captain Specs') end - context 'when false promise harness is enabled in assistant config' do + context 'when false promise harness is enabled in account settings' do before do - assistant.update!(config: assistant.config.merge('false_promise_harness_enabled' => true)) + account.update!(settings: account.settings.merge('captain_false_promise_harness_enabled' => true)) end it 'sends the original response when the detector marks it safe' do