From a20a75bf9945e8feff0293e03be5e0614cc94cec Mon Sep 17 00:00:00 2001 From: Kikia Carter Date: Tue, 13 May 2025 11:11:03 -0400 Subject: [PATCH 1/2] Fix: Remove parallel_tool_calls from OpenAI provider for O3 model compatibility - Removed parallel_tool_calls=True from OpenAI _initialize_default_params - Removed code that adds parallel_tool_calls to API request in _prepare_api_request --- src/mcp_agent/llm/providers/augmented_llm_openai.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/mcp_agent/llm/providers/augmented_llm_openai.py b/src/mcp_agent/llm/providers/augmented_llm_openai.py index 42c728f70..8991465b0 100644 --- a/src/mcp_agent/llm/providers/augmented_llm_openai.py +++ b/src/mcp_agent/llm/providers/augmented_llm_openai.py @@ -78,7 +78,7 @@ def __init__(self, provider: Provider = Provider.OPENAI, *args, **kwargs) -> Non self._reasoning_effort = self.context.config.openai.reasoning_effort # Determine if we're using a reasoning model - # TODO -- move this to model capabiltities, add o4. + # TODO -- move this to model capabilities, add o4. chosen_model = self.default_request_params.model if self.default_request_params else None self._reasoning = chosen_model and ( chosen_model.startswith("o3") or chosen_model.startswith("o1") @@ -95,7 +95,6 @@ def _initialize_default_params(self, kwargs: dict) -> RequestParams: return RequestParams( model=chosen_model, systemPrompt=self.instruction, - parallel_tool_calls=True, max_iterations=20, use_history=True, ) @@ -346,9 +345,6 @@ def _prepare_api_request( else: base_args["max_tokens"] = request_params.maxTokens - if tools: - base_args["parallel_tool_calls"] = request_params.parallel_tool_calls - arguments: Dict[str, str] = self.prepare_provider_arguments( base_args, request_params, self.OPENAI_EXCLUDE_FIELDS.union(self.BASE_EXCLUDE_FIELDS) ) From 49bf8b8a0134a8ec1e2fc1880426acfbb01a65fd Mon Sep 17 00:00:00 2001 From: evalstate <1936278+evalstate@users.noreply.github.com> Date: Tue, 13 May 2025 21:48:55 +0100 Subject: [PATCH 2/2] fix parallel_tool_calls - keep functionality for non-reasoning models --- src/mcp_agent/llm/providers/augmented_llm_openai.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mcp_agent/llm/providers/augmented_llm_openai.py b/src/mcp_agent/llm/providers/augmented_llm_openai.py index 8991465b0..1e876184c 100644 --- a/src/mcp_agent/llm/providers/augmented_llm_openai.py +++ b/src/mcp_agent/llm/providers/augmented_llm_openai.py @@ -95,6 +95,7 @@ def _initialize_default_params(self, kwargs: dict) -> RequestParams: return RequestParams( model=chosen_model, systemPrompt=self.instruction, + parallel_tool_calls=True, max_iterations=20, use_history=True, ) @@ -324,7 +325,7 @@ async def post_tool_call( return result def _prepare_api_request( - self, messages, tools, request_params: RequestParams + self, messages, tools: List[ChatCompletionToolParam] | None, request_params: RequestParams ) -> dict[str, str]: # Create base arguments dictionary @@ -344,6 +345,8 @@ def _prepare_api_request( ) else: base_args["max_tokens"] = request_params.maxTokens + if tools: + base_args["parallel_tool_calls"] = request_params.parallel_tool_calls arguments: Dict[str, str] = self.prepare_provider_arguments( base_args, request_params, self.OPENAI_EXCLUDE_FIELDS.union(self.BASE_EXCLUDE_FIELDS)