@@ -165,10 +165,8 @@ def add_message_and_run!(content: nil, image_url: nil)
165165 # @param output [String] The output of the tool
166166 # @return [Array<Langchain::Message>] The messages
167167 def submit_tool_output ( tool_call_id :, output :)
168- tool_role = determine_tool_role
169-
170168 # TODO: Validate that `tool_call_id` is valid by scanning messages and checking if this tool call ID was invoked
171- add_message ( role : tool_role , content : output , tool_call_id : tool_call_id )
169+ add_message ( role : @llm_adapter . tool_role , content : output , tool_call_id : tool_call_id )
172170 end
173171
174172 # Delete all messages
@@ -179,9 +177,6 @@ def clear_messages!
179177 @messages = [ ]
180178 end
181179
182- # TODO: Remove in the next major release
183- alias_method :clear_thread! , :clear_messages!
184-
185180 # Set new instructions
186181 #
187182 # @param new_instructions [String] New instructions that will be set as a system message
@@ -328,24 +323,6 @@ def execute_tools
328323 :failed
329324 end
330325
331- # Determine the tool role based on the LLM type
332- #
333- # @return [String] The tool role
334- def determine_tool_role
335- case llm
336- when Langchain ::LLM ::Anthropic
337- Messages ::AnthropicMessage ::TOOL_ROLE
338- when Langchain ::LLM ::GoogleGemini , Langchain ::LLM ::GoogleVertexAI
339- Messages ::GoogleGeminiMessage ::TOOL_ROLE
340- when Langchain ::LLM ::MistralAI
341- Messages ::MistralAIMessage ::TOOL_ROLE
342- when Langchain ::LLM ::Ollama
343- Messages ::OllamaMessage ::TOOL_ROLE
344- when Langchain ::LLM ::OpenAI
345- Messages ::OpenAIMessage ::TOOL_ROLE
346- end
347- end
348-
349326 def initialize_instructions
350327 if llm . is_a? ( Langchain ::LLM ::OpenAI ) || llm . is_a? ( Langchain ::LLM ::MistralAI )
351328 self . instructions = @instructions if @instructions
0 commit comments