Skip to content

ClientSessionGroup silently omits later pages of tools, resources, and prompts #3792

Open

Description

@namtran1812

Problem

ClientSessionGroup._aggregate_components() calls each list_*() method once and ignores next_cursor. When a server paginates its catalog, the group registers only the first page.

This leaves later-page tools unavailable through group.call_tool(), even though the connected server exposes them.

Reproduction

Use an in-process server whose tools listing returns:

  1. Tool first, with next_cursor="page-2".
  2. Tool second, with no continuation cursor.

Connect its session using group.connect_with_session(...).

Observed: group.tools contains only first, and the server receives one listing request.

Expected: the group follows the cursor and registers both tools. Resources and prompts have the same single-page aggregation behavior.

Reproduced on main at d7845c07.

Proposed fix

Drain pagination within group aggregation while preserving naming hooks, ownership routing, and collision checks.

Stage the complete catalog before registering components, so a continuation-page failure does not publish a partial catalog. Detect repeated cursors to avoid an endless listing loop, and treat cursor values as opaque—including an empty string.

This is narrower than #2556’s proposal for new public list_all_* helpers: it fixes the existing group’s aggregation behavior without adding a public API.

Validation

A proposed implementation is available on:
https://github.com/namtran1812/python-sdk/tree/fix/session-group-pagination

Added 10 regression cases covering complete discovery, later-page tool routing, naming hooks, disconnect cleanup, continuation-page failures, cursor cycles, collisions, and empty pages.

  • macOS: all 22 session-group tests passed; Ruff, formatting, and Pyright passed.
  • Linux: 6,236 tests passed, 8 skipped, 1 xfailed; 100% coverage and strict coverage checks passed.

Would this group-specific pagination fix be an acceptable contribution?

AI assistance

AI assistance was used for investigation, implementation, and testing. I ran the focused tests and static checks locally on macOS.

Activity

  1. added
    bugSomething isn't working
    v1Affects the v1.x maintenance line
    v2Affects the v2 line (2.x on main)
    on Oct 31, 2026
  2. techaurah commented on Nov 1, 2026

    @techaurah

    Hi, we are TechAurah. We would like to work on this if a maintainer is willing to assign it to us.

    Our read of the problem: ClientSessionGroup fetches only the first page when listing each server's tools, resources, and prompts, so components behind a nextCursor are never registered and cannot be called through the group. The fix drains each catalog by following cursors until none remains, for all three component types, before registration.

    We noticed the earlier attempt (#3793) was auto-closed because the author was not assigned to this issue, which is why we are asking here first. We will include pagination tests with multi-page fake servers for tools, resources, and prompts.

    Happy to adjust the approach if the maintainers prefer a different shape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingv1Affects the v1.x maintenance linev2Affects the v2 line (2.x on main)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions