How to fix tool call returning duplicates? Tool works fine in direct tests but the large model produces duplicates

It is recommended to check whether the internal logic of the tool contains multiple conditional judgments and string concatenation, which may cause duplicate entries in the returned JSON result.