# Pull Request Template ## Description captain decides if conversation should be resolved or open Fixes https://linear.app/chatwoot/issue/AI-91/make-captain-resolution-time-configurable Update: Added 2 entries in reporting events: `conversation_captain_handoff` and `conversation_captain_resolved` ## Type of change Please delete options that are not relevant. - [x] New feature (non-breaking change which adds functionality) - [x] This change requires a documentation update ## 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. LLM call decides that conversation is resolved, drops a private note <img width="1228" height="438" alt="image" src="https://github.com/user-attachments/assets/fb2cf1e9-4b2b-458b-a1e2-45c53d6a0158" /> LLM call decides conversation is still open as query was not resolved <img width="1215" height="573" alt="image" src="https://github.com/user-attachments/assets/2d1d5322-f567-487e-954e-11ab0798d11c" /> ## 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 --------- Co-authored-by: Sojan Jose <sojan@pepalo.com>
24 lines
1.1 KiB
Ruby
24 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 })
|
|
|
|
conversation.with_captain_activity_context(reason: reason, reason_type: :tool) { conversation.resolved! }
|
|
|
|
"Conversation ##{conversation.display_id} resolved#{" (Reason: #{reason})" if reason}"
|
|
end
|
|
|
|
private
|
|
|
|
def permissions
|
|
%w[conversation_manage conversation_unassigned_manage conversation_participating_manage]
|
|
end
|
|
end
|