# List a session's compactions from AgentOS

> Agno AgentOS adds `GET /sessions/{session_id}/compactions`, which lists a session's compactions newest first with token counts before and after.

- Published: 2026-11-17
- Author: Anurag Sharma
- Categories: Changelog
- Canonical: https://www.agno.com/blog/list-a-sessions-compactions-from-agentos
- Markdown: https://www.agno.com/blog/list-a-sessions-compactions-from-agentos.md

Agno AgentOS can now list a session's compactions with `GET /sessions/{session_id}/compactions`, so a chat UI can keep showing how far a conversation was folded after the page reloads. A compaction is one fold made by an Agent's `compaction` setting, which archives the older messages of a long session behind a summary and keeps the last few runs word for word.

```python
agent = Agent(db=SqliteDb(db_file="agno.db"), compaction=True)
```

```bash
curl "http://localhost:7777/sessions/s1/compactions?type=agent"
```

The route returns every compaction of the session, newest first, with no pagination. Each item carries `id`, `run_id`, `messages_compacted`, `tokens_before`, `tokens_after`, `created_at` and `archived`, which says whether the replaced messages were stored and can be read back. The summary text and the archived messages stay out of the response. It takes the same optional `type`, `user_id`, `db_id` and `table` query parameters as the session runs route, answers 404 for a session that does not exist or that the caller's user cannot read, and needs the `sessions:read` scope when AgentOS authorization is on. `SqliteDb` and `PostgresDb` store compaction records; every other database returns an empty list. The Python `AgentOSClient` has no method for it yet, so call the route over HTTP.

We ran it on this release with a 12-run session in `SqliteDb` and the stub summarizer from the release's own tests in place of a model. The token counts come from Agno's real counter. `agent.compact()` folded the first 18 messages and kept the last three runs, and the route then reported the fold:

```text
Compacted 18 messages (15864 -> 3988 tokens).
GET /sessions/s1/compactions -> 200 [{"messages_compacted": 18, "tokens_before": 15864, "tokens_after": 3988, "archived": true, ...}]
```

![A session of 12 runs and 24 messages at 15,864 tokens folds into one summary of 18 messages plus the last 3 runs at 3,988 tokens, with the real output of GET /sessions/s1/compactions underneath](https://www.agno.com/images/v3-2-1-session-compactions.png)

See the [manual compaction cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/02_agents/03_context_management/compaction/compaction_manual.py), and learn more about [sessions](https://docs.agno.com/sessions/overview) and [AgentOS scopes](https://docs.agno.com/agent-os/security/overview) in the documentation.
