pager___asyncpager

pager___asyncpager is a cursor rule for Cursor from altaidevorg/rules-for-ai. It costs 0 tokens per session (4,034 once invoked), scanned A, original, MIT.

A helper for reading every item from an API list that arrives in separate pages. It handles the token used to request the next page, including for asynchronous code.

In plain words
What is it for?
Use it when processing paginated lists such as available models, uploaded files, or tuning jobs in the Google GenAI SDK.
Why use it?
It removes the repeated code needed to pass page tokens and stop when the list is complete.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/altaidevorg/rules-for-ai/pager___asyncpager
Clone the repo
git clone --depth 1 https://github.com/altaidevorg/rules-for-ai

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pager___asyncpager

README.md
[![agentmods](https://agentmods.dev/badge/rules/altaidevorg/rules-for-ai/pager___asyncpager.svg)](https://agentmods.dev/rules/altaidevorg/rules-for-ai/pager___asyncpager)
Your own site
<a href="https://agentmods.dev/rules/altaidevorg/rules-for-ai/pager___asyncpager"><img src="https://agentmods.dev/badge/rules/altaidevorg/rules-for-ai/pager___asyncpager.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 4,034 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.04034
Opus 5 $0.00000 $0.02017
Sonnet 5 $0.00000 $0.00807
Haiku 4.5 $0.00000 $0.00403

Measured 5d ago against content hash 01d81492f9ec, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

pager___asyncpager scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

examples/google-genai/pager___asyncpager.mdc · 299 lines

How it starts

The opening of the file, as written. The whole thing — 299 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Chapter 6: Pager / AsyncPager

In Chapter 5: Function Calling Utilities, we explored how the SDK facilitates interactions with external tools. Now, let's turn our attention to another common API interaction pattern: handling large lists of results that the API returns in chunks, or pages. This chapter introduces the Pager and AsyncPager classes, which abstract the complexities of pagination.

Motivation and Use Case

When you request a list of resources from an API (like available models using models.list, uploaded files using files.list, or tuning jobs using tunings.list), the total number of items might be very large. Returning the entire list in a single response could be inefficient or even infeasible due to size limits.

To handle this, APIs often implement pagination. The API returns a manageable subset of the list (a page) along with a next_page_token. To get the next subset of results, you make another API request, including this token. This process repeats until all items have been retrieved (indicated by the absence of a next_page_token in the response).

Managing this token passing and repeated request cycle manually adds boilerplate code to your application. The Pager (for synchronous operations) and AsyncPager (for asynchronous operations) classes implement the Pager design pattern to hide this complexity. They act as iterators that automatically fetch subsequent pages when needed.

Central Use Case: You want to process all available generative models, potentially hundreds, without worrying about fetching page by page.

# Assuming 'client' is configured (e.g., using genai.Client(api_key=...))
from google import genai

# models.list() returns a Pager object
model_pager = client.models.list()

# Iterate directly over the pager
print("Processing all available models:")
count = 0
for model in model_pager:
    # The pager automatically fetches the next page when the current one is exhausted
    # We only print basic info here for brevity
    if "generateContent" in model.supported_generation_methods:
        print(f"- Found model: {model.name} ({model.display_name})")
        count += 1
print(f"\nTotal models processed: {count}")

# The pager transparently handled fetching multiple pages if necessary.

This example demonstrates how the Pager allows simple iteration over potentially large result sets without explicit pagination logic.

Read the full file on GitHub · 299 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 299 lines · 0 tokens per session scan A 01d81492f9ec

Subscribe to this mod's changes

pager___asyncpager is a cursor rule published in the GitHub repository altaidevorg/rules-for-ai (2 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 4,034 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.