:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(user_interviews): classify responses (abandoned/short/off-topic/long) (#60808)
Paul D'Ambra2ed328f9bc02
diff --git a/products/user_interviews/backend/classification.py b/products/user_interviews/backend/classification.pynew file mode 100644index 000000000000..83ee19d25958--- /dev/null+++ b/products/user_interviews/backend/classification.py@@ -0,0 +1,33 @@+import re++from .models import UserInterviewClassification++# Vapi voice-interview transcripts are newline-delimited `AI:` / `User:` turns. Keep the+# speaker vocabulary in sync with frontend/parseTranscript.ts (TURN_SPLIT_RE) — both sides+# parse the same Vapi format independently.+_USER_TURN_RE = re.compile(+ r"(?:^|\n)\s*(?:User|Interviewee):\s+(.+?)(?=\n\s*(?:AI|Assistant|Interviewer|User|Interviewee):|$)",+ re.IGNORECASE | re.DOTALL,+)+_AI_TURN_RE = re.compile(r"(?:^|\n)\s*(?:AI|Assistant|Interviewer):\s+", re.IGNORECASE)+++def _user_turns(transcript: str) -> list[str]:+ return [t.strip() for t in _USER_TURN_RE.findall(transcript) if t.strip()]+++def derive_auto_classifications(transcript: str) -> list[str]:+ """Derive the mechanical classifications for a Vapi voice-interview transcript.++ Only `abandoned` is auto-derived — when the AI spoke but the interviewee never+ meaningfully did. `off-topic` needs human judgement and is never auto-set.++ Only the `AI:` / `User:` turn format (Vapi) is recognised. Transcripts in other formats+ (e.g. the audio-upload path's `#### Speaker N` headings) have no parseable turns, so we+ return no classifications rather than mislabel them `abandoned`.+ """+ if _user_turns(transcript):+ return []+ # No interviewee turns. Only call it `abandoned` when the AI clearly spoke (a real+ # voice interview the interviewee dropped); an unrecognised format gets left untagged.+ return [UserInterviewClassification.ABANDONED] if _AI_TURN_RE.search(transcript) else []diff --git a/products/user_interviews/backend/facade/api.py b/products/user_interviews/backend/facade/api.pyindex fa18ff3e8ec0..50e145b709e0 100644--- a/products/user_interviews/backend/facade/api.py+++ b/products/user_interviews/backend/facade/api.py@@ -17,6 +17,7 @@ Do NOT:from uuid import UUIDfrom products.user_interviews.backend import logic+from products.user_interviews.backend.classification import derive_auto_classificationsfrom products.user_interviews.backend.facade.contracts import IntervieweeIdentityfrom products.user_interviews.backend.max_tools import AnalyzeUserInterviewsTool, CreateUserInterviewTopicTool@@ -24,6 +25,7 @@ __all__ = ["AnalyzeUserInterviewsTool","CreateUserInterviewTopicTool","IntervieweeIdentity",+ "derive_auto_classifications","has_replied","parse_interviewee_identifier",]diff --git a/products/user_interviews/backend/migrations/0007_userinterview_classifications.py b/products/user_interviews/backend/migrations/0007_userinterview_classifications.pynew file mode 100644index 000000000000..44c1c0577618--- /dev/null+++ b/products/user_interviews/backend/migrations/0007_userinterview_classifications.py@@ -0,0 +1,29 @@+# Generated by Django 5.2.14 on 2026-05-31 12:01++import django.contrib.postgres.fields+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("user_interviews", "0006_userinterviewtopic_invite_fields"),+ ]++ operations = [+ migrations.AddField(+ model_name="userinterview",+ name="classifications",+ field=django.contrib.postgres.fields.ArrayField(+ base_field=models.CharField(+ choices=[+ ("abandoned", "Abandoned"),+ ("off-topic", "Off-topic"),+ ],+ max_length=20,+ ),+ blank=True,+ default=list,+ size=None,+ ),+ ),+ ]diff --git a/products/user_interviews/backend/migrations/0008_userinterview_user_interview_classif_gin.py b/products/user_interviews/backend/migrations/0008_userinterview_user_interview_classif_gin.pynew file mode 100644index 000000000000..1349fe4f0409--- /dev/null+++ b/products/user_interviews/backend/migrations/0008_userinterview_user_interview_classif_gin.py@@ -0,0 +1,32 @@+from django.contrib.postgres.indexes import GinIndex+from django.db import migrations++from posthog.migration_helpers import CreateIndexConcurrently+++class Migration(migrations.Migration):+ # CONCURRENTLY can't run inside a transaction.+ atomic = False++ dependencies = [+ ("user_interviews", "0007_userinterview_classifications"),+ ]++ operations = [+ migrations.SeparateDatabaseAndState(+ state_operations=[+ migrations.AddIndex(+ model_name="userinterview",+ index=GinIndex(fields=["classifications"], name="user_interview_classif_gin"),+ ),+ ],+ database_operations=[+ CreateIndexConcurrently(+ index_name="user_interview_classif_gin",+ table_name="user_interviews_userinterview",+ columns="(classifications)",+ using="gin",+ ),+ ],+ ),+ ]diff --git a/products/user_interviews/backend/migrations/max_migration.txt b/products/user_interviews/backend/migrations/max_migration.txtindex 3002631ed091..c7efa0be5ae4 100644--- a/products/user_interviews/backend/migrations/max_migration.txt+++ b/products/user_interviews/backend/migrations/max_migration.txt@@ -1 +1 @@-0006_userinterviewtopic_invite_fields+0008_userinterview_user_interview_classif_gindiff --git a/products/user_interviews/backend/models.py b/products/user_interviews/backend/models.pyindex bfa7ace8a861..c7dfacaca4d2 100644--- a/products/user_interviews/backend/models.py+++ b/products/user_interviews/backend/models.py@@ -1,6 +1,7 @@import refrom django.contrib.postgres.fields import ArrayField+from django.contrib.postgres.indexes import GinIndexfrom django.core import validatorsfrom django.db import modelsfrom django.utils.deconstruct import deconstructible@@ -22,6 +23,11 @@ class EmailWithDisplayNameValidator:return validators.validate_email(value)+class UserInterviewClassification(models.TextChoices):+ ABANDONED = "abandoned", "Abandoned"+ OFF_TOPIC = "off-topic", "Off-topic"++class UserInterview(UUIDTModel, CreatedMetaFields):team = models.ForeignKey(Team, on_delete=models.CASCADE)interviewee_emails = ArrayField(@@ -29,6 +35,11 @@ class UserInterview(UUIDTModel, CreatedMetaFields):)transcript = models.TextField(blank=True)summary = models.TextField(blank=True)+ classifications = ArrayField(+ models.CharField(max_length=20, choices=UserInterviewClassification.choices),+ default=list,+ blank=True,+ )# Optional topic linkage for AI voice interviews triggered via SharingConfiguration links.topic = models.ForeignKey("UserInterviewTopic",@@ -41,6 +52,11 @@ class UserInterview(UUIDTModel, CreatedMetaFields):recording_url = models.URLField(blank=True, default="", max_length=2048)call_metadata = models.JSONField(default=dict, blank=True)+ class Meta:+ # GIN index backs the `classifications__overlap` (&&) filter used by the list and+ # search endpoints — without it those queries fall back to a sequential scan.+ indexes = [GinIndex(fields=["classifications"], name="user_interview_classif_gin")]+class UserInterviewTopic(UUIDTModel, CreatedMetaFields):team = models.ForeignKey(Team, on_delete=models.CASCADE)diff --git a/products/user_interviews/backend/presentation/views.py b/products/user_interviews/backend/presentation/views.pyindex 3a7f2cff88f9..e277035546d6 100644--- a/products/user_interviews/backend/presentation/views.py+++ b/products/user_interviews/backend/presentation/views.py@@ -13,6 +13,7 @@ from django.utils import timezonefrom django.utils.text import slugifyimport structlog+import django_filtersimport posthoganalyticsimport posthoganalytics.ai.openaifrom django_filters.rest_framework import DjangoFilterBackend@@ -44,10 +45,16 @@ from posthog.permissions import PostHogFeatureFlagPermissionfrom posthog.security.spreadsheet_safety import sanitize_formula_injectionfrom posthog.utils import absolute_uri-from ..facade.api import parse_interviewee_identifier+from ..facade.api import derive_auto_classifications, parse_interviewee_identifierfrom ..facade.enums import SEARCH_DOCUMENT_TYPESfrom ..invite_email import build_invite_email_context, validate_invite_message, validate_invite_subject-from ..models import EmailWithDisplayNameValidator, IntervieweeContext, UserInterview, UserInterviewTopic+from ..models import (+ EmailWithDisplayNameValidator,+ IntervieweeContext,+ UserInterview,+ UserInterviewClassification,+ UserInterviewTopic,+)logger = structlog.get_logger(__name__)@@ -73,6 +80,15 @@ class _InterviewLinksCSVRenderer(csvrenderers.CSVRenderer):class UserInterviewSerializer(serializers.ModelSerializer):created_by = UserBasicSerializer(read_only=True)audio = serializers.FileField(write_only=True)+ classifications = serializers.ListField(+ child=serializers.ChoiceField(choices=UserInterviewClassification.choices),+ required=False,+ help_text=(+ "Searchable classifications on the response. `abandoned` is auto-derived from the transcript when "+ "the interview is recorded; `off-topic` is set manually. Sending `classifications` on an update "+ "replaces the whole list — pass the full desired set, not a delta."+ ),+ )class Meta:model = UserInterview@@ -85,6 +101,7 @@ class UserInterviewSerializer(serializers.ModelSerializer):"topic","transcript","summary",+ "classifications","audio",)read_only_fields = ("id", "created_by", "created_at", "interviewee_identifier", "topic", "transcript")@@ -96,6 +113,7 @@ class UserInterviewSerializer(serializers.ModelSerializer):audio = validated_data.pop("audio")validated_data["transcript"] = self._transcribe_audio(audio, validated_data["interviewee_emails"])validated_data["summary"] = self._summarize_transcript(validated_data["transcript"])+ validated_data["classifications"] = derive_auto_classifications(validated_data["transcript"])return super().create(validated_data)def _transcribe_audio(self, audio: File, interviewee_emails: list[str]) -> str:@@ -297,6 +315,16 @@ class UserInterviewSearchRequestSerializer(serializers.Serializer):allow_null=True,help_text="Optional. Restrict results to interviews belonging to a specific UserInterviewTopic.",)+ classifications = serializers.ListField(+ child=serializers.ChoiceField(choices=UserInterviewClassification.choices),+ required=False,+ allow_empty=False,+ min_length=1,+ help_text=(+ "Optional. Restrict results to interviews carrying any of these classifications (OR). "+ "Combines with `topic_id` as AND."+ ),+ )limit = serializers.IntegerField(required=False,min_value=1,@@ -331,6 +359,32 @@ class UserInterviewSearchResultSerializer(serializers.Serializer):created_at = serializers.DateTimeField(help_text="When the interview row was created.")+class UserInterviewFilterSet(django_filters.FilterSet):+ classifications = django_filters.CharFilter(+ method="filter_classifications",+ help_text=(+ "Comma-separated classifications; returns responses carrying any of them (OR). "+ "Valid values: abandoned, off-topic."+ ),+ )++ class Meta:+ model = UserInterview+ fields = ["topic"]++ def filter_classifications(self, queryset: Any, name: str, value: str) -> Any:+ wanted = [t.strip() for t in value.split(",") if t.strip()]+ if not wanted:+ return queryset+ unknown = [c for c in wanted if c not in UserInterviewClassification.values]+ if unknown:+ valid = ", ".join(UserInterviewClassification.values)+ raise ValidationError(+ {"classifications": f"Unknown classification(s): {', '.join(unknown)}. Valid values: {valid}."}+ )+ return queryset.filter(classifications__overlap=wanted)++class UserInterviewViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):scope_object = "user_interview"queryset = UserInterview.objects.order_by("-created_at").select_related("created_by").all()@@ -339,7 +393,7 @@ class UserInterviewViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):posthog_feature_flag = "user-interviews"permission_classes = [PostHogFeatureFlagPermission]filter_backends = [DjangoFilterBackend]- filterset_fields = ["topic"]+ filterset_class = UserInterviewFilterSet@validated_request(request_serializer=UserInterviewSearchRequestSerializer,@@ -371,19 +425,21 @@ class UserInterviewViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):query_str: str = body["query"]document_types: list[str] = body.get("document_types") or list(SEARCH_DOCUMENT_TYPES)topic_id = body.get("topic_id")+ classifications: list[str] = body.get("classifications") or []limit: int = body.get("limit") or SEARCH_DEFAULT_LIMIT- # When a topic_id filter is requested, resolve it via the current Postgres linkage- # rather than the embedding-time `metadata.topic_id` — UserInterview.topic is- # nullable with on_delete=SET_NULL, so historical metadata can name a topic the- # row no longer belongs to.+ # When a topic_id or classifications filter is requested, resolve it via the current+ # Postgres linkage rather than the embedding-time `metadata.topic_id` — UserInterview.topic+ # is nullable with on_delete=SET_NULL, so historical metadata can name a topic the+ # row no longer belongs to, and classifications are mutated post-embedding.scoped_document_ids: list[str] | None = None- if topic_id is not None:- scoped_ids_qs = (- UserInterview.objects.filter(team_id=self.team_id, topic_id=topic_id)- .order_by("id")- .values_list("id", flat=True)[: SEARCH_TOPIC_INTERVIEW_CAP + 1]- )+ if topic_id is not None or classifications:+ scoped_qs = UserInterview.objects.filter(team_id=self.team_id)+ if topic_id is not None:+ scoped_qs = scoped_qs.filter(topic_id=topic_id)+ if classifications:+ scoped_qs = scoped_qs.filter(classifications__overlap=classifications)+ scoped_ids_qs = scoped_qs.order_by("id").values_list("id", flat=True)[: SEARCH_TOPIC_INTERVIEW_CAP + 1]scoped_document_ids = [str(pk) for pk in scoped_ids_qs]if not scoped_document_ids:return response.Response(UserInterviewSearchResultSerializer([], many=True).data)@@ -391,7 +447,8 @@ class UserInterviewViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):logger.warning("user_interviews_search_topic_scope_capped",team_id=self.team_id,- topic_id=str(topic_id),+ topic_id=str(topic_id) if topic_id is not None else None,+ classifications=classifications or None,cap=SEARCH_TOPIC_INTERVIEW_CAP,)scoped_document_ids = scoped_document_ids[:SEARCH_TOPIC_INTERVIEW_CAP]diff --git a/products/user_interviews/backend/presentation/webhooks.py b/products/user_interviews/backend/presentation/webhooks.pyindex 119791e83617..696bf38420b1 100644--- a/products/user_interviews/backend/presentation/webhooks.py+++ b/products/user_interviews/backend/presentation/webhooks.py@@ -40,6 +40,7 @@ from posthog.models.team import Teamfrom posthog.rate_limit import IPThrottlefrom posthog.storage.llm_prompt_cache import get_prompt_by_name_from_cache+from ..facade.api import derive_auto_classificationsfrom ..models import UserInterview, UserInterviewTopiclogger = structlog.get_logger(__name__)@@ -497,6 +498,7 @@ def vapi_webhook(request: Request) -> Response:topic = interviewee_context.topicrecording_url = (message.get("recording") or {}).get("url", "") or message.get("recordingUrl", "") or ""+ transcript = message.get("transcript", "") or ""with transaction.atomic():interview = UserInterview.objects.create(@@ -506,11 +508,12 @@ def vapi_webhook(request: Request) -> Response:interviewee_emails=[interviewee_context.interviewee_identifier]if "@" in interviewee_context.interviewee_identifierelse [],- transcript=message.get("transcript", "") or "",+ transcript=transcript,summary=message.get("summary", "") or "",recording_url=recording_url,call_metadata=call,created_by=topic.created_by,+ classifications=derive_auto_classifications(transcript),)transaction.on_commit(lambda: _emit_interview_embeddings(interview, topic))diff --git a/products/user_interviews/backend/test_classification.py b/products/user_interviews/backend/test_classification.pynew file mode 100644index 000000000000..4b25c7180fae--- /dev/null+++ b/products/user_interviews/backend/test_classification.py@@ -0,0 +1,30 @@+from django.test import SimpleTestCase++from parameterized import parameterized++from products.user_interviews.backend.classification import derive_auto_classifications+from products.user_interviews.backend.models import UserInterviewClassification+++class TestDeriveAutoClassifications(SimpleTestCase):+ @parameterized.expand(+ [+ ("empty transcript has no parseable turns", "", []),+ ("ai only, no user turn", "AI: Hi there, are you free?\n", [UserInterviewClassification.ABANDONED]),+ ("ai only multi line", "AI: Hi.\nAI: Still there?\n", [UserInterviewClassification.ABANDONED]),+ ("blank user turn is not a real turn", "AI: Hello.\nUser: \n", [UserInterviewClassification.ABANDONED]),+ (+ "lowercase ai-only prefix still abandoned",+ "ai: are you there?\n",+ [UserInterviewClassification.ABANDONED],+ ),+ ("a real exchange is not auto-classified", "AI: How was onboarding?\nUser: Fine, no complaints.", []),+ (+ "unrecognised speaker-heading format is left untagged, not abandoned",+ "#### Speaker 1\nThanks for joining today.\n#### Speaker 2\nHappy to help, this product changed how we work.",+ [],+ ),+ ]+ )+ def test_derive_auto_classifications(self, _name: str, transcript: str, expected: list[str]):+ assert derive_auto_classifications(transcript) == expecteddiff --git a/products/user_interviews/backend/test_user_interviews_list.py b/products/user_interviews/backend/test_user_interviews_list.pyindex ce3368f1e6d7..84f31b8e2de1 100644--- a/products/user_interviews/backend/test_user_interviews_list.py+++ b/products/user_interviews/backend/test_user_interviews_list.py@@ -28,7 +28,12 @@ class TestUserInterviewsListFilters(APIBaseTest):)def _create_interview(- self, *, topic: UserInterviewTopic | None, summary: str, team: Team | None = None+ self,+ *,+ topic: UserInterviewTopic | None,+ summary: str,+ team: Team | None = None,+ classifications: list[str] | None = None,) -> UserInterview:return UserInterview.objects.create(team=team or self.team,@@ -37,6 +42,7 @@ class TestUserInterviewsListFilters(APIBaseTest):transcript="Hello world",summary=summary,topic=topic,+ classifications=classifications or [],)@parameterized.expand(@@ -83,6 +89,64 @@ class TestUserInterviewsListFilters(APIBaseTest):assert filtered_by_other_team_topic.status_code == status.HTTP_200_OK, filtered_by_other_team_topic.contentassert filtered_by_other_team_topic.json()["results"] == []+ @parameterized.expand(+ [+ ("no classification filter returns all", None, {"abandoned-one", "off-topic-one", "unclassified"}),+ ("single classification", "abandoned", {"abandoned-one"}),+ ("multiple classifications are OR", "abandoned,off-topic", {"abandoned-one", "off-topic-one"}),+ ("classification with no matches", "off-topic", {"off-topic-one"}),+ ]+ )+ def test_classifications_filter(+ self, _name: str, classifications_param: str | None, expected_summaries: set[str]+ ) -> None:+ topic = self._create_topic("Classified topic")+ self._create_interview(topic=topic, summary="abandoned-one", classifications=["abandoned"])+ self._create_interview(topic=topic, summary="off-topic-one", classifications=["off-topic"])+ self._create_interview(topic=topic, summary="unclassified", classifications=[])++ params = {} if classifications_param is None else {"classifications": classifications_param}+ response = self.client.get(self._list_url(), params)++ assert response.status_code == status.HTTP_200_OK, response.content+ summaries = {row["summary"] for row in response.json()["results"]}+ assert summaries == expected_summaries++ def test_list_rejects_unknown_classification(self) -> None:+ topic = self._create_topic("Classified topic")+ self._create_interview(topic=topic, summary="abandoned-one", classifications=["abandoned"])++ response = self.client.get(self._list_url(), {"classifications": "abandoned,bogus"})++ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.content++ def test_partial_update_replaces_classifications(self) -> None:+ topic = self._create_topic("Classified topic")+ interview = self._create_interview(topic=topic, summary="resp", classifications=["abandoned"])++ response = self.client.patch(+ f"{self._list_url()}{interview.id}/",+ {"classifications": ["off-topic"]},+ format="json",+ )++ assert response.status_code == status.HTTP_200_OK, response.content+ assert set(response.json()["classifications"]) == {"off-topic"}+ interview.refresh_from_db()+ assert set(interview.classifications) == {"off-topic"}++ def test_partial_update_rejects_unknown_classification(self) -> None:+ topic = self._create_topic("Classified topic")+ interview = self._create_interview(topic=topic, summary="resp", classifications=[])++ response = self.client.patch(+ f"{self._list_url()}{interview.id}/",+ {"classifications": ["bogus"]},+ format="json",+ )++ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.content+def test_retrieve_returns_full_transcript_and_summary(self) -> None:topic = self._create_topic("Topic A")interview = self._create_interview(topic=topic, summary="Full summary text")diff --git a/products/user_interviews/frontend/generated/api.schemas.ts b/products/user_interviews/frontend/generated/api.schemas.tsindex 113b705364c9..23b010a71874 100644--- a/products/user_interviews/frontend/generated/api.schemas.ts+++ b/products/user_interviews/frontend/generated/api.schemas.ts@@ -275,6 +275,17 @@ export interface BulkIntervieweeContextResponseApi {skipped_identifiers: string[]}+/**+ * * `abandoned` - Abandoned+ * `off-topic` - Off-topic+ */+export type ClassificationsEnumApi = (typeof ClassificationsEnumApi)[keyof typeof ClassificationsEnumApi]++export const ClassificationsEnumApi = {+ Abandoned: 'abandoned',+ OffTopic: 'off-topic',+} as const+export interface UserInterviewApi {readonly id: stringreadonly created_by: UserBasicApi@@ -285,6 +296,8 @@ export interface UserInterviewApi {readonly topic: string | nullreadonly transcript: stringsummary?: string+ /** Searchable classifications on the response. `abandoned` is auto-derived from the transcript when the interview is recorded; `off-topic` is set manually. Sending `classifications` on an update replaces the whole list — pass the full desired set, not a delta. */+ classifications?: ClassificationsEnumApi[]audio: string}@@ -307,6 +320,8 @@ export interface PatchedUserInterviewApi {readonly topic?: string | nullreadonly transcript?: stringsummary?: string+ /** Searchable classifications on the response. `abandoned` is auto-derived from the transcript when the interview is recorded; `off-topic` is set manually. Sending `classifications` on an update replaces the whole list — pass the full desired set, not a delta. */+ classifications?: ClassificationsEnumApi[]audio?: string}@@ -338,6 +353,11 @@ export interface UserInterviewSearchRequestApi {* @nullable*/topic_id?: string | null+ /**+ * Optional. Restrict results to interviews carrying any of these classifications (OR). Combines with `topic_id` as AND.+ * @minItems 1+ */+ classifications?: ClassificationsEnumApi[]/*** Maximum number of matches to return (1-50). Defaults to 10. Two matches per interview are possible — one for the transcript, one for the summary.* @minimum 1@@ -396,6 +416,10 @@ export type UserInterviewTopicsIntervieweesListParams = {}export type UserInterviewsListParams = {+ /**+ * Comma-separated classifications; returns responses carrying any of them (OR). Valid values: abandoned, off-topic.+ */+ classifications?: string/*** Number of results to return per page.*/diff --git a/products/user_interviews/frontend/generated/api.ts b/products/user_interviews/frontend/generated/api.tsindex a0a4e7b34c29..70439fa8ac29 100644--- a/products/user_interviews/frontend/generated/api.ts+++ b/products/user_interviews/frontend/generated/api.ts@@ -508,6 +508,9 @@ export const userInterviewsCreate = async (if (userInterviewApi.summary !== undefined) {formData.append(`summary`, userInterviewApi.summary)}+ if (userInterviewApi.classifications !== undefined) {+ userInterviewApi.classifications.forEach((value) => formData.append(`classifications`, value))+ }formData.append(`audio`, userInterviewApi.audio)return apiMutator<UserInterviewApi>(getUserInterviewsCreateUrl(projectId), {@@ -549,6 +552,9 @@ export const userInterviewsUpdate = async (if (userInterviewApi.summary !== undefined) {formData.append(`summary`, userInterviewApi.summary)}+ if (userInterviewApi.classifications !== undefined) {+ userInterviewApi.classifications.forEach((value) => formData.append(`classifications`, value))+ }formData.append(`audio`, userInterviewApi.audio)return apiMutator<UserInterviewApi>(getUserInterviewsUpdateUrl(projectId, id), {@@ -575,6 +581,9 @@ export const userInterviewsPartialUpdate = async (if (patchedUserInterviewApi?.summary !== undefined) {formData.append(`summary`, patchedUserInterviewApi.summary)}+ if (patchedUserInterviewApi?.classifications !== undefined) {+ patchedUserInterviewApi?.classifications.forEach((value) => formData.append(`classifications`, value))+ }if (patchedUserInterviewApi?.audio !== undefined) {formData.append(`audio`, patchedUserInterviewApi.audio)}diff --git a/products/user_interviews/frontend/generated/api.zod.ts b/products/user_interviews/frontend/generated/api.zod.tsindex faa580ec8edd..ab952da421a8 100644--- a/products/user_interviews/frontend/generated/api.zod.ts+++ b/products/user_interviews/frontend/generated/api.zod.ts@@ -302,6 +302,12 @@ export const userInterviewsCreateBodyIntervieweeEmailsItemMax = 254export const UserInterviewsCreateBody = /* @__PURE__ */ zod.object({interviewee_emails: zod.array(zod.string().max(userInterviewsCreateBodyIntervieweeEmailsItemMax)).optional(),summary: zod.string().optional(),+ classifications: zod+ .array(zod.enum(['abandoned', 'off-topic']).describe('\* `abandoned` - Abandoned\n\* `off-topic` - Off-topic'))+ .optional()+ .describe(+ 'Searchable classifications on the response. `abandoned` is auto-derived from the transcript when the interview is recorded; `off-topic` is set manually. Sending `classifications` on an update replaces the whole list — pass the full desired set, not a delta.'+ ),audio: zod.url(),})@@ -310,6 +316,12 @@ export const userInterviewsUpdateBodyIntervieweeEmailsItemMax = 254export const UserInterviewsUpdateBody = /* @__PURE__ */ zod.object({interviewee_emails: zod.array(zod.string().max(userInterviewsUpdateBodyIntervieweeEmailsItemMax)).optional(),summary: zod.string().optional(),+ classifications: zod+ .array(zod.enum(['abandoned', 'off-topic']).describe('\* `abandoned` - Abandoned\n\* `off-topic` - Off-topic'))+ .optional()+ .describe(+ 'Searchable classifications on the response. `abandoned` is auto-derived from the transcript when the interview is recorded; `off-topic` is set manually. Sending `classifications` on an update replaces the whole list — pass the full desired set, not a delta.'+ ),audio: zod.url(),})@@ -318,6 +330,12 @@ export const userInterviewsPartialUpdateBodyIntervieweeEmailsItemMax = 254export const UserInterviewsPartialUpdateBody = /* @__PURE__ */ zod.object({interviewee_emails: zod.array(zod.string().max(userInterviewsPartialUpdateBodyIntervieweeEmailsItemMax)).optional(),summary: zod.string().optional(),+ classifications: zod+ .array(zod.enum(['abandoned', 'off-topic']).describe('\* `abandoned` - Abandoned\n\* `off-topic` - Off-topic'))+ .optional()+ .describe(+ 'Searchable classifications on the response. `abandoned` is auto-derived from the transcript when the interview is recorded; `off-topic` is set manually. Sending `classifications` on an update replaces the whole list — pass the full desired set, not a delta.'+ ),audio: zod.url().optional(),})@@ -345,6 +363,13 @@ export const UserInterviewsSearchCreateBody = /* @__PURE__ */ zod.object({.uuid().nullish().describe('Optional. Restrict results to interviews belonging to a specific UserInterviewTopic.'),+ classifications: zod+ .array(zod.enum(['abandoned', 'off-topic']).describe('\* `abandoned` - Abandoned\n\* `off-topic` - Off-topic'))+ .min(1)+ .optional()+ .describe(+ 'Optional. Restrict results to interviews carrying any of these classifications (OR). Combines with `topic_id` as AND.'+ ),limit: zod.number().min(1)diff --git a/products/user_interviews/mcp/tools.yaml b/products/user_interviews/mcp/tools.yamlindex 172317019b07..861a87a9ea6b 100644--- a/products/user_interviews/mcp/tools.yaml+++ b/products/user_interviews/mcp/tools.yaml@@ -308,11 +308,29 @@ tools:scope to a single research topic — use this to answer questions like "do I have any responses on my X topicyet?". Use `limit`/`offset` for pagination. `transcript` and `summary` can be long; when listing, preferskimming the response shapes and then call `user-interviews-retrieve` for the full text of a specific- interview.+ interview. Pass `classifications` (comma-separated; any of `abandoned`, `off-topic`) to return only+ responses carrying any of those classifications — e.g. `classifications=abandoned` to find drop-offs.feature_flag: user-interviewsuser-interviews-partial-update:operation: user_interviews_partial_update- enabled: false+ enabled: true+ scopes:+ - user_interview:write+ annotations:+ readOnly: false+ destructive: false+ idempotent: true+ title: Set classifications on an interview response+ description: >+ Replace the searchable `classifications` on a single interview response. The valid classifications are+ `abandoned` and `off-topic`. `abandoned` is auto-derived from the transcript when the response is recorded;+ use this to correct it or to apply `off-topic`, which is never auto-set. Sending `classifications` replaces+ the entire list — pass the full desired set, not a delta, so include the auto-derived `abandoned` if you+ want to keep it. Filter by these later via the `classifications` parameter on `user-interviews-list` and+ `user-interviews-search`.+ include_params:+ - classifications+ feature_flag: user-interviewsuser-interviews-retrieve:operation: user_interviews_retrieveenabled: true@@ -344,8 +362,9 @@ tools:is a single (interview, document_type) pair — an interview can appear up to twice if both its transcript andsummary score above other interviews. Use `document_types` to restrict to just `transcript` or just`summary`. Filter by `topic_id` to scope the search to a single interview topic. `limit` caps the number of- returned matches (1-50, default 10). Useful for surfacing relevant excerpts when the caller has a research- question rather than a known string to grep for.+ returned matches (1-50, default 10). Filter by `classifications` (any of `abandoned`, `off-topic`) to+ restrict the search to responses carrying those; combines with `topic_id` as AND. Useful for surfacing+ relevant excerpts when the caller has a research question rather than a known string to grep for.feature_flag: user-interviewsuser-interviews-update:operation: user_interviews_updatediff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex c226de211605..ec0115aa806e 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -5388,7 +5388,7 @@"feature_flag": "user-interviews"},"user-interviews-list": {- "description": "List completed user interview responses in the current project, newest first. Each row includes the interviewee email(s) and identifier, the linked `topic` UUID (set when the interview came in via a topic's shared link), and the AI-generated `transcript` and `summary` fields. Pass `topic` with a topic UUID to scope to a single research topic — use this to answer questions like \"do I have any responses on my X topic yet?\". Use `limit`/`offset` for pagination. `transcript` and `summary` can be long; when listing, prefer skimming the response shapes and then call `user-interviews-retrieve` for the full text of a specific interview.",+ "description": "List completed user interview responses in the current project, newest first. Each row includes the interviewee email(s) and identifier, the linked `topic` UUID (set when the interview came in via a topic's shared link), and the AI-generated `transcript` and `summary` fields. Pass `topic` with a topic UUID to scope to a single research topic — use this to answer questions like \"do I have any responses on my X topic yet?\". Use `limit`/`offset` for pagination. `transcript` and `summary` can be long; when listing, prefer skimming the response shapes and then call `user-interviews-retrieve` for the full text of a specific interview. Pass `classifications` (comma-separated; any of `abandoned`, `off-topic`) to return only responses carrying any of those classifications — e.g. `classifications=abandoned` to find drop-offs.","category": "User interview topics","feature": "user_interviews","summary": "List user interview responses",@@ -5402,6 +5402,21 @@},"feature_flag": "user-interviews"},+ "user-interviews-partial-update": {+ "description": "Replace the searchable `classifications` on a single interview response. The valid classifications are `abandoned` and `off-topic`. `abandoned` is auto-derived from the transcript when the response is recorded; use this to correct it or to apply `off-topic`, which is never auto-set. Sending `classifications` replaces the entire list — pass the full desired set, not a delta, so include the auto-derived `abandoned` if you want to keep it. Filter by these later via the `classifications` parameter on `user-interviews-list` and `user-interviews-search`.",+ "category": "User interview topics",+ "feature": "user_interviews",+ "summary": "Set classifications on an interview response",+ "title": "Set classifications on an interview response",+ "required_scopes": ["user_interview:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": false+ },+ "feature_flag": "user-interviews"+ },"user-interviews-retrieve": {"description": "Fetch a single completed user interview response by id, including the full AI-generated `transcript` and `summary`. Use after `user-interviews-list` has narrowed down to a specific interview — for example, to read what a particular interviewee said about a research topic.","category": "User interview topics",@@ -5418,7 +5433,7 @@"feature_flag": "user-interviews"},"user-interviews-search": {- "description": "Search recorded user interviews by meaning, not keywords. Embeds the natural-language `query` with the same model used to index transcripts and summaries, then returns the top matches by cosine similarity. Each match is a single (interview, document_type) pair — an interview can appear up to twice if both its transcript and summary score above other interviews. Use `document_types` to restrict to just `transcript` or just `summary`. Filter by `topic_id` to scope the search to a single interview topic. `limit` caps the number of returned matches (1-50, default 10). Useful for surfacing relevant excerpts when the caller has a research question rather than a known string to grep for.",+ "description": "Search recorded user interviews by meaning, not keywords. Embeds the natural-language `query` with the same model used to index transcripts and summaries, then returns the top matches by cosine similarity. Each match is a single (interview, document_type) pair — an interview can appear up to twice if both its transcript and summary score above other interviews. Use `document_types` to restrict to just `transcript` or just `summary`. Filter by `topic_id` to scope the search to a single interview topic. `limit` caps the number of returned matches (1-50, default 10). Filter by `classifications` (any of `abandoned`, `off-topic`) to restrict the search to responses carrying those; combines with `topic_id` as AND. Useful for surfacing relevant excerpts when the caller has a research question rather than a known string to grep for.","category": "User interview topics","feature": "user_interviews","summary": "Semantic search across interview responses",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex eb5a565f7e80..61f7d424a21b 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -5743,7 +5743,7 @@"feature_flag": "user-interviews"},"user-interviews-list": {- "description": "List completed user interview responses in the current project, newest first. Each row includes the interviewee email(s) and identifier, the linked `topic` UUID (set when the interview came in via a topic's shared link), and the AI-generated `transcript` and `summary` fields. Pass `topic` with a topic UUID to scope to a single research topic — use this to answer questions like \"do I have any responses on my X topic yet?\". Use `limit`/`offset` for pagination. `transcript` and `summary` can be long; when listing, prefer skimming the response shapes and then call `user-interviews-retrieve` for the full text of a specific interview.",+ "description": "List completed user interview responses in the current project, newest first. Each row includes the interviewee email(s) and identifier, the linked `topic` UUID (set when the interview came in via a topic's shared link), and the AI-generated `transcript` and `summary` fields. Pass `topic` with a topic UUID to scope to a single research topic — use this to answer questions like \"do I have any responses on my X topic yet?\". Use `limit`/`offset` for pagination. `transcript` and `summary` can be long; when listing, prefer skimming the response shapes and then call `user-interviews-retrieve` for the full text of a specific interview. Pass `classifications` (comma-separated; any of `abandoned`, `off-topic`) to return only responses carrying any of those classifications — e.g. `classifications=abandoned` to find drop-offs.","category": "User interview topics","feature": "user_interviews","summary": "List user interview responses",@@ -5757,6 +5757,21 @@},"feature_flag": "user-interviews"},+ "user-interviews-partial-update": {+ "description": "Replace the searchable `classifications` on a single interview response. The valid classifications are `abandoned` and `off-topic`. `abandoned` is auto-derived from the transcript when the response is recorded; use this to correct it or to apply `off-topic`, which is never auto-set. Sending `classifications` replaces the entire list — pass the full desired set, not a delta, so include the auto-derived `abandoned` if you want to keep it. Filter by these later via the `classifications` parameter on `user-interviews-list` and `user-interviews-search`.",+ "category": "User interview topics",+ "feature": "user_interviews",+ "summary": "Set classifications on an interview response",+ "title": "Set classifications on an interview response",+ "required_scopes": ["user_interview:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": false+ },+ "feature_flag": "user-interviews"+ },"user-interviews-retrieve": {"description": "Fetch a single completed user interview response by id, including the full AI-generated `transcript` and `summary`. Use after `user-interviews-list` has narrowed down to a specific interview — for example, to read what a particular interviewee said about a research topic.","category": "User interview topics",@@ -5773,7 +5788,7 @@"feature_flag": "user-interviews"},"user-interviews-search": {- "description": "Search recorded user interviews by meaning, not keywords. Embeds the natural-language `query` with the same model used to index transcripts and summaries, then returns the top matches by cosine similarity. Each match is a single (interview, document_type) pair — an interview can appear up to twice if both its transcript and summary score above other interviews. Use `document_types` to restrict to just `transcript` or just `summary`. Filter by `topic_id` to scope the search to a single interview topic. `limit` caps the number of returned matches (1-50, default 10). Useful for surfacing relevant excerpts when the caller has a research question rather than a known string to grep for.",+ "description": "Search recorded user interviews by meaning, not keywords. Embeds the natural-language `query` with the same model used to index transcripts and summaries, then returns the top matches by cosine similarity. Each match is a single (interview, document_type) pair — an interview can appear up to twice if both its transcript and summary score above other interviews. Use `document_types` to restrict to just `transcript` or just `summary`. Filter by `topic_id` to scope the search to a single interview topic. `limit` caps the number of returned matches (1-50, default 10). Filter by `classifications` (any of `abandoned`, `off-topic`) to restrict the search to responses carrying those; combines with `topic_id` as AND. Useful for surfacing relevant excerpts when the caller has a research question rather than a known string to grep for.","category": "User interview topics","feature": "user_interviews","summary": "Semantic search across interview responses",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 4a3e62c68bde..f04727685a1d 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -10408,6 +10408,18 @@ export namespace Schemas {available: boolean;}+ /**+ * * `abandoned` - Abandoned+ * `off-topic` - Off-topic+ */+ export type ClassificationsEnum = typeof ClassificationsEnum[keyof typeof ClassificationsEnum];+++ export const ClassificationsEnum = {+ Abandoned: 'abandoned',+ OffTopic: 'off-topic',+ } as const;+/*** * `claude` - claude*/@@ -26270,6 +26282,8 @@ export namespace Schemas {readonly topic: string | null;readonly transcript: string;summary?: string;+ /** Searchable classifications on the response. `abandoned` is auto-derived from the transcript when the interview is recorded; `off-topic` is set manually. Sending `classifications` on an update replaces the whole list — pass the full desired set, not a delta. */+ classifications?: ClassificationsEnum[];audio: string;}@@ -32389,6 +32403,8 @@ export namespace Schemas {readonly topic?: string | null;readonly transcript?: string;summary?: string;+ /** Searchable classifications on the response. `abandoned` is auto-derived from the transcript when the interview is recorded; `off-topic` is set manually. Sending `classifications` on an update replaces the whole list — pass the full desired set, not a delta. */+ classifications?: ClassificationsEnum[];audio?: string;}@@ -39178,6 +39194,11 @@ export namespace Schemas {* @nullable*/topic_id?: string | null;+ /**+ * Optional. Restrict results to interviews carrying any of these classifications (OR). Combines with `topic_id` as AND.+ * @minItems 1+ */+ classifications?: ClassificationsEnum[];/*** Maximum number of matches to return (1-50). Defaults to 10. Two matches per interview are possible — one for the transcript, one for the summary.* @minimum 1@@ -43704,6 +43725,10 @@ export namespace Schemas {};export type EnvironmentsUserInterviewsListParams = {+ /**+ * Comma-separated classifications; returns responses carrying any of them (OR). Valid values: abandoned, off-topic.+ */+ classifications?: string;/*** Number of results to return per page.*/@@ -49804,6 +49829,10 @@ export namespace Schemas {};export type UserInterviewsListParams = {+ /**+ * Comma-separated classifications; returns responses carrying any of them (OR). Valid values: abandoned, off-topic.+ */+ classifications?: string;/*** Number of results to return per page.*/diff --git a/services/mcp/src/generated/user_interviews/api.ts b/services/mcp/src/generated/user_interviews/api.tsindex d9efae373974..4ae8646e1d86 100644--- a/services/mcp/src/generated/user_interviews/api.ts+++ b/services/mcp/src/generated/user_interviews/api.ts@@ -3,7 +3,7 @@* MCP service uses these Zod schemas for generated tool handlers.* To regenerate: hogli build:openapi*- * PostHog API - MCP 17 enabled ops+ * PostHog API - MCP 18 enabled ops* OpenAPI spec version: 1.0.0*/import * as zod from 'zod'@@ -393,6 +393,12 @@ export const UserInterviewsListParams = /* @__PURE__ */ zod.object({})export const UserInterviewsListQueryParams = /* @__PURE__ */ zod.object({+ classifications: zod+ .string()+ .optional()+ .describe(+ 'Comma-separated classifications; returns responses carrying any of them (OR). Valid values: abandoned, off-topic.'+ ),limit: zod.number().optional().describe('Number of results to return per page.'),offset: zod.number().optional().describe('The initial index from which to return the results.'),topic: zod.string().optional(),@@ -407,6 +413,29 @@ export const UserInterviewsRetrieveParams = /* @__PURE__ */ zod.object({),})+export const UserInterviewsPartialUpdateParams = /* @__PURE__ */ zod.object({+ id: zod.string().describe('A UUID string identifying this user interview.'),+ project_id: zod+ .string()+ .describe(+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/."+ ),+})++export const userInterviewsPartialUpdateBodyIntervieweeEmailsItemMax = 254++export const UserInterviewsPartialUpdateBody = /* @__PURE__ */ zod.object({+ interviewee_emails: zod.array(zod.string().max(userInterviewsPartialUpdateBodyIntervieweeEmailsItemMax)).optional(),+ summary: zod.string().optional(),+ classifications: zod+ .array(zod.enum(['abandoned', 'off-topic']).describe('* `abandoned` - Abandoned\n* `off-topic` - Off-topic'))+ .optional()+ .describe(+ 'Searchable classifications on the response. `abandoned` is auto-derived from the transcript when the interview is recorded; `off-topic` is set manually. Sending `classifications` on an update replaces the whole list — pass the full desired set, not a delta.'+ ),+ audio: zod.url().optional(),+})+/*** Embed `query` with the same model used to index interview transcripts and summaries, then return the top matches by cosine distance. Each match is a single (interview, document_type) pair — an interview can appear up to twice if both its transcript and summary score above other interviews. Useful for surfacing relevant interview snippets in natural language, without exact keyword matches.* @summary Search interview responses by semantic similarity@@ -439,6 +468,13 @@ export const UserInterviewsSearchCreateBody = /* @__PURE__ */ zod.object({.uuid().nullish().describe('Optional. Restrict results to interviews belonging to a specific UserInterviewTopic.'),+ classifications: zod+ .array(zod.enum(['abandoned', 'off-topic']).describe('* `abandoned` - Abandoned\n* `off-topic` - Off-topic'))+ .min(1)+ .optional()+ .describe(+ 'Optional. Restrict results to interviews carrying any of these classifications (OR). Combines with `topic_id` as AND.'+ ),limit: zod.number().min(1)diff --git a/services/mcp/src/tools/generated/user_interviews.ts b/services/mcp/src/tools/generated/user_interviews.tsindex c5b087cd4a62..0393d9c3ea84 100644--- a/services/mcp/src/tools/generated/user_interviews.ts+++ b/services/mcp/src/tools/generated/user_interviews.ts@@ -26,6 +26,8 @@ import {UserInterviewTopicsSendInvitesCreateBody,UserInterviewTopicsSendInvitesCreateParams,UserInterviewsListQueryParams,+ UserInterviewsPartialUpdateBody,+ UserInterviewsPartialUpdateParams,UserInterviewsRetrieveParams,UserInterviewsSearchCreateBody,} from '@/generated/user_interviews/api'@@ -404,6 +406,7 @@ const userInterviewsList = (): ToolBase<method: 'GET',path: `/api/projects/${encodeURIComponent(String(projectId))}/user_interviews/`,query: {+ classifications: params.classifications,limit: params.limit,offset: params.offset,topic: params.topic,@@ -413,6 +416,28 @@ const userInterviewsList = (): ToolBase<},})+const UserInterviewsPartialUpdateSchema = UserInterviewsPartialUpdateParams.omit({ project_id: true }).extend(+ UserInterviewsPartialUpdateBody.omit({ interviewee_emails: true, summary: true, audio: true }).shape+)++const userInterviewsPartialUpdate = (): ToolBase<typeof UserInterviewsPartialUpdateSchema, Schemas.UserInterview> => ({+ name: 'user-interviews-partial-update',+ schema: UserInterviewsPartialUpdateSchema,+ handler: async (context: Context, params: z.infer<typeof UserInterviewsPartialUpdateSchema>) => {+ const projectId = await context.stateManager.getProjectId()+ const body: Record<string, unknown> = {}+ if (params.classifications !== undefined) {+ body['classifications'] = params.classifications+ }+ const result = await context.api.request<Schemas.UserInterview>({+ method: 'PATCH',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/user_interviews/${encodeURIComponent(String(params.id))}/`,+ body,+ })+ return result+ },+})+const UserInterviewsRetrieveSchema = UserInterviewsRetrieveParams.omit({ project_id: true })const userInterviewsRetrieve = (): ToolBase<typeof UserInterviewsRetrieveSchema, Schemas.UserInterview> => ({@@ -445,6 +470,9 @@ const userInterviewsSearch = (): ToolBase<typeof UserInterviewsSearchSchema, Schif (params.topic_id !== undefined) {body['topic_id'] = params.topic_id}+ if (params.classifications !== undefined) {+ body['classifications'] = params.classifications+ }if (params.limit !== undefined) {body['limit'] = params.limit}@@ -473,6 +501,7 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {'user-interview-topics-retrieve': userInterviewTopicsRetrieve,'user-interview-topics-send-invites': userInterviewTopicsSendInvites,'user-interviews-list': userInterviewsList,+ 'user-interviews-partial-update': userInterviewsPartialUpdate,'user-interviews-retrieve': userInterviewsRetrieve,'user-interviews-search': userInterviewsSearch,}