Repository navigation
feat: add sentry conversation command group for inspecting AI agent transcripts - #1020
Conversation
|
|
Addressed both Warden findings in 3021223: GGA-VPD (absolute date ranges silently ignored): 5RV-D34 (Infinity timestamps on empty spans): Also consolidated the duplicate view formatter into AI-generated, verified against tsc and updated code. |
Codecov Results 📊✅ Patch coverage is 92.18%. Project has 4301 uncovered lines. Files with missing lines (2)
Generated by Codecov Action |
sentry ai-conversations command groupsentry conversation command group
|
Jared, get this PR into a mergeable state |
Adds `sentry conversation list` (paginated AI conversation listing) and `sentry conversation view [org] <conversation-id>` (full transcript with turns, messages, and tool calls), following existing CLI patterns (buildListCommand/buildCommand, bidirectional pagination, resolveOrg, domain formatter). Rebuilt on top of current main after the pnpm-workspace restructure moved the CLI under packages/cli/; the original feat/ai-conversations-command branch predated that migration and could no longer merge cleanly. New files: - src/commands/conversation/ (route map, list, view) - src/lib/api/conversations.ts (list + detail endpoints) - src/lib/formatters/conversation.ts (table + transcript parser) - src/types/conversation.ts (Zod schemas) Wired into app routes, api-client barrel, types barrel, and completions. Generated docs/skill files regenerated.
eb249d0 to
c7c9ff9
Compare
|
Got #1020 into a mergeable state. The branch was 254 commits behind Rebuilt the feature cleanly on top of current
Locally green: |
|
Jared, address all bot comments, review this PR in terms of our command standards for naming, help, documentation, output format consistency etc. and make any fixes you see necessary. Than ask me to review before merging. |
|
Jared, |
- Fix token double-count in buildTranscriptResult: sum tokens per turn (ai_client spans) instead of every span, so parent invoke_agent spans that aggregate child usage don't inflate the header total (Cursor Bugbot). - Route human output through the markdown pipeline: formatConversationTable uses formatTable/Column; formatTranscriptResult/formatTurnHuman use mdKvTable, markdown headings, escapeMarkdownCell/Inline, safeCodeSpan and renderMarkdown instead of hand-rolled padStart columns + raw sanitize(). - Use typed ContextError for missing org (list) and missing conversation-id (view) instead of bare throw new Error. - Add module-level JSDoc to src/types/conversation.ts. - Update tests for markdown-rendered output and typed errors.
|
@BYK ready for your review. Pushed Bot comments
Command-standards pass (against
Green locally: Two things I deliberately left as-is (flag me if you want them changed):
Not auto-merging — it's |
Use
See what |
- Register a hidden `conversations` route alias + PLURAL_TO_SINGULAR entry so `sentry conversations` runs `conversation list` and the singular is suggested, matching issues/replays/events (Cursor Bugbot). - collectMessages: fall back to `parts` (in addition to content/text) so `conversation view` renders text for spans that store message parts under a `parts` array instead of dropping them as empty turns (Cursor Bugbot). - conversation view: take a single `[<org>/]<conversation-id>` positional instead of two positionals; conversation IDs are org-scoped and never contain a slash, so org is parsed off the prefix and otherwise auto-detected. - conversation list: drop the Tools/Errs/User columns on terminals narrower than 100 cols so the core columns don't truncate aggressively, mirroring `issue list`'s TREND-column behavior. - Regenerate committed skill docs for the new alias.
|
Done in 52e7e59. Both Bugbot issues + your two follow-ups:
Updated the view/formatter tests and regenerated the skill docs. Typecheck + |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 52e7e59. Configure here.
The `conversations` alias added in the previous commit was registered in the route map but missing from `hideRoute`, so — unlike every other plural alias — it surfaced in help output, the generated project tree (as a phantom `conversations.ts`), and the skill docs. Add it to `hideRoute` and regenerate the committed skill docs (Cursor Bugbot).
|
Jared, final requests:
|
|
After those and if you don't have any more bot comments, you can merge Jared |
…ntry/api
The /organizations/{org}/ai-conversations/ endpoints are not modeled by
@sentry/api 0.253.0 (the latest release) — they're a new AI-monitoring
feature not yet published to getsentry/sentry-api-schema, so no generated
SDK function or response type exists. Document that here, matching the
convention used for the experimental endpoints in logs.ts/traces.ts, so
the direct apiRequestToRegion calls read as a deliberate choice rather
than a missed reuse of the SDK (BYK review).
sentry conversation command groupsentry conversation command group for inspecting AI agent transcripts

Goal
Give Sentry users a first-class, terminal-native way to inspect AI agent
conversations — the same LLM/tool-call transcripts you can see in the Sentry
UI's AI monitoring views — without leaving the shell or hand-rolling API calls.
This is aimed squarely at the CLI's agent-friendly audience: people debugging
agents want to pull a conversation's full transcript (and a scannable list of
recent ones) into their own tooling.
Two commands:
sentry conversation list— recent AI conversations for an orgsentry conversation view [<org>/]<conversation-id>— the full transcript(user/assistant turns, tool calls, tokens, errors)
Principles
Consistency over novelty. Everything reuses the existing CLI machinery —
buildListCommand/buildCommand, the shared bidirectional paginationcursor-stack,
resolveOrgauto-detection, the markdown/plain renderingpipeline, and
--json/--fieldsoutput. Nothing about conversations gets abespoke code path where a shared one exists, so it behaves exactly like
issue,trace, andspanfor flags, pagination, and JSON envelopes.Match
gh-style ergonomics.viewtakes a single[<org>/]<conversation-id>positional (org is parsed off the prefix orauto-detected), mirroring how the other view commands accept a target. The
list table sheds low-priority columns on narrow terminals instead of
truncating the useful ones.
Lean on
@sentry/api, deviate only where forced. Response pagination goesthrough the SDK's canonical Link-header parser. The
/ai-conversations/endpoints themselves are not yet modeled by
@sentry/api(0.253.0, thelatest release) — they're a new AI-monitoring feature that hasn't landed in
getsentry/sentry-api-schema— so, exactly aslogs.ts/traces.tsdo fortheir experimental endpoints, they're called directly via
apiRequestToRegionwith local Zod schemas and an explanatory comment. When the SDK ships these
endpoints, the local schemas should be swapped for the generated types.
Faithful transcripts. Transcript reconstruction from raw
gen_ai.*spanattributes is ported from sentry-mcp's
get-ai-conversation-detailsso theCLI, MCP, and UI tell the same story about a conversation.
Agent-friendly output. Every command emits a structured
--jsonenvelopeso coding agents can consume conversations directly, per the CLI's core goals.
Test plan
sentry conversation listshows recent conversationssentry conversation list my-orgwith explicit orgsentry conversation list --jsonoutputs the JSON envelopesentry conversation list -c next/-c prevpaginatesentry conversation view my-org/conv-123shows the transcriptsentry conversation view conv-123with auto-detected orgsentry conversation view my-org/conv-123 --jsonoutputs structured JSON