Freeze Cursor Pagination Contracts Before AI Agents Write List Clients
Coding agents frequently default to offset-based pagination patterns when generating list clients, even when an API uses opaque cursor pagination, leading to bugs that pass local tests but fail in staging. A recommended practice is to freeze a contract file and a golden response fixture in the repository before any client code is generated, ensuring the agent cannot rewrite the source of truth without breaking CI. The contract specifies forbidden query keys such as page, offset, and per_page, and enforces that next_cursor must always be treated as an opaque string or null, never parsed as JSON. A failing contract test acts as a gatekeeping mechanism, catching pagination drift before the client file even exists. The approach is intentionally minimal and repository-agnostic, designed to prevent agents from applying generic CRUD assumptions to APIs with strict pagination rules.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in