{% if page_info.has_prev_page %}
{% set prev_args = request.args.to_dict() %}
{# FIX: Explicitly set direction to 'prev' #}
{% do prev_args.update({'last_id': page_info.prev_last_id, 'direction': 'prev'}) %}
Previous
{% endif %}
{% if page_info.has_next_page %}
{% set next_args = request.args.to_dict() %}
{# FIX: Explicitly set direction to 'next' #}
{% do next_args.update({'last_id': page_info.next_last_id, 'direction': 'next'}) %}
Next
{% endif %}