Skip to content

Add pagination to list_sessions#229

Merged
jackwildman merged 1 commit intomainfrom
session-list-pagination
Feb 25, 2026
Merged

Add pagination to list_sessions#229
jackwildman merged 1 commit intomainfrom
session-list-pagination

Conversation

@jackwildman
Copy link
Contributor

Summary

  • SDK: New SessionListResult dataclass with total/offset/limit fields
  • Generated API client: offset/limit query params on list_sessions endpoint
  • MCP server: ListSessionsInput model for pagination params, output shows page info
  • All function signatures updated with offset: int = 0, limit: int = 25 defaults

Test plan

  • SDK tests pass (uv run pytest tests/test_session.py)
  • MCP tests pass (uv run pytest everyrow-mcp/tests/test_server.py)
  • Pyright type check clean
  • Integration test against deployed API

🤖 Generated with Claude Code

Comment on lines +63 to +65
total = d.pop("total")
offset = d.pop("offset")
limit = d.pop("limit")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The from_dict method uses d.pop() for new pagination fields, which will raise a KeyError if the API response is from an older backend version, causing a crash.
Severity: CRITICAL

Suggested Fix

Replace d.pop("key") with d.get("key", default_value) for the total, offset, and limit fields to provide graceful degradation and maintain backwards-compatibility with older API responses that do not include these fields. This prevents KeyError crashes.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/everyrow/generated/models/session_list_response.py#L63-L65

Potential issue: The `SessionListResponse.from_dict()` method uses `d.pop()` to extract
the `total`, `offset`, and `limit` fields from the API response. If the SDK is deployed
before the backend API is updated to include these new pagination fields, or if it
receives a response from an older, cached, or partially-deployed backend, the call will
fail with a `KeyError`. This breaks backwards-compatibility and will cause a runtime
crash when calling the `list_sessions()` endpoint.

Did we get this right? 👍 / 👎 to inform future reviews.

@jackwildman jackwildman force-pushed the session-list-pagination branch 2 times, most recently from 40d4e47 to 4c241e3 Compare February 25, 2026 16:31
Add offset/limit pagination support:
- SDK: new SessionListResult with total/offset/limit fields
- Generated API: offset/limit query params on list_sessions endpoint
- MCP server: ListSessionsInput model, pagination display in output
- Tests: updated and new pagination tests for SDK and MCP

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jackwildman jackwildman force-pushed the session-list-pagination branch from 4c241e3 to d8de3bb Compare February 25, 2026 17:06
@jackwildman jackwildman merged commit 868c41c into main Feb 25, 2026
5 checks passed
@jackwildman jackwildman deleted the session-list-pagination branch February 25, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant