Skip to content

docs(ai-monitoring): Document the sort param on AI conversations - #130350

Merged
BYK merged 1 commit into
masterfrom
docs/ai-conversations-sort-param
Nov 7, 2026
Merged

BYK merged 1 commit into
masterfrom
docs/ai-conversations-sort-param

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

GET /organizations/{org}/agents/conversations/ (listOrganizationAIConversations) accepts a sort query param. OrganizationAIConversationsSerializer validates it against AI_CONVERSATIONS_FIELDS, and it defaults to -conversation.age, but the OpenAPI docs didn't list it. This adds the parameter with an enum of the canonical fields, each with an optional - prefix. Only this operation changes in the generated schema, and there's no runtime change.

The enum comes from a new AI_CONVERSATIONS_SORT_FIELDS tuple. It takes the keys of AI_CONVERSATIONS_FIELDS before the legacy spellings are added, so messages, the bare field names and the function aliases stay accepted but undocumented.

The Sentry CLI's agent-conversation list --sort needs this to move onto the generated @sentry/api operation (getsentry/toolkit#2073). The generated query type has no sort today.

Checked locally with make build-api-docs, pnpm run validate-api-examples, tests/sentry/api/endpoints/test_organization_ai_conversations.py, tests/apidocs, prek and mypy.

via @BYK.

--

View Session [Sentry]

The AI conversations list endpoint accepts a sort query parameter,
validated against AI_CONVERSATIONS_FIELDS, with a default of
-conversation.age. The OpenAPI docs didn't list it.

Document it with an enum of the canonical sort fields, each with an
optional - prefix. The legacy spellings the endpoint still accepts while
the frontend and backend deploy independently stay undocumented.

Refs getsentry/toolkit#2073

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot requested a review from a team as a code owner November 7, 2026 01:22
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 7, 2026
@BYK
BYK merged commit a205501 into master Nov 7, 2026
80 of 81 checks passed
@BYK
BYK deleted the docs/ai-conversations-sort-param branch November 7, 2026 01:30
BYK added a commit to getsentry/toolkit that referenced this pull request Nov 7, 2026
Stacked on #2073. That PR moves the CLI onto the generated `@sentry/api`
operations. This one fixes the cases where the CLI, not the API docs,
was wrong. The full list is in getsentry/sentry#130351. Where the 1.44.0
operation now matches, the call moves onto it here too.

Each fix was checked against the getsentry/sentry endpoint code.

### Moved onto generated operations
| Area | Fix | Operation |
| --- | --- | --- |
| `alert issues list/view` | Filter workflows by `project` (the endpoint
ignores `projectSlug`) and send `id` as a number |
`listOrganizationWorkflows` (×2) |
| `code-mappings upload` | Send the bulk body in snake_case:
`default_branch`, `stack_root`, `source_root` |
`bulkUpsertOrganizationCodeMappings` |
| `explore`, `dashboard view` tables | Type `dataset` as a public Events
dataset. Explore still falls back to `errors`, and unmapped widget types
still render as unsupported | `listOrganizationEvents` (×2) |
| `issue view` and other org-scoped issue lookups | Send only the
`collapse` values the details endpoint reads (`release`, `stats`,
`tags`). It ignored `lifetime`/`filtered`/`unhandled`, and the detail
response keeps those fields either way. The short-ID endpoint still gets
every value | `getOrganizationIssue` |
| `issue view` replay lookup | Send `data_source=errors`. `events` isn't
a value the endpoint accepts | `getOrganizationReplayCount` |
| `issue explain/plan` | Drop `mode=explorer`, which the autofix
endpoint never reads | `startOrganizationIssueAutofix` (×2),
`getOrganizationIssueAutofixState` |

### Fixed, but still on the helper
- **`issue merge`**: now sends `{merge: true}` with numeric IDs.
`updateOrganizationIssues` marks every body field required until
getsentry/sentry#130348 lands.
- **`trace view`**: no longer sends `project` or `limit`, since the
endpoint reads neither. It stays on the helper until
getsentry/sentry#130349 documents `timestamp`. An unknown project in
`trace view org/project/<id>` still fails as before.
- **Dashboard and explore time series**: get the same typed `dataset`,
but stay on the helper until #130349 fixes `yAxis`/`interval`.
- **AI conversations list**: untouched, because it's waiting on
getsentry/sentry#130350 (`sort`).

### Kept on purpose
- **`replay list`** keeps requesting `info_ids` and `warning_ids`. The
server computes them and `replay list --json` prints them, so dropping
them would change the output. `fetchReplayPage` stays on the helper, and
a comment says why.

### Behavior notes
- On the moved calls, errors use the SDK wording already used by the
moved calls in #2073 and by the metric alert path, e.g. `Failed to list
issue alert rules: 403 Forbidden`. They no longer start with `API
request failed:`, and they no longer have an `Endpoint:` line. Status
codes and the 401/403 enrichment are unchanged.
- Existing bug, not fixed here: `trace view org/project/<id>` prints
"Filtered to project", but the trace endpoint has returned spans from
every project since getsentry/sentry#87314.
- Docs gap: with `returnIds=true`, the replay-count response maps each
issue ID to a list of replay IDs. The documented schema describes
counts. The CLI keeps validating that response with its own schema.

### Verification
- `pnpm run tsc` and `pnpm run lint` pass.
- CLI tests: 12884 pass and 5 fail. All 5 are the sandbox-only
permission tests that fail on `main` too (`completions` ×2, `upgrade`
acquireLock, `db/resilient` readonly, `dsn/code-scanner`).
- Unit tests were updated or added for each changed request shape,
including the new `test/lib/api/code-mappings.test.ts`.
- API discovery no longer lists the moved call sites.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A80220b9d4c297e2a971f05dcb03af515 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A80220b9d4c297e2a971f05dcb03af515)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A80220b9d4c297e2a971f05dcb03af515/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant