Skip to content

Commit 8b59fff

Browse files
committed
Add Llama 3.x validation at bind_tools time
- Llama 3.x validation happens early at bind_tools time - Cohere validation happens at provider level (_prepare_request time) - All 16 parallel tool calling tests now pass
1 parent 1c2b0ef commit 8b59fff

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

libs/oci/langchain_oci/chat_models/oci_generative_ai.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -861,14 +861,6 @@ def _should_allow_more_tool_calls(
861861

862862
# Add parallel tool calls support (GenericChatRequest models)
863863
if "is_parallel_tool_calls" in kwargs:
864-
# Validate Llama 3.x doesn't support parallel tool calls
865-
model_id = self.llm.model_id
866-
if "llama" in model_id.lower() and not self.llm._supports_parallel_tool_calls(model_id):
867-
raise ValueError(
868-
f"Parallel tool calls not supported for {model_id}. "
869-
"Only Llama 4+ models support this feature. "
870-
"Llama 3.x (including 3.3) don't support parallel calls."
871-
)
872864
result["is_parallel_tool_calls"] = kwargs["is_parallel_tool_calls"]
873865

874866
return result
@@ -1321,7 +1313,13 @@ def bind_tools(
13211313
else self.parallel_tool_calls
13221314
)
13231315
if use_parallel:
1324-
# Store the parameter; validation happens in provider
1316+
# Validate Llama 3.x doesn't support parallel tool calls (early check)
1317+
if "llama" in self.model_id.lower() and not self._supports_parallel_tool_calls(self.model_id):
1318+
raise ValueError(
1319+
f"Parallel tool calls not supported for {self.model_id}. "
1320+
"Only Llama 4+ models support this feature. "
1321+
"Llama 3.x (including 3.3) don't support parallel calls."
1322+
)
13251323
kwargs["is_parallel_tool_calls"] = True
13261324

13271325
return super().bind(tools=formatted_tools, **kwargs)

0 commit comments

Comments
 (0)