-
Notifications
You must be signed in to change notification settings - Fork 33
feat(plugins): Add conversation classification analytics #1025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
dcramer
wants to merge
4
commits into
main
Choose a base branch
from
codex/conversation-classification-913
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
74e1176
feat(plugins): Add conversation classification analytics
dcramer 8ede9a1
fix(ci): Cover conversation classifier package
dcramer 1e3d1c6
fix(security): Expand classifier credential redaction
dcramer 1d98740
fix(plugins): Use persisted destination visibility
dcramer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
106 changes: 106 additions & 0 deletions
106
packages/docs/src/content/docs/extend/conversation-classification-plugin.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| --- | ||
| title: Conversation Classification Plugin | ||
| description: Classify the primary job requested in Junior conversations for aggregate product analytics. | ||
| type: tutorial | ||
| summary: Configure asynchronous per-turn classification with a stable taxonomy and bounded retention. | ||
| prerequisites: | ||
| - /extend/ | ||
| related: | ||
| - /concepts/skills-and-plugins/ | ||
| - /operate/security-hardening/ | ||
| - /reference/runtime-commands/ | ||
| --- | ||
|
|
||
| The conversation classification plugin records one requested-job category for | ||
| each successfully completed turn. Classification runs after visible reply | ||
| delivery and does not change the user-facing response. | ||
|
|
||
| ## Install | ||
|
|
||
| ```bash | ||
| pnpm add @sentry/junior-conversation-classification | ||
| ``` | ||
|
|
||
| ## Register | ||
|
|
||
| Add the plugin factory to `plugins.ts`: | ||
|
|
||
| ```ts title="plugins.ts" | ||
| import { defineJuniorPlugins } from "@sentry/junior"; | ||
| import { createConversationClassificationPlugin } from "@sentry/junior-conversation-classification"; | ||
|
|
||
| export const plugins = defineJuniorPlugins([ | ||
| createConversationClassificationPlugin(), | ||
| ]); | ||
| ``` | ||
|
|
||
| The plugin uses runtime hooks and background tasks, so do not register it as a | ||
| bare package-name string. | ||
|
|
||
| ## Run migrations | ||
|
|
||
| Apply the packaged Postgres migration before serving traffic: | ||
|
|
||
| ```bash | ||
| pnpm exec junior upgrade | ||
| ``` | ||
|
|
||
| ## Configure | ||
|
|
||
| ```ts title="plugins.ts" | ||
| createConversationClassificationPlugin({ | ||
| maxTranscriptChars: 8_000, | ||
| modelId: "anthropic/claude-haiku-4.5", | ||
| retentionDays: 180, | ||
| taxonomy: { | ||
| version: "company-intent-v1", | ||
| categories: [ | ||
| { | ||
| id: "engineering", | ||
| description: "Implementation, debugging, or code review work.", | ||
| }, | ||
| { | ||
| id: "research", | ||
| description: "Investigation or information gathering without changes.", | ||
| }, | ||
| { | ||
| id: "other", | ||
| description: "No other category is a confident fit.", | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| - `modelId` defaults to Junior's fast structured model. | ||
| - `maxTranscriptChars` defaults to `12000` and must be at least `256`. | ||
| - `retentionDays` defaults to `90` and controls plugin-owned cleanup. | ||
| - Category ids must be unique lowercase identifiers. Keep ids stable within a | ||
| version and change the version when category definitions materially change. | ||
|
|
||
| ## Data handling | ||
|
|
||
| The additional structured-model request contains only authoritative user | ||
| instructions from the completed turn and tool names with success/error status. | ||
| Ambient thread context, assistant text, and tool-result bodies are excluded. | ||
| The plugin stores no transcript text. | ||
|
|
||
| ## Verify | ||
|
|
||
| Run a local conversation through the configured app: | ||
|
|
||
| ```bash | ||
| pnpm cli -- chat -p "Explain what the conversation classification plugin measures." | ||
| ``` | ||
|
|
||
| Confirm the command exits successfully and that the background task writes a | ||
| row to `junior_conversation_classifications`. | ||
|
|
||
| For initial-intent reporting, select the earliest `turn_completed_at_ms` row | ||
| for each `conversation_id`. Keep all rows when analyzing how requests change | ||
| within longer conversations. | ||
|
|
||
| ## Next step | ||
|
|
||
| Review [Security Hardening](/operate/security-hardening/) before enabling | ||
| classification for private workplace conversations. |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.