: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(signals): add MCP tool to edit report title and summary (#65850)
Oliver Brownef74f4f67fb55
diff --git a/frontend/src/scenes/inbox/__mocks__/inboxMocks.ts b/frontend/src/scenes/inbox/__mocks__/inboxMocks.tsindex 97e3e40947ef..81b215755ca8 100644--- a/frontend/src/scenes/inbox/__mocks__/inboxMocks.ts+++ b/frontend/src/scenes/inbox/__mocks__/inboxMocks.ts@@ -355,6 +355,29 @@ export function mockArtefacts(reportId: string): { results: any[]; count: numbercreated_at: BASE_DATE,task_id: `${reportId}-task-impl`,},+ // Human edits to the report's title / summary are logged as their own artefacts.+ {+ id: `${reportId}-title`,+ type: 'title_change',+ content: {+ old_title: 'Invite flow error',+ new_title: 'Empty recipient rows crash team invites',+ },+ created_at: BASE_DATE,+ created_by: { id: 1, uuid: 'u-1', email: '[email protected]', first_name: 'Octo', last_name: 'Cat' },+ },+ {+ id: `${reportId}-summary`,+ type: 'summary_change',+ content: {+ old_summary: 'Users hit an error when inviting their team.',+ new_summary:+ 'Submitting the invite form with an empty recipient row returns a `500` from `/api/invites`. ' ++ 'The gap is missing client-side validation before submit.',+ },+ created_at: BASE_DATE,+ created_by: { id: 1, uuid: 'u-1', email: '[email protected]', first_name: 'Octo', last_name: 'Cat' },+ },]return { results, count: results.length }}diff --git a/frontend/src/scenes/inbox/components/detail/ArtefactLogList.tsx b/frontend/src/scenes/inbox/components/detail/ArtefactLogList.tsxindex 70eb17e041ab..4f7ccccbbc63 100644--- a/frontend/src/scenes/inbox/components/detail/ArtefactLogList.tsx+++ b/frontend/src/scenes/inbox/components/detail/ArtefactLogList.tsx@@ -27,7 +27,9 @@ import {LineReferenceContent,NoteContent,SignalFindingContent,+ SummaryChangeContent,TaskRunArtefactContent,+ TitleChangeContent,} from './artefactTypes'/** Map a file extension to a CodeSnippet language for syntax highlighting; falls back to plain text. */@@ -153,6 +155,80 @@ function CollapsibleNote({ note, author }: { note: string; author?: string }): J)}+/**+ * A `title_change` / `summary_change` artefact: shows the value the report now carries, with the+ * previous value tucked behind a "Show previous" toggle (omitted when the field had no prior value).+ * `markdown` renders the body as markdown — summaries are descriptions, titles are plain text.+ * `collapse` hides the new value behind a one-line preview (summaries can be long; titles are short+ * enough to show inline).+ */+function ContentChangeBody({+ previous,+ current,+ markdown = false,+ collapse = false,+}: {+ previous?: string | null+ current: string+ markdown?: boolean+ collapse?: boolean+}): JSX.Element {+ const [expanded, setExpanded] = useState(false)+ const [showPrevious, setShowPrevious] = useState(false)+ const renderText = (text: string, muted: boolean): JSX.Element => {+ const color = muted ? 'text-secondary' : 'text-default'+ return markdown ? (+ <LemonMarkdown className={`text-xs leading-normal ${color}`} disableImages>+ {text}+ </LemonMarkdown>+ ) : (+ <span className={`text-xs ${color}`}>{text}</span>+ )+ }+ const previousToggle = previous?.trim() ? (+ <>+ <button+ type="button"+ onClick={() => setShowPrevious((v) => !v)}+ className="flex w-fit items-center gap-1 rounded px-1 py-0.5 text-xs text-secondary transition-colors hover:bg-fill-highlight-50"+ >+ {showPrevious ? <IconChevronDown /> : <IconChevronRight />}+ {showPrevious ? 'Hide previous' : 'Show previous'}+ </button>+ {showPrevious ? <div className="min-w-0">{renderText(previous, true)}</div> : null}+ </>+ ) : null++ if (collapse) {+ const preview = current.split('\n').find((line) => line.trim()) ?? current+ return (+ <div className="flex w-full min-w-0 flex-col gap-1">+ <button+ type="button"+ onClick={() => setExpanded((v) => !v)}+ className="flex w-full min-w-0 items-center gap-1 rounded px-1 py-0.5 text-left text-xs text-secondary transition-colors hover:bg-fill-highlight-50"+ >+ {expanded ? <IconChevronDown className="shrink-0" /> : <IconChevronRight className="shrink-0" />}+ <span className="truncate">{expanded ? 'Hide new value' : preview}</span>+ </button>+ {expanded ? (+ <>+ <div className="min-w-0">{renderText(current, false)}</div>+ {previousToggle}+ </>+ ) : null}+ </div>+ )+ }++ return (+ <div className="flex w-full min-w-0 flex-col gap-1">+ <div className="min-w-0">{renderText(current, false)}</div>+ {previousToggle}+ </div>+ )+}+/** The suggested-reviewers list as a point-in-time log entry. */function ReviewersBody({ reviewers }: { reviewers: EnrichedReviewer[] }): JSX.Element {if (reviewers.length === 0) {@@ -293,6 +369,14 @@ function ArtefactBody({}case 'suggested_reviewers':return <ReviewersBody reviewers={(content as unknown as EnrichedReviewer[]) ?? []} />+ case 'title_change': {+ const c = content as TitleChangeContent+ return <ContentChangeBody previous={c.old_title} current={c.new_title ?? ''} />+ }+ case 'summary_change': {+ const c = content as SummaryChangeContent+ return <ContentChangeBody previous={c.old_summary} current={c.new_summary ?? ''} markdown collapse />+ }case 'dismissal': {const c = content as DismissalContentreturn (diff --git a/frontend/src/scenes/inbox/components/detail/artefactTypes.ts b/frontend/src/scenes/inbox/components/detail/artefactTypes.tsindex 173786c25be7..7c520a453097 100644--- a/frontend/src/scenes/inbox/components/detail/artefactTypes.ts+++ b/frontend/src/scenes/inbox/components/detail/artefactTypes.ts@@ -58,6 +58,16 @@ export interface DismissalContent {note?: string}+export interface TitleChangeContent {+ old_title?: string | null+ new_title: string+}++export interface SummaryChangeContent {+ old_summary?: string | null+ new_summary: string+}+// ── Type labels ──────────────────────────────────────────────────────────────────────────────/** Human label for each artefact type as it reads in the activity log header. */@@ -75,6 +85,8 @@ export const ARTEFACT_TYPE_LABELS: Record<string, string> = {repo_selection: 'Repo selected',dismissal: 'Report dismissed',video_segment: 'Video segment',+ title_change: 'Title edited',+ summary_change: 'Summary edited',}export function artefactTypeLabel(type: string): string {diff --git a/products/signals/backend/artefact_schemas.py b/products/signals/backend/artefact_schemas.pyindex 0b19d1be9054..423cebaedd3b 100644--- a/products/signals/backend/artefact_schemas.py+++ b/products/signals/backend/artefact_schemas.py@@ -390,6 +390,50 @@ class NoteArtefact(BaseModel):return v+class TitleChange(BaseModel):+ """Content schema for a `title_change` artefact: a record of an edit to the report's title.++ Appended automatically by the report edit path whenever the title actually changes, capturing+ the value before and after so the report carries an audit trail of who renamed it and when.+ Never written through the generic artefact API (it is read-only there) — it only ever reflects+ a real edit that was applied to the report.+ """++ old_title: str | None = Field(+ default=None, description="The report's title before this edit (null if it had no title)."+ )+ new_title: str = Field(description="The report's title after this edit.")++ @field_validator("new_title")+ @classmethod+ def new_title_must_not_be_empty(cls, v: str) -> str:+ if not v.strip():+ raise ValueError("must not be empty or whitespace-only")+ return v+++class SummaryChange(BaseModel):+ """Content schema for a `summary_change` artefact: a record of an edit to the report's summary+ (its human-facing description).++ Appended automatically by the report edit path whenever the summary actually changes, capturing+ the value before and after. Like `title_change`, it is read-only through the generic artefact+ API and only ever reflects a real edit applied to the report.+ """++ old_summary: str | None = Field(+ default=None, description="The report's summary before this edit (null if it had no summary)."+ )+ new_summary: str = Field(description="The report's summary after this edit.")++ @field_validator("new_summary")+ @classmethod+ def new_summary_must_not_be_empty(cls, v: str) -> str:+ if not v.strip():+ raise ValueError("must not be empty or whitespace-only")+ return v++# ── Type mapping ─────────────────────────────────────────────────────────────────# Content models that describe the report's current state (latest row of each type wins) vs@@ -398,7 +442,7 @@ class NoteArtefact(BaseModel):StatusArtefactContent = (SafetyJudgment | ActionabilityAssessment | PriorityAssessment | RepoSelectionResult | SuggestedReviewers)-LogArtefactContent = CodeReference | Commit | TaskRunArtefact | NoteArtefact+LogArtefactContent = CodeReference | Commit | TaskRunArtefact | NoteArtefact | TitleChange | SummaryChangeArtefactContent = StatusArtefactContent | LogArtefactContent | SignalFinding | Dismissal | VideoSegment# Keys are `SignalReportArtefact.ArtefactType` values, kept as plain strings so this module stays@@ -416,6 +460,8 @@ ARTEFACT_CONTENT_SCHEMAS: Mapping[str, type[BaseModel]] = {"commit": Commit,"task_run": TaskRunArtefact,"note": NoteArtefact,+ "title_change": TitleChange,+ "summary_change": SummaryChange,}_ARTEFACT_TYPE_BY_MODEL: Mapping[type[BaseModel], str] = {model: t for t, model in ARTEFACT_CONTENT_SCHEMAS.items()}@@ -424,7 +470,11 @@ _ARTEFACT_TYPE_BY_MODEL: Mapping[type[BaseModel], str] = {model: t for t, model# (`dict | list`, so even `{}` validates) that predates the typed-content contract; accepting writes# would let callers persist arbitrary or empty payloads. It stays readable so stored legacy rows# still parse, but new ones can never be created or updated through the API.-NON_WRITABLE_ARTEFACT_TYPES: frozenset[str] = frozenset({"video_segment"})+# `title_change` / `summary_change` are system-generated edit-history records: the report edit path+# is their only writer, so accepting them through the generic API would let a caller fabricate edits+# that never happened. They stay readable (and so show up in the report's artefact log) but cannot+# be created or edited directly.+NON_WRITABLE_ARTEFACT_TYPES: frozenset[str] = frozenset({"video_segment", "title_change", "summary_change"})def artefact_type_for(content: BaseModel) -> str:diff --git a/products/signals/backend/migrations/0053_alter_signalreportartefact_type.py b/products/signals/backend/migrations/0053_alter_signalreportartefact_type.pynew file mode 100644index 000000000000..af7e8ddfd3d5--- /dev/null+++ b/products/signals/backend/migrations/0053_alter_signalreportartefact_type.py@@ -0,0 +1,33 @@+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("signals", "0052_signalscoutrun_edited_report_ids"),+ ]++ operations = [+ migrations.AlterField(+ model_name="signalreportartefact",+ name="type",+ field=models.CharField(+ choices=[+ ("video_segment", "Video Segment"),+ ("safety_judgment", "Safety Judgment"),+ ("actionability_judgment", "Actionability Judgment"),+ ("priority_judgment", "Priority Judgment"),+ ("signal_finding", "Signal Finding"),+ ("repo_selection", "Repo Selection"),+ ("suggested_reviewers", "Suggested Reviewers"),+ ("dismissal", "Dismissal"),+ ("code_reference", "Code Reference"),+ ("commit", "Commit"),+ ("task_run", "Task Run"),+ ("note", "Note"),+ ("title_change", "Title Change"),+ ("summary_change", "Summary Change"),+ ],+ max_length=100,+ ),+ ),+ ]diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txtindex 9ad92bc046ae..4bc5f6413950 100644--- a/products/signals/backend/migrations/max_migration.txt+++ b/products/signals/backend/migrations/max_migration.txt@@ -1 +1 @@-0052_signalscoutrun_edited_report_ids+0053_alter_signalreportartefact_typediff --git a/products/signals/backend/models.py b/products/signals/backend/models.pyindex 387126ea88fa..6d4dcb54fc87 100644--- a/products/signals/backend/models.py+++ b/products/signals/backend/models.py@@ -731,6 +731,8 @@ class SignalReportArtefact(UUIDModel):COMMIT = "commit"TASK_RUN = "task_run"NOTE = "note"+ TITLE_CHANGE = "title_change"+ SUMMARY_CHANGE = "summary_change"# Every artefact is an append-only, point-in-time log entry — nothing is mutated in place by# the producers. The two sets below classify *what an entry means*, not how it is written:@@ -739,7 +741,7 @@ class SignalReportArtefact(UUIDModel):# report's *current* status is the latest row of that type by `created_at` (the serializer# derives priority/actionability/reviewers with `order_by("-created_at")[:1]` subqueries).# - log artefacts record discrete work done on a report (code references, commits,- # task runs, notes). Appended via `add_log`.+ # task runs, notes, and title/summary edits). Appended via `add_log`.# `signal_finding` is appended too, but its logical identity is `(report, content.signal_id)`:# a new signal yields a new entry, re-researching an existing signal appends a new version# (latest per signal_id wins). It is intentionally in neither set.@@ -758,6 +760,8 @@ class SignalReportArtefact(UUIDModel):ArtefactType.COMMIT,ArtefactType.TASK_RUN,ArtefactType.NOTE,+ ArtefactType.TITLE_CHANGE,+ ArtefactType.SUMMARY_CHANGE,})diff --git a/products/signals/backend/test/test_artefact_schemas.py b/products/signals/backend/test/test_artefact_schemas.pyindex 6d35763d6008..c1a6346a8803 100644--- a/products/signals/backend/test/test_artefact_schemas.py+++ b/products/signals/backend/test/test_artefact_schemas.py@@ -11,7 +11,9 @@ from products.signals.backend.artefact_schemas import (CodeReference,Commit,NoteArtefact,+ SummaryChange,TaskRunArtefact,+ TitleChange,artefact_type_for,parse_artefact_content,)@@ -88,6 +90,20 @@ class TestArtefactSchemas(SimpleTestCase):with self.assertRaises(ValidationError):NoteArtefact(note=" ")+ def test_title_change_allows_null_old_title(self):+ # A report with no prior title (null) is a valid before-state for the first edit.+ change = TitleChange(new_title="A title")+ assert change.old_title is None+ assert change.new_title == "A title"++ def test_title_change_rejects_blank_new_title(self):+ with self.assertRaises(ValidationError):+ TitleChange(old_title="old", new_title=" ")++ def test_summary_change_rejects_blank_new_summary(self):+ with self.assertRaises(ValidationError):+ SummaryChange(old_summary="old", new_summary=" ")+class TestValidateArtefactContent(SimpleTestCase):@parameterized.expand(@@ -112,6 +128,8 @@ class TestValidateArtefactContent(SimpleTestCase):{"repository": "PostHog/posthog", "branch": "b", "commit_sha": "abc123f", "message": "fix: x"},),("task_run", {"task_id": "t1", "run_id": None, "product": "signals", "type": "implementation"}),+ ("title_change", {"old_title": "before", "new_title": "after"}),+ ("summary_change", {"old_summary": None, "new_summary": "after"}),])def test_accepts_valid_content_for_type(self, artefact_type, content):diff --git a/products/signals/backend/test/test_signal_report_api.py b/products/signals/backend/test/test_signal_report_api.pyindex 19a79d31f7a5..be2f03b06b71 100644--- a/products/signals/backend/test/test_signal_report_api.py+++ b/products/signals/backend/test/test_signal_report_api.py@@ -1901,3 +1901,173 @@ class TestSignalReportLegacyTaskArtefactList(APIBaseTest):# The gate row belongs to `other_report`, so `report`'s log stays empty.assert self._task_runs(str(report.id)) == []assert len(self._task_runs(str(other_report.id))) == 1+++class TestSignalReportContentUpdateAPI(APIBaseTest):+ def _url(self, report_id: str) -> str:+ return f"/api/projects/{self.team.id}/signals/reports/{report_id}/"++ def _create_report(self, team=None, report_status=SignalReport.Status.READY) -> SignalReport:+ return SignalReport.objects.create(+ team=team or self.team,+ status=report_status,+ title="Original title",+ summary="Original summary",+ signal_count=3,+ total_weight=1.5,+ )++ def test_update_title_and_summary(self):+ report = self._create_report()+ response = self.client.patch(+ self._url(str(report.id)),+ data={"title": "New title", "summary": "New summary"},+ format="json",+ )+ assert response.status_code == status.HTTP_200_OK+ body = response.json()+ assert body["title"] == "New title"+ assert body["summary"] == "New summary"+ report.refresh_from_db()+ assert report.title == "New title"+ assert report.summary == "New summary"++ def test_update_title_only_leaves_summary_unchanged(self):+ report = self._create_report()+ response = self.client.patch(self._url(str(report.id)), data={"title": "Just the title"}, format="json")+ assert response.status_code == status.HTTP_200_OK+ report.refresh_from_db()+ assert report.title == "Just the title"+ assert report.summary == "Original summary"++ def test_update_summary_trims_whitespace(self):+ report = self._create_report()+ response = self.client.patch(self._url(str(report.id)), data={"summary": " padded "}, format="json")+ assert response.status_code == status.HTTP_200_OK+ report.refresh_from_db()+ assert report.summary == "padded"++ def test_update_with_no_editable_fields_is_rejected(self):+ report = self._create_report()+ response = self.client.patch(self._url(str(report.id)), data={}, format="json")+ assert response.status_code == status.HTTP_400_BAD_REQUEST+ report.refresh_from_db()+ assert report.title == "Original title"++ @parameterized.expand([("blank_title", "title", ""), ("blank_summary", "summary", "")])+ def test_update_rejects_blank_values(self, _name, field, value):+ report = self._create_report()+ response = self.client.patch(self._url(str(report.id)), data={field: value}, format="json")+ assert response.status_code == status.HTTP_400_BAD_REQUEST++ def test_update_rejects_overlong_title(self):+ report = self._create_report()+ response = self.client.patch(self._url(str(report.id)), data={"title": "x" * 301}, format="json")+ assert response.status_code == status.HTTP_400_BAD_REQUEST++ def test_update_other_teams_report_returns_404(self):+ other_team = Team.objects.create(organization=self.organization, name="Other Team")+ report = self._create_report(team=other_team)+ response = self.client.patch(self._url(str(report.id)), data={"title": "Nope"}, format="json")+ assert response.status_code == status.HTTP_404_NOT_FOUND+ report.refresh_from_db()+ assert report.title == "Original title"++ def test_update_deleted_report_returns_404(self):+ report = self._create_report(report_status=SignalReport.Status.DELETED)+ response = self.client.patch(self._url(str(report.id)), data={"title": "Nope"}, format="json")+ assert response.status_code == status.HTTP_404_NOT_FOUND++ def test_update_suppressed_report_returns_404(self):+ # Suppressed reports are hidden from mutating-by-id actions unless an explicit status+ # filter asks for them, matching the delete/reingest contract.+ report = self._create_report(report_status=SignalReport.Status.SUPPRESSED)+ response = self.client.patch(self._url(str(report.id)), data={"title": "Nope"}, format="json")+ assert response.status_code == status.HTTP_404_NOT_FOUND++ def _artefacts_url(self, report_id: str) -> str:+ return f"/api/projects/{self.team.id}/signals/reports/{report_id}/artefacts/"++ def _create_task(self, team=None) -> "Task":+ Task = apps.get_model("tasks", "Task")+ return Task.objects.create(+ team=team or self.team,+ title="task",+ description="desc",+ origin_product=Task.OriginProduct.SIGNAL_REPORT,+ )++ def _artefacts(self, report: SignalReport, artefact_type: str) -> list[SignalReportArtefact]:+ return list(report.artefacts.filter(type=artefact_type).order_by("created_at"))++ def test_update_title_records_title_change_artefact(self):+ report = self._create_report()+ self.client.patch(self._url(str(report.id)), data={"title": "New title"}, format="json")++ artefacts = self._artefacts(report, SignalReportArtefact.ArtefactType.TITLE_CHANGE)+ assert len(artefacts) == 1+ content = json.loads(artefacts[0].content)+ assert content == {"old_title": "Original title", "new_title": "New title"}+ # Attributed to the requesting user, not a task, when no task header is present.+ assert artefacts[0].created_by_id == self.user.id+ assert artefacts[0].task_id is None++ def test_update_summary_records_summary_change_artefact(self):+ report = self._create_report()+ self.client.patch(self._url(str(report.id)), data={"summary": "New summary"}, format="json")++ artefacts = self._artefacts(report, SignalReportArtefact.ArtefactType.SUMMARY_CHANGE)+ assert len(artefacts) == 1+ content = json.loads(artefacts[0].content)+ assert content == {"old_summary": "Original summary", "new_summary": "New summary"}++ def test_update_both_records_one_artefact_per_field(self):+ report = self._create_report()+ self.client.patch(+ self._url(str(report.id)),+ data={"title": "New title", "summary": "New summary"},+ format="json",+ )+ assert len(self._artefacts(report, SignalReportArtefact.ArtefactType.TITLE_CHANGE)) == 1+ assert len(self._artefacts(report, SignalReportArtefact.ArtefactType.SUMMARY_CHANGE)) == 1++ def test_no_op_edit_records_no_artefact(self):+ # Setting a field to its current value isn't a change, so it leaves no edit-history entry.+ report = self._create_report()+ response = self.client.patch(+ self._url(str(report.id)),+ data={"title": "Original title", "summary": "New summary"},+ format="json",+ )+ assert response.status_code == status.HTTP_200_OK+ assert self._artefacts(report, SignalReportArtefact.ArtefactType.TITLE_CHANGE) == []+ assert len(self._artefacts(report, SignalReportArtefact.ArtefactType.SUMMARY_CHANGE)) == 1++ def test_edit_attributed_to_task_when_header_present(self):+ # Mirrors the other artefact-writing paths: an agent's task header overrides user attribution.+ report = self._create_report()+ task = self._create_task()+ response = self.client.patch(+ self._url(str(report.id)),+ data={"title": "Agent title"},+ format="json",+ headers={"X-PostHog-Task-Id": str(task.id)},+ )+ assert response.status_code == status.HTTP_200_OK+ artefacts = self._artefacts(report, SignalReportArtefact.ArtefactType.TITLE_CHANGE)+ assert len(artefacts) == 1+ assert str(artefacts[0].task_id) == str(task.id)+ assert artefacts[0].created_by_id is None++ @parameterized.expand([("title_change",), ("summary_change",)])+ def test_change_artefacts_are_read_only_via_artefact_api(self, artefact_type):+ # Edit-history artefacts are system-generated; the generic artefact write API must refuse+ # them so a caller can't fabricate edits that never happened.+ report = self._create_report()+ response = self.client.post(+ self._artefacts_url(str(report.id)),+ data=json.dumps({"artefact_type": artefact_type, "content": {}}),+ content_type="application/json",+ )+ assert response.status_code == status.HTTP_400_BAD_REQUEST+ assert "read-only" in response.json()["error"]diff --git a/products/signals/backend/views.py b/products/signals/backend/views.pyindex 4bdebe00c640..a1b635e4ce8d 100644--- a/products/signals/backend/views.py+++ b/products/signals/backend/views.py@@ -58,6 +58,8 @@ from products.signals.backend.artefact_schemas import (ArtefactContentValidationError,Dismissal,SuggestedReviewers,+ SummaryChange,+ TitleChange,parse_artefact_content,)from products.signals.backend.facade.api import emit_signal@@ -401,6 +403,11 @@ SIGNAL_REPORT_MAX_SNOOZE_FOR = 100_000# Upper bound on how many reports a single bulk transition may touch. Keeps one call# from fanning out into an unbounded write; callers page through larger sets.SIGNAL_REPORT_BULK_STATE_MAX_IDS = 100+# Bounds on the editable human-facing report fields. `title`/`summary` are TextFields on the+# model (so unbounded in the DB), but the write API caps them to keep an edit from storing an+# absurdly long title or summary.+SIGNAL_REPORT_TITLE_MAX_LENGTH = 300+SIGNAL_REPORT_SUMMARY_MAX_LENGTH = 10_000# Canonical dismissal reason codes, mirrored from the inbox UI source of truth at# frontend/src/scenes/inbox/utils/dismissalReasons.ts (itself a port of desktop's@@ -516,6 +523,43 @@ class SignalReportBulkStateResponseSerializer(serializers.Serializer):not_found_count = serializers.IntegerField(help_text="Number of requested ids not visible to the caller.")+class SignalReportContentUpdateSerializer(serializers.Serializer):+ """Editable human-facing fields on a signal report (PATCH).++ Both fields are optional so a caller can change either independently, but at least one+ must be supplied. Every other report field — status, weights, judgments — is owned by the+ signals pipeline and is deliberately not writable here.+ """++ # min_length=1 (not just allow_blank=False) so the non-empty constraint surfaces as+ # `minLength: 1` in the generated OpenAPI/Zod schema — otherwise clients only learn an+ # empty string is invalid when the server rejects it.+ title = serializers.CharField(+ required=False,+ allow_blank=False,+ trim_whitespace=True,+ min_length=1,+ max_length=SIGNAL_REPORT_TITLE_MAX_LENGTH,+ help_text="New human-facing title for the report. Omit to leave the title unchanged.",+ )+ summary = serializers.CharField(+ required=False,+ allow_blank=False,+ trim_whitespace=True,+ min_length=1,+ max_length=SIGNAL_REPORT_SUMMARY_MAX_LENGTH,+ help_text=(+ "New summary (the report's description) explaining what the report is about. "+ "Omit to leave the summary unchanged."+ ),+ )++ def validate(self, attrs: dict) -> dict:+ if "title" not in attrs and "summary" not in attrs:+ raise serializers.ValidationError("Provide at least one of 'title' or 'summary' to update.")+ return attrs++@extend_schema_view(destroy=extend_schema(exclude=True),)@@ -992,6 +1036,57 @@ class SignalReportViewSet(serializer = self.get_serializer(report, context=self._enriched_report_context(report))return Response(serializer.data)+ @validated_request(+ request_serializer=SignalReportContentUpdateSerializer,+ responses={+ 200: OpenApiResponse(response=SignalReportSerializer, description="Report updated."),+ 400: OpenApiResponse(description="Neither title nor summary supplied, or a value failed validation."),+ 404: OpenApiResponse(description="Report not found for this project."),+ },+ summary="Edit a report's title or summary",+ description=(+ "Edit the human-facing title and/or summary (description) of a signal report, addressed "+ "by id. Both fields are optional — supply only the ones you want to change; at least one "+ "is required. Every other report field (status, weights, judgments) is managed by the "+ "signals pipeline and cannot be set here. Returns the full updated report."+ ),+ operation_id="signals_reports_partial_update",+ )+ def partial_update(self, request: ValidatedRequest, *args, **kwargs) -> Response:+ report = cast(SignalReport, self.get_object())+ data = request.validated_data+ # Attribution mirrors the other artefact-writing paths (suggested reviewers, commit/task_run):+ # the edit is the agent's task when an `X-PostHog-Task-Id` header is present, otherwise the+ # requesting user. Resolved up front so a bad task header 400s before we mutate anything.+ attribution = resolve_request_attribution(request, self.team.id)+ update_fields: list[str] = []+ # Each real change is logged as its own append-only edit-history artefact capturing the+ # before/after, so the report carries an audit trail of human/agent title & summary edits.+ edit_artefacts: list[TitleChange | SummaryChange] = []+ if "title" in data and data["title"] != report.title:+ edit_artefacts.append(TitleChange(old_title=report.title, new_title=data["title"]))+ report.title = data["title"]+ update_fields.append("title")+ if "summary" in data and data["summary"] != report.summary:+ edit_artefacts.append(SummaryChange(old_summary=report.summary, new_summary=data["summary"]))+ report.summary = data["summary"]+ update_fields.append("summary")++ if update_fields:+ # `updated_at` is auto_now, but `update_fields` saves only the listed columns, so add it+ # explicitly to keep the edit timestamped.+ update_fields.append("updated_at")+ with transaction.atomic():+ report.save(update_fields=update_fields)+ for content in edit_artefacts:+ SignalReportArtefact.add_log(+ team_id=self.team.id,+ report_id=str(report.id),+ content=content,+ attribution=attribution,+ )+ return Response(SignalReportSerializer(report, context=self._enriched_report_context(report)).data)+@extend_schema(parameters=[OpenApiParameter(diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.tsindex e32a90d9efc2..4283d87fbfe8 100644--- a/products/signals/frontend/generated/api.schemas.ts+++ b/products/signals/frontend/generated/api.schemas.ts@@ -118,6 +118,28 @@ export interface PaginatedSignalReportListApi {results: SignalReportApi[]}+/**+ * Editable human-facing fields on a signal report (PATCH).+ *+ * Both fields are optional so a caller can change either independently, but at least one+ * must be supplied. Every other report field — status, weights, judgments — is owned by the+ * signals pipeline and is deliberately not writable here.+ */+export interface PatchedSignalReportContentUpdateApi {+ /**+ * New human-facing title for the report. Omit to leave the title unchanged.+ * @minLength 1+ * @maxLength 300+ */+ title?: string+ /**+ * New summary (the report's description) explaining what the report is about. Omit to leave the summary unchanged.+ * @minLength 1+ * @maxLength 10000+ */+ summary?: string+}+/*** * `suppressed` - suppressed* * `potential` - potential@@ -189,6 +211,8 @@ export interface SignalReportStateRequestApi {* * `commit` - Commit* * `task_run` - Task Run* * `note` - Note+ * * `title_change` - Title Change+ * * `summary_change` - Summary Change*/export type SignalReportArtefactTypeEnumApi =(typeof SignalReportArtefactTypeEnumApi)[keyof typeof SignalReportArtefactTypeEnumApi]@@ -206,6 +230,8 @@ export const SignalReportArtefactTypeEnumApi = {Commit: 'commit',TaskRun: 'task_run',Note: 'note',+ TitleChange: 'title_change',+ SummaryChange: 'summary_change',} as constexport interface _UserApi {diff --git a/products/signals/frontend/generated/api.ts b/products/signals/frontend/generated/api.tsindex 135308e59fc2..4be281c9a451 100644--- a/products/signals/frontend/generated/api.ts+++ b/products/signals/frontend/generated/api.ts@@ -23,6 +23,7 @@ import type {PaginatedSignalReportListApi,PaginatedSignalSourceConfigListApi,PatchedSignalReportArtefactLogUpdateApi,+ PatchedSignalReportContentUpdateApi,PatchedSignalScoutConfigApi,PatchedSignalSourceConfigApi,PauseResponseApi,@@ -183,6 +184,28 @@ export const signalsReportsRetrieve = async (})}+export const getSignalsReportsPartialUpdateUrl = (projectId: string, id: string) => {+ return `/api/projects/${projectId}/signals/reports/${id}/`+}++/**+ * Edit the human-facing title and/or summary (description) of a signal report, addressed by id. Both fields are optional — supply only the ones you want to change; at least one is required. Every other report field (status, weights, judgments) is managed by the signals pipeline and cannot be set here. Returns the full updated report.+ * @summary Edit a report's title or summary+ */+export const signalsReportsPartialUpdate = async (+ projectId: string,+ id: string,+ patchedSignalReportContentUpdateApi?: PatchedSignalReportContentUpdateApi,+ options?: RequestInit+): Promise<SignalReportApi> => {+ return apiMutator<SignalReportApi>(getSignalsReportsPartialUpdateUrl(projectId, id), {+ ...options,+ method: 'PATCH',+ headers: { 'Content-Type': 'application/json', ...options?.headers },+ body: JSON.stringify(patchedSignalReportContentUpdateApi),+ })+}+export const getSignalsReportsStateCreateUrl = (projectId: string, id: string) => {return `/api/projects/${projectId}/signals/reports/${id}/state/`}diff --git a/products/signals/frontend/generated/api.zod.ts b/products/signals/frontend/generated/api.zod.tsindex 359d361ba3cd..e78431527044 100644--- a/products/signals/frontend/generated/api.zod.ts+++ b/products/signals/frontend/generated/api.zod.ts@@ -18,6 +18,35 @@ export const SignalsProcessingPauseUpdateBody = /* @__PURE__ */ zod.object({.describe('Pause the grouping pipeline until this timestamp (ISO 8601).'),})+/**+ * Edit the human-facing title and/or summary (description) of a signal report, addressed by id. Both fields are optional — supply only the ones you want to change; at least one is required. Every other report field (status, weights, judgments) is managed by the signals pipeline and cannot be set here. Returns the full updated report.+ * @summary Edit a report's title or summary+ */+export const signalsReportsPartialUpdateBodyTitleMax = 300++export const signalsReportsPartialUpdateBodySummaryMax = 10000++export const SignalsReportsPartialUpdateBody = /* @__PURE__ */ zod+ .object({+ title: zod+ .string()+ .min(1)+ .max(signalsReportsPartialUpdateBodyTitleMax)+ .optional()+ .describe('New human-facing title for the report. Omit to leave the title unchanged.'),+ summary: zod+ .string()+ .min(1)+ .max(signalsReportsPartialUpdateBodySummaryMax)+ .optional()+ .describe(+ "New summary (the report's description) explaining what the report is about. Omit to leave the summary unchanged."+ ),+ })+ .describe(+ 'Editable human-facing fields on a signal report (PATCH).\n\nBoth fields are optional so a caller can change either independently, but at least one\nmust be supplied. Every other report field — status, weights, judgments — is owned by the\nsignals pipeline and is deliberately not writable here.'+ )+/*** Transition a report to a new state. The model validates allowed transitions.*diff --git a/products/signals/mcp/tools.yaml b/products/signals/mcp/tools.yamlindex e920a9d9e979..1ded0b1424ac 100644--- a/products/signals/mcp/tools.yaml+++ b/products/signals/mcp/tools.yaml@@ -229,6 +229,24 @@ tools:survives later transitions. Returns 409 if the transition is not allowed from the report's current status.To transition several reports at once, use `inbox-reports-bulk-set-state` instead of calling this perreport.+ inbox-reports-update:+ operation: signals_reports_partial_update+ enabled: true+ scopes:+ - task:write+ annotations:+ readOnly: false+ destructive: false+ idempotent: true+ enrich_url: '{id}'+ title: Edit a signal report's title or summary+ description: >+ Edit the human-facing title and/or summary (description) of a signal report, addressed by id. Both fields+ are optional — pass only the ones you want to change, but supply at least one. Use this to clarify a+ report's title or rewrite its summary when you understand the underlying issue better than the+ auto-generated text does. Every other field (status, weights, priority/actionability judgments) is managed+ by the signals pipeline and cannot be set here — change a report's state with inbox-reports-set-state and+ its judgments by appending artefacts with inbox-report-artefacts-create. Returns the full updated report.inbox-source-configs-create:operation: signals_source_configs_createenabled: truediff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 5df97e4b20e2..fb2c09d4d0c8 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -3941,6 +3941,20 @@"readOnlyHint": false}},+ "inbox-reports-update": {+ "description": "Edit the human-facing title and/or summary (description) of a signal report, addressed by id. Both fields are optional — pass only the ones you want to change, but supply at least one. Use this to clarify a report's title or rewrite its summary when you understand the underlying issue better than the auto-generated text does. Every other field (status, weights, priority/actionability judgments) is managed by the signals pipeline and cannot be set here — change a report's state with inbox-reports-set-state and its judgments by appending artefacts with inbox-report-artefacts-create. Returns the full updated report.",+ "category": "Signals",+ "feature": "signals",+ "summary": "Edit a signal report's title or summary",+ "title": "Edit a signal report's title or summary",+ "required_scopes": ["task:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": false+ }+ },"inbox-source-configs-create": {"description": "Create a signal source config for the current project, switching an inbox signal source on. A source ties a `source_product` to a `source_type` and an `enabled` flag. Valid `source_product` values: session_replay, llm_analytics, github, linear, zendesk, conversations, error_tracking, pganalyze, signals_scout, logs. Valid `source_type` values: session_analysis_cluster, evaluation, issue, ticket, issue_created, issue_reopened, issue_spiking, cross_source_issue, alert_state_change. The Signals scout source is ON BY DEFAULT — scout findings reach the inbox with no config row needed. The only reason to create a `source_product=signals_scout`, `source_type=cross_source_issue` row is to OPT OUT: create it with `enabled=false` (the per-scout `emit` flag is set separately via `signals-scout-config-update`). There is at most one config per (source_product, source_type) per project; if one already exists, update it instead. Enabling the session_analysis_cluster source requires the organization to have approved AI data processing.","category": "Signals",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex ff5424b84c26..afad6fb4c914 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -4223,6 +4223,20 @@"readOnlyHint": false}},+ "inbox-reports-update": {+ "description": "Edit the human-facing title and/or summary (description) of a signal report, addressed by id. Both fields are optional — pass only the ones you want to change, but supply at least one. Use this to clarify a report's title or rewrite its summary when you understand the underlying issue better than the auto-generated text does. Every other field (status, weights, priority/actionability judgments) is managed by the signals pipeline and cannot be set here — change a report's state with inbox-reports-set-state and its judgments by appending artefacts with inbox-report-artefacts-create. Returns the full updated report.",+ "category": "Signals",+ "feature": "signals",+ "summary": "Edit a signal report's title or summary",+ "title": "Edit a signal report's title or summary",+ "required_scopes": ["task:write"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": false+ }+ },"inbox-source-configs-create": {"description": "Create a signal source config for the current project, switching an inbox signal source on. A source ties a `source_product` to a `source_type` and an `enabled` flag. Valid `source_product` values: session_replay, llm_analytics, github, linear, zendesk, conversations, error_tracking, pganalyze, signals_scout, logs. Valid `source_type` values: session_analysis_cluster, evaluation, issue, ticket, issue_created, issue_reopened, issue_spiking, cross_source_issue, alert_state_change. The Signals scout source is ON BY DEFAULT — scout findings reach the inbox with no config row needed. The only reason to create a `source_product=signals_scout`, `source_type=cross_source_issue` row is to OPT OUT: create it with `enabled=false` (the per-scout `emit` flag is set separately via `signals-scout-config-update`). There is at most one config per (source_product, source_type) per project; if one already exists, update it instead. Enabling the session_analysis_cluster source requires the organization to have approved AI data processing.","category": "Signals",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 0211af5a8fab..acdf9e7f9a06 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -32703,6 +32703,8 @@ export namespace Schemas {* * `commit` - Commit* * `task_run` - Task Run* * `note` - Note+ * * `title_change` - Title Change+ * * `summary_change` - Summary Change*/export type SignalReportArtefactTypeEnum = typeof SignalReportArtefactTypeEnum[keyof typeof SignalReportArtefactTypeEnum];@@ -32720,6 +32722,8 @@ export namespace Schemas {Commit: 'commit',TaskRun: 'task_run',Note: 'note',+ TitleChange: 'title_change',+ SummaryChange: 'summary_change',} as const;export interface _User {@@ -39935,6 +39939,28 @@ export namespace Schemas {content?: unknown;}+ /**+ * Editable human-facing fields on a signal report (PATCH).+ *+ * Both fields are optional so a caller can change either independently, but at least one+ * must be supplied. Every other report field — status, weights, judgments — is owned by the+ * signals pipeline and is deliberately not writable here.+ */+ export interface PatchedSignalReportContentUpdate {+ /**+ * New human-facing title for the report. Omit to leave the title unchanged.+ * @minLength 1+ * @maxLength 300+ */+ title?: string;+ /**+ * New summary (the report's description) explaining what the report is about. Omit to leave the summary unchanged.+ * @minLength 1+ * @maxLength 10000+ */+ summary?: string;+ }+export type ScoutOriginEnum = typeof ScoutOriginEnum[keyof typeof ScoutOriginEnum];diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.tsindex 8462f96198c3..a9ae6b0d6278 100644--- a/services/mcp/src/generated/signals/api.ts+++ b/services/mcp/src/generated/signals/api.ts@@ -3,7 +3,7 @@* MCP service uses these Zod schemas for generated tool handlers.* To regenerate: hogli build:openapi*- * PostHog API - MCP 30 enabled ops+ * PostHog API - MCP 31 enabled ops* OpenAPI spec version: 1.0.0*/import * as zod from 'zod'@@ -71,6 +71,44 @@ export const SignalsReportsRetrieveParams = /* @__PURE__ */ zod.object({),})+/**+ * Edit the human-facing title and/or summary (description) of a signal report, addressed by id. Both fields are optional — supply only the ones you want to change; at least one is required. Every other report field (status, weights, judgments) is managed by the signals pipeline and cannot be set here. Returns the full updated report.+ * @summary Edit a report's title or summary+ */+export const SignalsReportsPartialUpdateParams = /* @__PURE__ */ zod.object({+ id: zod.string().describe('A UUID string identifying this signal report.'),+ 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 signalsReportsPartialUpdateBodyTitleMax = 300++export const signalsReportsPartialUpdateBodySummaryMax = 10000++export const SignalsReportsPartialUpdateBody = /* @__PURE__ */ zod+ .object({+ title: zod+ .string()+ .min(1)+ .max(signalsReportsPartialUpdateBodyTitleMax)+ .optional()+ .describe('New human-facing title for the report. Omit to leave the title unchanged.'),+ summary: zod+ .string()+ .min(1)+ .max(signalsReportsPartialUpdateBodySummaryMax)+ .optional()+ .describe(+ "New summary (the report's description) explaining what the report is about. Omit to leave the summary unchanged."+ ),+ })+ .describe(+ 'Editable human-facing fields on a signal report (PATCH).\n\nBoth fields are optional so a caller can change either independently, but at least one\nmust be supplied. Every other report field — status, weights, judgments — is owned by the\nsignals pipeline and is deliberately not writable here.'+ )+/*** Transition a report to a new state. The model validates allowed transitions.*diff --git a/services/mcp/src/tools/generated/signals.ts b/services/mcp/src/tools/generated/signals.tsindex ea29d9a019b4..2f1f953bddfe 100644--- a/services/mcp/src/tools/generated/signals.ts+++ b/services/mcp/src/tools/generated/signals.ts@@ -13,6 +13,8 @@ import {SignalsReportArtefactsRetrieveParams,SignalsReportsBulkStateCreateBody,SignalsReportsListQueryParams,+ SignalsReportsPartialUpdateBody,+ SignalsReportsPartialUpdateParams,SignalsReportsRetrieveParams,SignalsReportsStateCreateBody,SignalsReportsStateCreateParams,@@ -313,6 +315,31 @@ const inboxReportsSetState = (): ToolBase<typeof InboxReportsSetStateSchema, Wit},})+const InboxReportsUpdateSchema = SignalsReportsPartialUpdateParams.omit({ project_id: true }).extend(+ SignalsReportsPartialUpdateBody.shape+)++const inboxReportsUpdate = (): ToolBase<typeof InboxReportsUpdateSchema, WithPostHogUrl<Schemas.SignalReport>> => ({+ name: 'inbox-reports-update',+ schema: InboxReportsUpdateSchema,+ handler: async (context: Context, params: z.infer<typeof InboxReportsUpdateSchema>) => {+ const projectId = await context.stateManager.getProjectId()+ const body: Record<string, unknown> = {}+ if (params.title !== undefined) {+ body['title'] = params.title+ }+ if (params.summary !== undefined) {+ body['summary'] = params.summary+ }+ const result = await context.api.request<Schemas.SignalReport>({+ method: 'PATCH',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/reports/${encodeURIComponent(String(params.id))}/`,+ body,+ })+ return await withPostHogUrl(context, result, `/inbox/${result.id}`)+ },+})+const InboxSourceConfigsCreateSchema = SignalsSourceConfigsCreateBodyconst inboxSourceConfigsCreate = (): ToolBase<typeof InboxSourceConfigsCreateSchema, Schemas.SignalSourceConfig> => ({@@ -899,6 +926,7 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {'inbox-reports-list': inboxReportsList,'inbox-reports-retrieve': inboxReportsRetrieve,'inbox-reports-set-state': inboxReportsSetState,+ 'inbox-reports-update': inboxReportsUpdate,'inbox-source-configs-create': inboxSourceConfigsCreate,'inbox-source-configs-list': inboxSourceConfigsList,'inbox-source-configs-partial-update': inboxSourceConfigsPartialUpdate,diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-update.jsonnew file mode 100644index 000000000000..0f18a221010d--- /dev/null+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-update.json@@ -0,0 +1,23 @@+{+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "properties": {+ "id": {+ "description": "A UUID string identifying this signal report.",+ "type": "string"+ },+ "summary": {+ "description": "New summary (the report's description) explaining what the report is about. Omit to leave the summary unchanged.",+ "maxLength": 10000,+ "minLength": 1,+ "type": "string"+ },+ "title": {+ "description": "New human-facing title for the report. Omit to leave the title unchanged.",+ "maxLength": 300,+ "minLength": 1,+ "type": "string"+ }+ },+ "required": ["id"],+ "type": "object"+}