From d40fa272893a698936ab030b80299ad8656cc4af Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 9 Jul 2025 18:00:38 +0530 Subject: [PATCH] refactor: simplify not found state --- enterprise/lib/captain/tools/add_private_note_tool.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/enterprise/lib/captain/tools/add_private_note_tool.rb b/enterprise/lib/captain/tools/add_private_note_tool.rb index 12b5f9fb3..69905d5a2 100644 --- a/enterprise/lib/captain/tools/add_private_note_tool.rb +++ b/enterprise/lib/captain/tools/add_private_note_tool.rb @@ -9,7 +9,7 @@ class Captain::Tools::AddPrivateNoteTool < Captain::Tools::BaseAgentTool return 'Missing required parameters: conversation_id and note are required' if conversation_id.blank? || note.blank? conversation = find_conversation(conversation_id) - return conversation if conversation.is_a?(String) # Error message + return 'Conversation not found' unless conversation create_private_note(conversation, note) "Private note added successfully to conversation #{conversation_id}" @@ -18,8 +18,7 @@ class Captain::Tools::AddPrivateNoteTool < Captain::Tools::BaseAgentTool private def find_conversation(conversation_id) - conversation = account_scoped(::Conversation).find_by(display_id: conversation_id) - conversation || 'Conversation not found' + account_scoped(::Conversation).find_by(display_id: conversation_id) end def create_private_note(conversation, note)