# Load long session histories one page of runs at a time

> Agno AgentOS pages GET /sessions/{session_id}/runs when you pass limit, using run_index cursors. Calls without limit still return every run.

- Published: 2026-11-12
- Author: Yash Pratap Solanky
- Categories: Changelog
- Canonical: https://www.agno.com/blog/load-long-session-histories-one-page-of-runs-at-a-time
- Markdown: https://www.agno.com/blog/load-long-session-histories-one-page-of-runs-at-a-time.md

Agno AgentOS now pages `GET /sessions/{session_id}/runs` when you pass `limit`, so a chat UI can open a long session by loading only its newest runs. Before, the UI had to pull every run before it could show the last message. The `before_run_index` and `after_run_index` cursors step back or forward from there.

```text
GET /sessions/chat/runs?user_id=u1&limit=2
GET /sessions/chat/runs?user_id=u1&limit=2&before_run_index=4
```

On a session seeded with six runs, the first request returned the two newest and the second the two before them:

```text
data: run-4, run-5  meta: {"limit": 2, "total_count": 6, "has_more": true, "oldest_run_index": 4, "newest_run_index": 5}
data: run-2, run-3  meta: {"limit": 2, "total_count": 6, "has_more": true, "oldest_run_index": 2, "newest_run_index": 3}
```

Every run carries a `run_index`, its 0-based position in the whole session, and it stays the same on the list, page, preview and single-run endpoints. Take the next cursor from `meta`, since a cursor taken from `data[0]` can skip a run stored between a member and its parent.

A team session keeps each turn whole. With `limit=1`, the newest page held the member run `m2` and its team run `t2`, and `total_count` read 3 for three team turns.

This output comes from FastAPI's `TestClient` over the session router, with runs written to a local SQLite file.

See the [cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/05_agent_os/03_python_client/03_sessions_and_memory.py), and learn more about [sessions](https://docs.agno.com/sessions/overview) in the documentation.
