function step_accept_controller!(
        integrator, ccache::PredictiveControllerCache, alg::AdaptiveRadau, q
    )
    (; controller) = ccache
    (; qmin, qmax, gamma, qsteady_min, qsteady_max) = controller.basic
    qmax = get_current_qmax(integrator, qmax)
    (; cache) = integrator
    (; num_stages, step, iter, hist_iter, index) = cache

    EEst = value(OrdinaryDiffEqCore.get_EEst(integrator))

    if integrator.success_iter > 0
        expo = 1 / (get_current_adaptive_order(alg, cache) + 1)
        qgus = (ccache.dtacc / integrator.dt) *
            fastpower((EEst^2) / ccache.erracc, expo)
        qgus = max(inv(qmax), min(inv(qmin), qgus / gamma))
        qacc = max(q, qgus)
    else
        qacc = q
    end
    if qsteady_min <= qacc <= qsteady_max
        qacc = one(qacc)
    end
    cache.step = step + 1
    hist_iter = hist_iter * 0.8 + iter * 0.2
    cache.hist_iter = hist_iter
    max_stages = (alg.max_order - 1) ÷ 4 * 2 + 1
    min_stages = (alg.min_order - 1) ÷ 4 * 2 + 1
    if (step > 10)
        if (hist_iter < 2.6 && num_stages < max_stages)
            cache.num_stages += 2
            cache.index += 1
            cache.step = 1
            cache.hist_iter = iter
        elseif (
                (
                    hist_iter > 8 || cache.status == VerySlowConvergence ||
                        cache.status == Divergence
                ) && num_stages > min_stages
            )
            cache.num_stages -= 2
            cache.index -= 1
            cache.step = 1
            cache.hist_iter = iter
        end
    end
    ccache.dtacc = integrator.dt
    ccache.erracc = max(1.0e-2, EEst)
    if controller.basic.discontinuity_detection && integrator.is_disco_step
        integrator.is_disco_step = false
        return min((integrator.disco_checkpoint - integrator.t) / 4, integrator.dt / qacc)
    end
    return integrator.dt / qacc
end

function step_reject_controller!(
        integrator, ccache::PredictiveControllerCache, alg::AdaptiveRadau
    )
    (; controller) = ccache
    (; discontinuity_detection) = controller.basic
    (; dt, success_iter, cache) = integrator
    (; num_stages, step, iter, hist_iter) = cache
    integrator.dt = success_iter == 0 ? 0.1 * dt : dt / ccache.qold
    cache.step = step + 1
    hist_iter = hist_iter * 0.8 + iter * 0.2
    cache.hist_iter = hist_iter
    min_stages = (alg.min_order - 1) ÷ 4 * 2 + 1

    if (discontinuity_detection)
        disco_dt = set_discontinuity(integrator)
        if disco_dt > zero(dt)
            integrator.dt = disco_dt
        end
    end

    return if (step > 10)
        if (
                (
                    hist_iter > 8 || cache.status == VerySlowConvergence ||
                        cache.status == Divergence
                ) && num_stages > min_stages
            )
            cache.num_stages -= 2
            cache.index -= 1
            cache.step = 1
            cache.hist_iter = iter
        end
    end
end
