That is because you pre-allocated storage with Float64 element type, which during optimization will be populated with Dual numbers. The solution for that is to handle your storage with PreallocationTools.jl, until Optimization.jl can make better use of the Cache objects provided by DifferentiationInterface.jl.
To avoid this error, you would need to define a custom rule with ChainRulesCore.jl for your high-level function as a whole. That is what I did for HiddenMarkovModels.jl, where it turns out that the forward-backward algorithm gives you all the necessary information for derivatives. I assume similar results exist for the Kalman filter.
Alternately, Zygote.Buffer might be able to handle the simplest in-place operations.
Have you tried activating the recommended Enzyme.jl options? What is the stack trace?
Also, have you tried Mooncake.jl with AutoMooncake(; config=nothing)?