Skip to content

Feature request: add offset parameter to get_items() for real pagination #2810

@ecanlar

Description

@ecanlar

Feature Request

Problem

Currently, get_items(limit=N) only supports truncation — it returns the latest N items. There is no way to paginate through a session's history (e.g., "give me items 20-30"). This makes it impossible to efficiently browse or display conversation history in pages.

Proposed Solution

Add an offset parameter to get_items():

# Page 1: 10 most recent items
page1 = await session.get_items(limit=10, offset=0)

# Page 2: next 10 items
page2 = await session.get_items(limit=10, offset=10)

# Skip recent items, get the rest
older = await session.get_items(offset=5)

This is backward compatible — offset defaults to 0, preserving existing behavior.

Motivation

  • Building chat UIs with "load more" or infinite scroll
  • Exporting conversation history in batches
  • Analyzing specific portions of a session without loading the entire history
  • Consistent with standard database pagination patterns (LIMIT/OFFSET)

The existing limit parameter already implies the need for pagination but only provides half the mechanism.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions