feat: hand off if captain limits are reached
This commit is contained in:
@@ -3,8 +3,12 @@ class Captain::Conversation::ResponseBuilderJob < ApplicationJob
|
||||
|
||||
def perform(conversation, assistant)
|
||||
@conversation = conversation
|
||||
@inbox = conversation.inbox
|
||||
@assistant = assistant
|
||||
|
||||
# this ensures that the conversation is not processed if the assistant limits are reached
|
||||
return ActiveRecord::Base.transaction { process_action('handoff') } unless @inbox.captain_active?
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
generate_and_process_response
|
||||
end
|
||||
|
||||
@@ -10,6 +10,9 @@ module Enterprise::MessageTemplates::HookExecutionService
|
||||
end
|
||||
|
||||
def should_process_captain_response?
|
||||
conversation.pending? && message.incoming? && inbox.captain_active?
|
||||
# we don't check the captain usage limits here intentionally
|
||||
# as the usage limits are checked in the job itself
|
||||
# this is to ensure that the handoff can be done there if it's required
|
||||
conversation.pending? && message.incoming? && inbox.captain_assistant.present?
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user