API pagination contracts are fragile. A cursor format change, a page size default shift, or a total count that stops being accurate will silently break every client that depends on predictable pagination behavior. This prompt detects drift between two API versions by comparing pagination metadata, cursor structures, link headers, and count semantics. Use it when you are reviewing an API spec diff, validating a new deployment against a published contract, or building a CI gate that rejects pagination contract violations before they reach production.
Prompt
Pagination Contract Drift Detection Prompt

When to Use This Prompt
Identifies the specific scenarios, required inputs, and boundaries for using the pagination contract drift detection prompt.
The prompt expects structured input describing the pagination contract for both versions—including cursor formats, page size defaults, total count availability, link header structures, and any version-specific pagination parameters. You must provide this as a side-by-side comparison object with fields for cursor_structure, page_size_behavior, count_semantics, link_header_format, and pagination_parameters. The output is a drift report with client-breaking change flags, severity ratings (BREAKING, COMPATIBLE, DEPRECATION), and migration notes. This is not a general API diff tool—it focuses exclusively on pagination behavior and will miss non-pagination breaking changes like field removals or type narrowing.
Do not use this prompt when you need a full API compatibility assessment, when pagination is handled entirely client-side with no server contract, or when you lack structured pagination metadata from both versions. The prompt cannot infer pagination behavior from raw HTTP response bodies alone—you must extract and structure the pagination contract first. For high-risk production gates, always pair the prompt output with automated contract tests that verify cursor stability, page size consistency, and count accuracy against live endpoints before allowing a deployment to proceed.
Use Case Fit
Where the Pagination Contract Drift Detection Prompt delivers reliable value and where it introduces unacceptable risk.
Good Fit: Automated CI/CD Contract Checks
Use when: You run automated API compatibility checks in CI/CD and need to catch pagination-specific regressions (cursor format changes, default page size shifts, link header inconsistencies) that generic schema diff tools miss. Guardrail: Run this prompt alongside standard OpenAPI diff tools, not as a replacement. Pagination drift is a subset of contract drift.
Good Fit: Multi-Version API Surface Monitoring
Use when: You maintain multiple API versions and need to detect when pagination behavior diverges between v1, v2, and beta endpoints in ways that break client pagination loops. Guardrail: Feed the prompt explicit version-to-version comparison pairs with known stable versions as baselines. Avoid comparing unstable canary builds against production.
Bad Fit: Real-Time Production Traffic Analysis
Avoid when: You need sub-second detection of pagination drift in live traffic. This prompt is designed for spec-to-spec or spec-to-sample comparison, not streaming response inspection. Guardrail: Use a lightweight response schema validator in the request path for real-time enforcement. Reserve this prompt for pre-release review and post-deployment audit.
Bad Fit: Undocumented or Ad-Hoc Pagination Schemes
Avoid when: The API uses non-standard, undocumented, or dynamically negotiated pagination mechanisms without a formal contract to compare against. The prompt requires a reference contract to detect drift. Guardrail: If no spec exists, first run a contract inference prompt to extract the observed pagination pattern from sample responses, then use that inferred contract as the baseline.
Required Inputs: Contract Spec and Sample Payloads
What you need: A reference pagination contract (OpenAPI pagination extension, JSON Schema for paginated responses, or a documented cursor format) plus representative response samples from the version under test. Without both, drift detection is guesswork. Guardrail: Validate that sample payloads actually match the endpoint version being tested. Mismatched samples produce false drift flags.
Operational Risk: False Positives on Intentional Changes
Risk: The prompt may flag intentional pagination improvements (e.g., switching from offset to cursor-based pagination) as breaking drift. Guardrail: Always pair drift detection output with a human review step for flagged changes. Require explicit approval before blocking a release on pagination drift findings. Log all drift flags with the reviewer's disposition for audit.
Copy-Ready Prompt Template
Paste this prompt into your AI harness to detect pagination contract drift between API versions.
The following prompt template is designed to compare two API specifications or response samples and identify pagination contract drift. It focuses on cursor format changes, page size default shifts, total count accuracy, and link header consistency—the four most common sources of client-breaking pagination failures. Replace every square-bracket placeholder with real values before execution. The prompt expects structured input and produces a structured drift report that can be parsed by downstream automation.
textYou are an API contract reviewer specializing in pagination behavior. Compare the pagination contracts in [SPEC_OR_SAMPLE_A] (version [VERSION_A]) and [SPEC_OR_SAMPLE_B] (version [VERSION_B]). Analyze these pagination dimensions: 1. Cursor format: encoding, structure, field names, and whether cursors are opaque or decodable. 2. Page size defaults: default limit, max limit, and whether the default changed. 3. Total count accuracy: presence of total, estimatedTotal, or count fields, and whether semantics shifted. 4. Link header consistency: rel values (next, prev, first, last), URI template changes, and header name changes. [CONSTRAINTS] - Flag a change as breaking if an existing client relying on [VERSION_A] behavior would fail without code changes. - Treat additive fields as non-breaking unless they change required client parsing logic. - If a field was optional and becomes required, flag as breaking. - If a field was required and becomes optional, flag as additive with a deprecation note. [OUTPUT_SCHEMA] Return a JSON object with this exact structure: { "drift_detected": boolean, "breaking_changes": [ { "dimension": "cursor_format" | "page_size_defaults" | "total_count_accuracy" | "link_header_consistency", "severity": "breaking" | "warning" | "info", "field_path": string, "version_a_value": string, "version_b_value": string, "client_impact": string, "migration_note": string } ], "additive_changes": [ /* same structure as breaking_changes */ ], "compatible_changes": [ /* same structure as breaking_changes */ ], "summary": string, "recommended_action": "block_release" | "require_client_migration" | "safe_to_proceed" | "manual_review_needed" } [EXAMPLES] Example breaking change: Input A: {"cursor": "eyJpZCI6MTIzfQ=="} (base64-encoded JSON) Input B: {"cursor": "123"} (raw integer) Output: severity=breaking, client_impact="All clients decoding base64 cursors will fail to parse raw integer cursors." Example non-breaking change: Input A: {"pageSize": 20} Input B: {"pageSize": 20, "maxPageSize": 100} Output: severity=info, client_impact="New maxPageSize field is additive; existing clients ignoring it are unaffected." [RISK_LEVEL] This is a HIGH-RISK review. Pagination contract breaks cause silent data loss, infinite loops, and client crashes. Flag all cursor encoding changes as breaking unless proven compatible.
After pasting this template, replace [SPEC_OR_SAMPLE_A] and [SPEC_OR_SAMPLE_B] with either full OpenAPI/JSON Schema documents, representative response payloads, or pagination configuration objects. The [VERSION_A] and [VERSION_B] placeholders should contain version identifiers that appear in your drift report for traceability. The [OUTPUT_SCHEMA] block defines the exact JSON structure your harness should validate against after the model responds. If your API uses pagination mechanisms beyond the four listed dimensions—such as offset-based pagination, keyset pagination, or custom Link header variants—extend the dimension list in the prompt and add corresponding fields to the output schema. Always run the output through a JSON schema validator before ingesting it into your CI pipeline or deployment gate.
For production use, pair this prompt with a validation step that checks: (1) the output is valid JSON matching the schema, (2) every breaking_changes entry has a non-empty client_impact and migration_note, and (3) the recommended_action field is one of the four enumerated values. If validation fails, retry once with the validation error appended to the prompt as additional context. If the retry also fails, escalate for human review rather than silently accepting a malformed drift report. Do not use this prompt as the sole gate for production deployments—always combine it with contract tests that exercise actual client pagination loops against the new API version.
Prompt Variables
Inputs the Pagination Contract Drift Detection Prompt needs to produce a reliable drift report. Each placeholder must be populated before the prompt is sent. Validation notes describe how to check the input before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[CURRENT_API_SPEC] | The reference OpenAPI or JSON Schema definition for the paginated endpoint as it is expected to behave now. | openapi: paths./users.get.parameters[?(@.name=='cursor')] | Schema parse check: must be valid OpenAPI 3.x or JSON Schema. Required. Reject if spec fails to parse. |
[PREVIOUS_API_SPEC] | The prior version of the same endpoint spec to compare against for drift detection. | openapi: paths./users.get.parameters (version from tag v2.3.0) | Schema parse check: must be valid and structurally comparable to [CURRENT_API_SPEC]. Required. Reject if version labels are missing. |
[PRODUCTION_RESPONSE_SAMPLE] | A recent, anonymized production response payload from the endpoint under review. | {"data": [...], "pagination": {"cursor": "abc123", "has_more": true}} | JSON parse check: must be a valid JSON object. Required. Reject if empty or not a JSON object. Null allowed if endpoint is unreleased. |
[PAGINATION_STANDARD] | The organization's pagination contract standard to enforce (e.g., cursor format, envelope shape, link header rules). | Company API Standard v2.1: Cursor-based pagination with RFC 5988 Link headers. | Free text or structured policy document. Required. Reject if empty. Human review required if standard is ambiguous. |
[CLIENT_IMPACT_CONTEXT] | List of known client SDKs, internal services, or external integrations that consume this endpoint. | ["mobile-app-v3", "web-dashboard", "partner-api-gateway"] | JSON array of strings. Optional. Null allowed. If provided, each entry must be a non-empty string. Used to flag client-breaking changes. |
[DRIFT_THRESHOLD_CONFIG] | Severity thresholds for flagging drift: what counts as breaking, warning, or informational. | {"breaking": ["cursor_format_change", "total_count_removal"], "warning": ["page_size_default_change"]} | JSON object. Required. Keys must match known drift categories. Reject if categories are unrecognized. Default to strict if not provided. |
Implementation Harness Notes
How to wire the Pagination Contract Drift Detection Prompt into a CI/CD pipeline or monitoring system with validation, retries, and alert routing.
This prompt is designed to run as a scheduled or event-driven comparison step inside an API monitoring pipeline, not as a one-off chat interaction. The typical trigger is a new OpenAPI spec version, a detected change in a /.well-known endpoint, or a periodic crawl of live API responses. The harness should fetch the current contract (spec file or observed response schema) and the previous known-good contract, then pass both into the prompt as [CURRENT_CONTRACT] and [PREVIOUS_CONTRACT]. The prompt expects structured contract representations—ideally normalized JSON excerpts containing pagination-relevant fields: cursor formats, page size defaults, total count presence, link header structures, and next/prev token shapes. Do not pass raw HTTP response bodies without first extracting the pagination layer; the model needs the contract, not the payload.
Validation and retry logic is critical because this prompt outputs a structured drift report that downstream systems consume automatically. Implement a JSON schema validator on the output to confirm the presence of required fields: drift_detected (boolean), breaking_changes (array of objects with field, previous_value, current_value, client_impact), and recommendation (enum: no_action, notify_consumers, block_release). If validation fails, retry once with a repair prompt that includes the validation error and the raw output. If the retry also fails, escalate to a human reviewer via the on-call channel and log the failure for prompt improvement. For high-reliability pipelines, run the prompt against three model variants (e.g., GPT-4o, Claude 3.5 Sonnet, Gemini 1.5 Pro) and require at least two agreeing on breaking_changes before auto-blocking a release.
Model choice and latency budget depend on where this sits in your pipeline. For pre-merge CI checks where latency under 30 seconds is acceptable, use a frontier model with strong structured output support (GPT-4o with response_format or Claude with tool-use mode). For continuous monitoring of production endpoints where you're scanning dozens of APIs hourly, consider a smaller, fine-tuned model or a cached prompt prefix to reduce cost and latency. Always log the full prompt input, output, and validation result to your observability platform (Datadog, Grafana, or custom trace store) with the API version and timestamp as trace attributes. This makes drift decisions auditable and lets you replay historical comparisons when the prompt template changes.
Alert routing should map to the recommendation field. block_release findings must page the API platform on-call immediately and block the CD pipeline if integrated. notify_consumers findings should create a ticket in the developer relations queue with the full drift report attached. no_action findings can be logged silently. Before deploying this prompt to production, build a golden test set of at least 20 known contract pairs covering: cursor format changes (e.g., base64 to UUID), page size default shifts, total count removal, link header rel changes, and intentional non-breaking additions. Run these through the harness weekly as a regression gate. The most common failure mode is false positives on additive changes—tune the prompt's [CONSTRAINTS] block to explicitly distinguish additive from breaking pagination changes, and add counterexamples to your few-shot set for each false positive discovered in production.
Expected Output Contract
Fields, types, and validation rules for the pagination drift detection report. Use this contract to parse, validate, and store the model output before surfacing findings to API reliability dashboards or alerting systems.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
drift_report_id | string (UUID v4) | Must match UUID v4 regex. Generate if absent. | |
api_version_pair | object | Must contain from_version and to_version strings matching semver or date pattern. Parse check: both fields non-empty. | |
cursor_format_drift | object | Must contain status (string enum: stable, modified, broken) and details (string). If status is modified or broken, details must be non-empty. | |
page_size_default_drift | object | Must contain previous_default (integer), current_default (integer), and changed (boolean). changed must be true iff previous_default != current_default. | |
total_count_accuracy_drift | object | Must contain previous_behavior (string), current_behavior (string), and accuracy_change (string enum: none, improved, degraded). If degraded, a severity field must be present. | |
link_header_consistency_drift | object | Must contain rel_fields_checked (array of strings) and violations (array of objects with rel, expected_pattern, actual_pattern). violations may be empty array. | |
client_breaking_changes | array | Each item must have change_type (string), affected_field (string), severity (string enum: breaking, warning), and client_impact_description (string). Array may be empty. If non-empty, at least one item must have severity breaking. | |
overall_drift_verdict | string | Must be one of: no_drift, compatible_change, breaking_change_detected. Must be consistent with presence of severity breaking items in client_breaking_changes. |
Common Failure Modes
Pagination contract drift is subtle and breaks clients silently. These failures surface most often in production when API consumers rely on undocumented pagination behavior. Each card identifies a specific failure pattern and the guardrail that catches it before deployment.
Cursor Format Drift Goes Undetected
What to watch: The model flags a cursor encoding change as cosmetic when it actually breaks client-side cursor parsing. Base64-to-plaintext shifts, field reordering inside opaque cursors, or timestamp precision changes all cause silent client failures. Guardrail: Require the prompt to compare cursor decode output between versions, not just surface format. Add a test case where cursor format changes produce a BREAKING severity flag regardless of encoding rationale.
Page Size Default Change Missed as Non-Breaking
What to watch: When an API changes the default page size from 20 to 50, the model classifies it as additive or cosmetic. Clients with hardcoded pagination loops, rate limit assumptions, or memory budgets break. Guardrail: Configure the prompt's severity rules to treat any default value change—page size, sort order, or max limit—as a client-impacting change requiring explicit migration notes in the output.
Total Count Accuracy Regression Flagged Late
What to watch: The model only compares schema fields and misses that the total_count field now returns an estimate instead of an exact count. Clients using total count for progress bars or batch planning produce incorrect results. Guardrail: Add a semantic behavior check in the prompt that requires comparing field descriptions, annotations, and any x- vendor extensions for semantic changes—not just type presence. Include a test where total_count changes from integer to integer with a description change from "exact" to "approximate."
Link Header Parsing Inconsistency Across Versions
What to watch: The API changes Link header rel values from next/prev to next_page/previous_page or switches from RFC 5988 format to a custom envelope. The model treats this as a documentation update rather than a client-breaking protocol change. Guardrail: Include a Link header structure comparison rule in the prompt that validates rel value stability, URI template parameter consistency, and header presence. Add an eval case where any rel value rename triggers a BREAKING flag.
Empty Page Representation Ambiguity
What to watch: The model doesn't flag when the API changes how it represents empty result sets—switching from null items to empty array [], or from a 200 with empty body to a 404. Clients with null-safety checks or status-code-based pagination termination logic break silently. Guardrail: Add a contract-level rule requiring the prompt to compare empty-result representations across versions and flag any change in status code, body shape, or nullability as a client-breaking change. Test with a diff where items: null becomes items: [].
Pagination Parameter Rename Without Deprecation Window
What to watch: The API renames cursor to page_cursor or limit to page_size without a deprecation period. The model classifies this as a minor parameter addition because the old parameter still exists in the spec but is now ignored by the server. Guardrail: Configure the prompt to detect parameter renames by comparing parameter semantics and deprecation annotations, not just presence. Require a DEPRECATION severity flag when a new parameter duplicates an existing parameter's function without the old one being marked deprecated.
Evaluation Rubric
Use this rubric to test the Pagination Contract Drift Detection Prompt before production deployment. Each criterion targets a specific failure mode observed in API contract analysis. Run these tests against a golden dataset of known API version pairs with labeled drift outcomes.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Cursor Format Drift Detection | Identifies all cursor format changes (e.g., offset-to-cursor, opaque-to-timestamp) with correct severity classification | Misses cursor format change when field name stays same but value encoding changes; classifies breaking change as informational | Run against 5 version pairs with known cursor format changes; verify 100% recall and correct severity labeling |
Page Size Default Change Flagging | Flags any change to default page size, max page size, or absence of page size parameter with client impact note | Reports no change when default page size shifts from 20 to 50; fails to note that missing page_size param now behaves differently | Test with spec pairs where only page size defaults changed; verify flag appears with 'client-breaking' severity |
Total Count Accuracy Assessment | Correctly identifies when total count becomes estimated, approximate, or removed; distinguishes from count still being exact | Labels exact count as estimated because response field description changed wording; misses count removal when field is deprecated but still present | Use 3 pairs with count semantics changes (exact-to-estimate, exact-to-removed, no-change); verify correct classification in all 3 |
Link Header Consistency Check | Detects missing, renamed, or reordered link relation types; flags new required link headers as additive change | Misses that 'prev' link was removed while 'next' remains; classifies new mandatory 'first' link as informational instead of additive | Test with spec pairs containing link header additions, removals, and renames; verify each change type is correctly categorized |
False Positive Rate on Non-Pagination Changes | Does not flag pagination drift for changes unrelated to pagination (e.g., new response fields, auth header changes) | Reports pagination drift when a new data field is added to response body; confuses rate-limit header changes with pagination changes | Feed spec diffs with only non-pagination changes; verify zero pagination drift flags in output |
Multi-Version Drift Accumulation Detection | When given 3+ sequential versions, identifies cumulative drift that single-version comparison would miss | Reports no breaking change across v1-to-v3 when v1-to-v2 and v2-to-v3 each had additive changes that together break clients; only compares adjacent versions | Provide 3-version chain where v1-to-v3 is breaking but each step is additive; verify cumulative breaking change is flagged |
Output Schema Compliance | Output matches [OUTPUT_SCHEMA] exactly: all required fields present, severity values from allowed enum, affected_endpoints list non-empty when drift found | Missing 'recommended_client_action' field; severity value 'warning' not in allowed enum ['breaking', 'additive', 'informational']; empty affected_endpoints when drift detected | Validate output against JSON Schema; run 10 test cases and verify 100% schema compliance |
Confidence Calibration on Ambiguous Changes | Assigns confidence score below 0.8 when drift determination is ambiguous; includes 'requires_human_review: true' for low-confidence findings | Assigns 0.95 confidence to ambiguous cursor format change; never sets requires_human_review flag even when evidence is conflicting | Test with deliberately ambiguous spec diffs (partial documentation, undocumented behavior); verify confidence < 0.8 and review flag set |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a single API spec version and a small set of known pagination patterns. Drop the structured output schema initially and ask for a plain-text drift summary. Replace [OUTPUT_SCHEMA] with a simple instruction: "List any pagination differences you find."
Prompt snippet
codeAnalyze the pagination behavior across these API versions: [SPEC_V1] and [SPEC_V2]. Focus on cursor format, page size defaults, total count accuracy, and link header consistency. List any differences you find.
Watch for
- The model inventing drift where none exists because it expects changes
- Missing link header analysis when the spec buries pagination in extension fields
- Overly verbose output that buries the signal

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us