Error during backward integration with callback in DifferentialEquations.jl

Hi everyone,
I was trying to run the following example

using OrdinaryDiffEq

function dynamic!(dx, x, p, t)
    dx[1] = exp(-x[2] - sin(x[2])^2)
    dx[2] = 1. / (x[2] + 1.)
    dx[3] = 1.
end

x0 = [0., 1.0164282571836771, 0.]
cb = ContinuousCallback((x,_,_) -> x[2] , terminate!) 
prob = ODEProblem(dynamic!, x0, (2, 0))
sol = OrdinaryDiffEq.solve(prob, callback = cb)

and I get the following error Current interpolant only works between tprev and t. I don’t really know if I am doing something wrong or if it’s a bug.

Thank you for your help.

Package info

[1dea7af3] OrdinaryDiffEq v6.95.1

Julia & platform info

Julia Version 1.11.5
Commit 760b2e5b73 (2025-04-14 06:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 12 × 13th Gen Intel(R) Core(TM) i5-1335U
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, goldmont)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)

Open an issue on OrdinaryDiffEq.jl and we’ll look into this in some detail. Looks like a bug where there’s a spot that isn’t robust to backwards integration.

Thank you for your answer. Done in the issue #2691.