Add a temporary `captain_disable_auto_resolve` boolean setting on accounts to prevent Captain from resolving conversations. Guards both the scheduled resolution job and the assistant's resolve tool. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
29 lines
1.1 KiB
Ruby
29 lines
1.1 KiB
Ruby
class Captain::Tools::ResolveConversationTool < Captain::Tools::BasePublicTool
|
|
description 'Resolve a conversation when the issue has been addressed or the conversation should be closed'
|
|
param :reason, type: 'string', desc: 'Brief reason for resolving the conversation', required: true
|
|
|
|
def perform(tool_context, reason:)
|
|
conversation = find_conversation(tool_context.state)
|
|
return 'Conversation not found' unless conversation
|
|
return "Conversation ##{conversation.display_id} is already resolved" if conversation.resolved?
|
|
return 'Auto-resolve is disabled for this account' if conversation.account.captain_disable_auto_resolve
|
|
|
|
log_tool_usage('resolve_conversation', { conversation_id: conversation.id, reason: reason })
|
|
|
|
Current.captain_resolve_reason = reason
|
|
begin
|
|
conversation.resolved!
|
|
ensure
|
|
Current.captain_resolve_reason = nil
|
|
end
|
|
|
|
"Conversation ##{conversation.display_id} resolved#{" (Reason: #{reason})" if reason}"
|
|
end
|
|
|
|
private
|
|
|
|
def permissions
|
|
%w[conversation_manage conversation_unassigned_manage conversation_participating_manage]
|
|
end
|
|
end
|