  Kottwitz's conjecture describes the contribution of a supercuspidal
represention to the cohomology of a local Shimura variety in terms of the local
Langlands correspondence. A natural extension of this conjecture concerns
Scholze's more general spaces of local shtukas. Using a new Lefschetz-Verdier
trace formula for v-stacks, we prove the extended conjecture, disregarding the
action of the Weil group, and modulo a virtual representation whose character
vanishes on the locus of elliptic elements. As an application, we show that for
an irreducible smooth representation of an inner form of $\mathrm{GL}_n$, the
$L$-parameter constructed by Fargues-Scholze agrees with the usual
semisimplified parameter arising from local Langlands.
