Repository navigation
feat(agent-conversation): Show aggregate metrics and costs - #1458
Merged
Merged
Conversation
Preserve detail stats through pagination and expose costs, call totals, errors, token totals, and trace IDs in conversation output. Refs TET-2959 Refs TET-2951 Co-Authored-By: GPT-5.6 Sol <agent@openai.com>
vgrozdanic
marked this pull request as ready for review
October 9, 2026 14:13
7 tasks done
joshuawayzwright
pushed a commit
to joshuawayzwright/sentry-mcp
that referenced
this pull request
Nov 16, 2026
…ination (getsentry#1458) ## Root Cause `listConversations` in `src/lib/api/conversations.ts` passed the user's `limit` directly as `per_page` without capping at `API_MAX_PER_PAGE` (100). The Sentry API silently caps `per_page` at 100, so users requesting more than 100 conversations got silently truncated results. Additionally, the function only fetched a single page — unlike all other list APIs (`listTransactions`, `listSpans`, `listReplays`, etc.) which use `autoPaginate()` for multi-page fetches. ## Reproduction 1. Run `sentry conversation list --limit 200` 2. The API receives `per_page=200`, silently caps at 100, and returns only 100 results 3. No further pages are fetched, so the user sees at most 100 conversations instead of 200 ## Fix - Cap `per_page` at `Math.min(limit, API_MAX_PER_PAGE)` - Use the `autoPaginate()` helper for multi-page fetches, matching the pattern used by `listTransactions`, `listSpans`, `listReplays`, and all other list APIs in the codebase - Extract the single-page fetch into a `fetchConversationsPage()` helper (same pattern as other API modules) <div><a href="https://cursor.com/agents/bc-6e0fdaa7-73f7-4608-be3a-1498a6cc73bd?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/automations/95624600-485e-4461-829e-6b76f086c473"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/view-automation-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/view-automation-light.png"><img alt="View Automation" width="141" height="28" src="https://cursor.com/assets/images/view-automation-dark.png"></picture></a> </div> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com> Co-authored-by: jared-outpost[bot] <jared-outpost[bot]@users.noreply.github.com>
joshuawayzwright
pushed a commit
to joshuawayzwright/sentry-mcp
that referenced
this pull request
Nov 16, 2026
…ination (getsentry#1458) ## Root Cause `listConversations` in `src/lib/api/conversations.ts` passed the user's `limit` directly as `per_page` without capping at `API_MAX_PER_PAGE` (100). The Sentry API silently caps `per_page` at 100, so users requesting more than 100 conversations got silently truncated results. Additionally, the function only fetched a single page — unlike all other list APIs (`listTransactions`, `listSpans`, `listReplays`, etc.) which use `autoPaginate()` for multi-page fetches. ## Reproduction 1. Run `sentry conversation list --limit 200` 2. The API receives `per_page=200`, silently caps at 100, and returns only 100 results 3. No further pages are fetched, so the user sees at most 100 conversations instead of 200 ## Fix - Cap `per_page` at `Math.min(limit, API_MAX_PER_PAGE)` - Use the `autoPaginate()` helper for multi-page fetches, matching the pattern used by `listTransactions`, `listSpans`, `listReplays`, and all other list APIs in the codebase - Extract the single-page fetch into a `fetchConversationsPage()` helper (same pattern as other API modules) <div><a href="https://cursor.com/agents/bc-6e0fdaa7-73f7-4608-be3a-1498a6cc73bd?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/automations/95624600-485e-4461-829e-6b76f086c473"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/view-automation-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/view-automation-light.png"><img alt="View Automation" width="141" height="28" src="https://cursor.com/assets/images/view-automation-dark.png"></picture></a> </div> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com> Co-authored-by: jared-outpost[bot] <jared-outpost[bot]@users.noreply.github.com>
joshuawayzwright
pushed a commit
to joshuawayzwright/sentry-mcp
that referenced
this pull request
Nov 16, 2026
…ination (getsentry#1458) ## Root Cause `listConversations` in `src/lib/api/conversations.ts` passed the user's `limit` directly as `per_page` without capping at `API_MAX_PER_PAGE` (100). The Sentry API silently caps `per_page` at 100, so users requesting more than 100 conversations got silently truncated results. Additionally, the function only fetched a single page — unlike all other list APIs (`listTransactions`, `listSpans`, `listReplays`, etc.) which use `autoPaginate()` for multi-page fetches. ## Reproduction 1. Run `sentry conversation list --limit 200` 2. The API receives `per_page=200`, silently caps at 100, and returns only 100 results 3. No further pages are fetched, so the user sees at most 100 conversations instead of 200 ## Fix - Cap `per_page` at `Math.min(limit, API_MAX_PER_PAGE)` - Use the `autoPaginate()` helper for multi-page fetches, matching the pattern used by `listTransactions`, `listSpans`, `listReplays`, and all other list APIs in the codebase - Extract the single-page fetch into a `fetchConversationsPage()` helper (same pattern as other API modules) <div><a href="https://cursor.com/agents/bc-6e0fdaa7-73f7-4608-be3a-1498a6cc73bd?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/automations/95624600-485e-4461-829e-6b76f086c473"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/view-automation-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/view-automation-light.png"><img alt="View Automation" width="141" height="28" src="https://cursor.com/assets/images/view-automation-dark.png"></picture></a> </div> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com> Co-authored-by: jared-outpost[bot] <jared-outpost[bot]@users.noreply.github.com>
joshuawayzwright
pushed a commit
to joshuawayzwright/sentry-mcp
that referenced
this pull request
Nov 16, 2026
…#1486) ## What Adds a small shared `paginate<T>()` helper in `packages/cli/src/lib/api/infrastructure.ts` and migrates the divergent list call sites onto it. Every list endpoint was hand-wiring the same two things and occasionally getting them wrong (see getsentry#1458, where `listConversations` passed raw `limit` as `per_page` and did a single fetch): ```ts const perPage = Math.min(limit ?? N, API_MAX_PER_PAGE); return autoPaginate((cursor) => fetchFooPage(..., perPage, cursor), limit, options.cursor); ``` `paginate()` centralizes the `per_page` cap and the `limit` + initial-cursor threading into `autoPaginate`, so call sites can't drift: ```ts const regionUrl = await resolveOrgRegion(orgSlug); return paginate(options, (perPage, cursor) => fetchConversationsPage(regionUrl, orgSlug, { ...options, cursor }, perPage) ); ``` ## Design note I intentionally did **not** build the `createPaginatedList(endpoint, schema)` factory from the issue. Each endpoint does bespoke query building (sort mapping, field arrays, project resolution, response unwrapping), so a generic endpoint/schema factory would fight those. Extracting only the bug-prone cap + autoPaginate wiring keeps every existing `fetch*Page` helper intact and avoids a `region.ts` ↔ `infrastructure.ts` import cycle (region resolution stays at the call site). ## Changes - `infrastructure.ts`: new exported `paginate<T>(options, fetchPage, defaultLimit = 10)`. - Migrated `listConversations` (default 10), `listReplays` (default 25), `listTransactions` (default 10), `listSpans` (default 10). - `fetch*Page` helpers unchanged — still usable for tests / one-off calls, per the issue's scope. ## Tests Added a focused `describe("paginate")` block in `test/lib/api/infrastructure.test.ts`: per_page cap at `API_MAX_PER_PAGE`, default-limit fallback, initial-cursor forwarding, literal-limit passthrough below the cap, and multi-page accumulation up to `limit`. `vitest run` on the affected suites: **131 passed** (`infrastructure`, `conversations`, `traces`, `replays`). Biome clean on the touched files. Pre-existing `tsc` errors from missing generated SDK/docs files are unrelated to this change. Fixes getsentry#1473 --------- Co-authored-by: jared-outpost[bot] <jared-outpost[bot]@users.noreply.github.com>
joshuawayzwright
pushed a commit
to joshuawayzwright/sentry-mcp
that referenced
this pull request
Nov 16, 2026
…#1486) ## What Adds a small shared `paginate<T>()` helper in `packages/cli/src/lib/api/infrastructure.ts` and migrates the divergent list call sites onto it. Every list endpoint was hand-wiring the same two things and occasionally getting them wrong (see getsentry#1458, where `listConversations` passed raw `limit` as `per_page` and did a single fetch): ```ts const perPage = Math.min(limit ?? N, API_MAX_PER_PAGE); return autoPaginate((cursor) => fetchFooPage(..., perPage, cursor), limit, options.cursor); ``` `paginate()` centralizes the `per_page` cap and the `limit` + initial-cursor threading into `autoPaginate`, so call sites can't drift: ```ts const regionUrl = await resolveOrgRegion(orgSlug); return paginate(options, (perPage, cursor) => fetchConversationsPage(regionUrl, orgSlug, { ...options, cursor }, perPage) ); ``` ## Design note I intentionally did **not** build the `createPaginatedList(endpoint, schema)` factory from the issue. Each endpoint does bespoke query building (sort mapping, field arrays, project resolution, response unwrapping), so a generic endpoint/schema factory would fight those. Extracting only the bug-prone cap + autoPaginate wiring keeps every existing `fetch*Page` helper intact and avoids a `region.ts` ↔ `infrastructure.ts` import cycle (region resolution stays at the call site). ## Changes - `infrastructure.ts`: new exported `paginate<T>(options, fetchPage, defaultLimit = 10)`. - Migrated `listConversations` (default 10), `listReplays` (default 25), `listTransactions` (default 10), `listSpans` (default 10). - `fetch*Page` helpers unchanged — still usable for tests / one-off calls, per the issue's scope. ## Tests Added a focused `describe("paginate")` block in `test/lib/api/infrastructure.test.ts`: per_page cap at `API_MAX_PER_PAGE`, default-limit fallback, initial-cursor forwarding, literal-limit passthrough below the cap, and multi-page accumulation up to `limit`. `vitest run` on the affected suites: **131 passed** (`infrastructure`, `conversations`, `traces`, `replays`). Biome clean on the touched files. Pre-existing `tsc` errors from missing generated SDK/docs files are unrelated to this change. Fixes getsentry#1473 --------- Co-authored-by: jared-outpost[bot] <jared-outpost[bot]@users.noreply.github.com>
joshuawayzwright
pushed a commit
to joshuawayzwright/sentry-mcp
that referenced
this pull request
Nov 16, 2026
…#1486) ## What Adds a small shared `paginate<T>()` helper in `packages/cli/src/lib/api/infrastructure.ts` and migrates the divergent list call sites onto it. Every list endpoint was hand-wiring the same two things and occasionally getting them wrong (see getsentry#1458, where `listConversations` passed raw `limit` as `per_page` and did a single fetch): ```ts const perPage = Math.min(limit ?? N, API_MAX_PER_PAGE); return autoPaginate((cursor) => fetchFooPage(..., perPage, cursor), limit, options.cursor); ``` `paginate()` centralizes the `per_page` cap and the `limit` + initial-cursor threading into `autoPaginate`, so call sites can't drift: ```ts const regionUrl = await resolveOrgRegion(orgSlug); return paginate(options, (perPage, cursor) => fetchConversationsPage(regionUrl, orgSlug, { ...options, cursor }, perPage) ); ``` ## Design note I intentionally did **not** build the `createPaginatedList(endpoint, schema)` factory from the issue. Each endpoint does bespoke query building (sort mapping, field arrays, project resolution, response unwrapping), so a generic endpoint/schema factory would fight those. Extracting only the bug-prone cap + autoPaginate wiring keeps every existing `fetch*Page` helper intact and avoids a `region.ts` ↔ `infrastructure.ts` import cycle (region resolution stays at the call site). ## Changes - `infrastructure.ts`: new exported `paginate<T>(options, fetchPage, defaultLimit = 10)`. - Migrated `listConversations` (default 10), `listReplays` (default 25), `listTransactions` (default 10), `listSpans` (default 10). - `fetch*Page` helpers unchanged — still usable for tests / one-off calls, per the issue's scope. ## Tests Added a focused `describe("paginate")` block in `test/lib/api/infrastructure.test.ts`: per_page cap at `API_MAX_PER_PAGE`, default-limit fallback, initial-cursor forwarding, literal-limit passthrough below the cap, and multi-page accumulation up to `limit`. `vitest run` on the affected suites: **131 passed** (`infrastructure`, `conversations`, `traces`, `replays`). Biome clean on the touched files. Pre-existing `tsc` errors from missing generated SDK/docs files are unrelated to this change. Fixes getsentry#1473 --------- Co-authored-by: jared-outpost[bot] <jared-outpost[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Conversation details now preserve server aggregate stats across pagination and expose cost, call totals, errors, token totals, and deduplicated trace IDs in JSON and human output. Conversation list output also shows cost.
Port of getsentry/cli#1662 after CLI moved into Toolkit.
Refs TET-2959
Refs TET-2951