diff --git a/pydantic_ai_slim/pydantic_ai/models/huggingface.py b/pydantic_ai_slim/pydantic_ai/models/huggingface.py index 23473fb7d6..e4a7157393 100644 --- a/pydantic_ai_slim/pydantic_ai/models/huggingface.py +++ b/pydantic_ai_slim/pydantic_ai/models/huggingface.py @@ -377,8 +377,6 @@ def _map_tool_definition(f: ToolDefinition) -> ChatCompletionInputTool: }, } ) - if f.strict is not None: - tool_param['function']['strict'] = f.strict return tool_param async def _map_user_message( diff --git a/tests/models/test_huggingface.py b/tests/models/test_huggingface.py index c872c6154b..7c9493fed7 100644 --- a/tests/models/test_huggingface.py +++ b/tests/models/test_huggingface.py @@ -893,51 +893,6 @@ async def test_thinking_part_in_history(allow_model_requests: None): ) -@pytest.mark.parametrize('strict', [True, False, None]) -async def test_tool_strict_mode(allow_model_requests: None, strict: bool | None): - tool_call = ChatCompletionOutputToolCall.parse_obj_as_instance( # type:ignore - { - 'function': ChatCompletionOutputFunctionDefinition.parse_obj_as_instance( # type:ignore - { - 'name': 'my_tool', - 'arguments': '{"x": 42}', - } - ), - 'id': '1', - 'type': 'function', - } - ) - responses = [ - completion_message( - ChatCompletionOutputMessage.parse_obj_as_instance( # type:ignore - { - 'content': None, - 'role': 'assistant', - 'tool_calls': [tool_call], - } - ) - ), - completion_message(ChatCompletionOutputMessage(content='final response', role='assistant')), # type: ignore - ] - mock_client = MockHuggingFace.create_mock(responses) - model = HuggingFaceModel('hf-model', provider=HuggingFaceProvider(hf_client=mock_client, api_key='x')) - agent = Agent(model) - - @agent.tool_plain(strict=strict) - def my_tool(x: int) -> int: - return x - - result = await agent.run('hello') - assert result.output == 'final response' - - kwargs = get_mock_chat_completion_kwargs(mock_client)[0] - tools = kwargs['tools'] - if strict is not None: - assert tools[0]['function']['strict'] is strict - else: - assert 'strict' not in tools[0]['function'] - - @pytest.mark.parametrize( 'content_item, error_message', [