In Hilchot Keilim 2:3, Rambam says that objects that have a receptacle that is made only to be (permanently) filled is not susceptible to tumah.
בֵּית קִבּוּל הֶעָשׂוּי לְמַלְּאוֹתוֹ אֵינוֹ בֵּית קִבּוּל. כֵּיצַד. בְּקַעַת שֶׁל עֵץ שֶׁחוֹקְקִין בָּהּ בֵּית קִבּוּל וְתוֹקְעִין בּוֹ הַסַּדָּן שֶׁל בַּרְזֶל. אִם שֶׁל נַפָּחִים הִיא אֵינָהּ מְקַבֶּלֶת טֻמְאָה שֶׁאַף עַל פִּי שֶׁיֵּשׁ בָּהּ בֵּית קִבּוּל לֹא נַעֲשָׂה אֶלָּא לְמַלְּאוֹתוֹ. וְכֵן כָּל כַּיּוֹצֵא בָּזֶה.
When a receptacle is intended to be filled, it is not considered as a receptacle. What is implied? When a receptacle is hollowed out from a block of wood and then a metal anvil is inserted into it, if it is a blacksmith's, it is not susceptible to ritual impurity. Although it has a receptacle, it was made to be filled. Similar laws apply in all analogous situations. [from Chabad]
On the other hand, the mishna Keilim 23:1 — cited as authoritative by Rambam in Hilchot Keilim 7:15 — lists objects that are made to be filled/stuffed, and are susceptible to tumah when closed (according to Rambam's explanation, as well as Bartenura's).
הַכַּדּוּר וְהָאִמּוּם וְהַקָּמֵעַ וְהַתְּפִלִּין שֶׁנִּקְרְעוּ, הַנּוֹגֵעַ בָּהֶן, טָמֵא. וּבְמַה שֶּׁבְּתוֹכָן, טָהוֹר. הָאֻכָּף שֶׁנִּקְרַע, הַנּוֹגֵעַ בְּמַה שֶּׁבְּתוֹכוֹ, טָמֵא, מִפְּנֵי שֶׁהַתֶּפֶר מְחַבְּרוֹ:
If a ball, a mould, an amulet or tefillin were torn, one that touches them becomes unclean, But one that touches what is inside them remains clean. If a saddle was torn, one that touches its contents unclean, because the stitching joins them. [from Sefaria]
According to Rambam, shouldn't these objects be insusceptible to tumah when closed? If this is indeed a contradiction, how can this be resolved?
Kehati mentions this issue, and cites an explanation of Tiferet Yisrael, Boaz that Hilchot Keilim 2:3 only applies to objects that will never be opened, unlike these, which are opened occasionally to check the tefillin or to rearrange the stuffing. But it seems to me that even Rambam's example of an anvil will get taken out of the receptacle when being replaced or moved. Also, at least a ball is made never to be opened, it would seem to me.
So I'm looking for other explanations, or a defence of the explanation in Boaz.