diff --git a/api/core/agent/patterns/base.py b/api/core/agent/patterns/base.py index 4e6fa5284d..33a746ce5a 100644 --- a/api/core/agent/patterns/base.py +++ b/api/core/agent/patterns/base.py @@ -56,7 +56,10 @@ class AgentPattern(ABC): @abstractmethod def run( - self, prompt_messages: list[PromptMessage], model_parameters: dict[str, Any], stop: list[str] = [], + self, + prompt_messages: list[PromptMessage], + model_parameters: dict[str, Any], + stop: list[str] = [], stream: bool = True, ) -> Generator[LLMResultChunk | AgentLog, None, AgentResult]: """Execute the agent strategy.""" @@ -468,7 +471,8 @@ class AgentPattern(ABC): return None missing = [ - p for p in required_params + p + for p in required_params if p not in tool_args or tool_args[p] is None or (isinstance(tool_args[p], str) and not tool_args[p].strip()) diff --git a/api/core/agent/patterns/function_call.py b/api/core/agent/patterns/function_call.py index d9f043bbe5..391b23e17c 100644 --- a/api/core/agent/patterns/function_call.py +++ b/api/core/agent/patterns/function_call.py @@ -34,7 +34,10 @@ class FunctionCallStrategy(AgentPattern): """Function Call strategy using model's native tool calling capability.""" def run( - self, prompt_messages: list[PromptMessage], model_parameters: dict[str, Any], stop: list[str] = [], + self, + prompt_messages: list[PromptMessage], + model_parameters: dict[str, Any], + stop: list[str] = [], stream: bool = True, ) -> Generator[LLMResultChunk | AgentLog, None, AgentResult]: """Execute the function call agent strategy.""" @@ -307,9 +310,7 @@ class FunctionCallStrategy(AgentPattern): tool_call_log.data = {**tool_call_log.data, "error": validation_error} yield tool_call_log - messages.append( - ToolPromptMessage(content=validation_error, tool_call_id=tool_call_id, name=tool_name) - ) + messages.append(ToolPromptMessage(content=validation_error, tool_call_id=tool_call_id, name=tool_name)) return validation_error, [], None, True # Invoke tool using base class method with error handling diff --git a/api/core/agent/patterns/react.py b/api/core/agent/patterns/react.py index b81d572aea..87a9fa9b65 100644 --- a/api/core/agent/patterns/react.py +++ b/api/core/agent/patterns/react.py @@ -52,7 +52,10 @@ class ReActStrategy(AgentPattern): self.instruction = instruction def run( - self, prompt_messages: list[PromptMessage], model_parameters: dict[str, Any], stop: list[str] = [], + self, + prompt_messages: list[PromptMessage], + model_parameters: dict[str, Any], + stop: list[str] = [], stream: bool = True, ) -> Generator[LLMResultChunk | AgentLog, None, AgentResult]: """Execute the ReAct agent strategy.""" diff --git a/api/tests/unit_tests/utils/structured_output_parser/test_structured_output_parser.py b/api/tests/unit_tests/utils/structured_output_parser/test_structured_output_parser.py index c61f85854e..0b2bddf889 100644 --- a/api/tests/unit_tests/utils/structured_output_parser/test_structured_output_parser.py +++ b/api/tests/unit_tests/utils/structured_output_parser/test_structured_output_parser.py @@ -370,7 +370,7 @@ def test_structured_output_with_pydantic_model_validation_error(): model_schema=model_schema, model_instance=model_instance, prompt_messages=[UserPromptMessage(content="test")], - output_model=ExampleOutput + output_model=ExampleOutput, )