I don't know anything about Kagi's internals, so pardon my ignorance, but I'd assume adding a simple rule for Github to ignore https://github.com/${X}/${Y}/discussions/${Z}?sort={STRING}, when https://github.com/${X}/${Y}/discussions/${Z} is already present in the results, should be an achievable task.
Edit: Or rather always use https://github.com/${X}/${Y}/discussions/${Z} instead when any occurence of https://github.com/${X}/${Y}/discussions/${Z}?sort={STRING} is in the results and then deduplicate. Because no one really needs a preset sorting option in the search results.