: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(self-driving): Allow keeping report charts the same (#74450)
Michael Matloka9262d7a448bf
diff --git a/products/signals/ARCHITECTURE.md b/products/signals/ARCHITECTURE.mdindex 8810156fac11..97f05fd4dce1 100644--- a/products/signals/ARCHITECTURE.md+++ b/products/signals/ARCHITECTURE.md@@ -454,7 +454,7 @@ An **append-only, attributed, schema-validated log of the work done on a report*`chart_id` is the author's own slug because a report's summary and its charts are written in one call: the summary places a chart by referencing it as a markdown link with a `chart:` target (`[Daily signups](chart:signups-drop)`), and an unreferenced chart still renders below the summary. Ids are unique within the set, so a reference resolves to exactly one chart. Placement is resolved from the same markdown parse the renderer runs (`frontend/src/scenes/inbox/utils/chartPlacement.ts`) rather than by matching the raw summary: a reference in a code span is literal text, one in a table cell or heading has no room to draw, and a repeated reference points back at a chart rather than asking for a second copy — each of those resolves to "not placed here", so the chart falls to the trailing block instead of being drawn twice or lost. A paragraph holding nothing but references lays its charts out as a row. Height comes from the node (a `BoldNumber` gets a short box, a retention grid a tall scrolling one) unless the author sets `size`.-Scouts write them via `charts` on `emit_report` / `edit_report`. On an edit `charts` is the report's whole set — it replaces what was there, the way `summary` replaces the summary, and omitting it leaves the existing charts alone. On the emit path the safety judge sees a report's chart titles, captions, and queries alongside its prose, so an injected chart is suppressed with the report. The edit path judges nothing today — not title, summary, notes, reviewers, or charts — so a chart set by a later edit reaches the reader unscreened, exactly as an edited summary does.+Scouts write them via `charts` on `emit_report` / `edit_report`. On an edit `charts` is the report's whole set — it replaces what was there, the way `summary` replaces the summary. Omitting the field (or sending null) leaves the existing charts alone; an explicit empty list clears them, so a scout can retract a chart its finding has outgrown rather than only ever swap one for another. On the emit path the safety judge sees a report's chart titles, captions, and queries alongside its prose, so an injected chart is suppressed with the report. The edit path judges nothing today — not title, summary, notes, reviewers, or charts — so a chart set by a later edit reaches the reader unscreened, exactly as an edited summary does.The main **agentic research pipeline** authors charts too, so every signal source that funnels through it (not just scouts) can produce a visual report. The research agent's presentation step (`report_generation/research.py`) returns `charts` alongside the title and summary; the caller activity (`temporal/agentic/report.py`) replaces `SignalReport.charts` with them, and a re-research is shown the report's current charts to keep, refresh, or drop. It is gated per team by the `signals-report-charts` flag (`_team_report_charts_enabled`, on in DEBUG) so it ships dark on the fleet-wide path. Unlike the scout emit path, these charts are **not** safety-judged: the pipeline judge screens the input signals before research runs, so it never sees research-authored charts — the same as it never sees the research-authored title/summary, which are agent output from already-screened signals.diff --git a/products/signals/backend/scout_harness/prompt.py b/products/signals/backend/scout_harness/prompt.pyindex c3145dc926f0..5dad643113ea 100644--- a/products/signals/backend/scout_harness/prompt.py+++ b/products/signals/backend/scout_harness/prompt.py@@ -400,7 +400,7 @@ _REPORT_CHARTS = f"""# Attaching charts- **Pin the window.** Use absolute dates wherever the node supports it, so the reader sees the data you wrote about rather than whatever a relative range resolves to when they open the report days later.- **Size only when the default is wrong.** The inbox sizes a chart from its query. Set `size` to `small` (a single number, a short series), `medium`, or `large` (rows or a grid to read — retention, paths, a wide breakdown) when it isn't.- **At most {MAX_REPORT_CHARTS} per report**, which is far more than most reports should use. Every chart runs its query when someone opens the report, so attach the ones that carry the argument rather than everything you looked at — three charts a reader studies beat a dozen they scroll past.-- **`charts` on an edit is the report's whole set, not an addition.** It replaces what the report had, the way `summary` replaces the summary — so to keep a chart, send it again. Leave `charts` out entirely and the report keeps the ones it has. Read the report first (`inbox-reports-retrieve` returns its `charts`) when you mean to add to them rather than start over.+- **`charts` on an edit is the report's whole set, not an addition.** It replaces what the report had, the way `summary` replaces the summary — so to keep a chart, send it again. Leave `charts` out entirely and the report keeps the ones it has. Read the report first (`inbox-reports-retrieve` returns its `charts`) when you mean to add to them rather than start over. Send `charts: []` to take every chart down, which is what you want when the finding has moved on and the old chart would now mislead.A trends chart and a graph built from SQL, as they arrive in `charts`:diff --git a/products/signals/backend/scout_harness/serializers.py b/products/signals/backend/scout_harness/serializers.pyindex c9d091a3239d..ec9615cf80ab 100644--- a/products/signals/backend/scout_harness/serializers.py+++ b/products/signals/backend/scout_harness/serializers.py@@ -1038,12 +1038,14 @@ class EditReportRequestSerializer(serializers.Serializer):)charts = serializers.ListField(required=False,+ allow_null=True,child=ReportChartSerializer(),max_length=MAX_REPORT_CHARTS,help_text=("The full set of charts the report should show. Replaces the report's charts rather than ""adding to them, the way `summary` replaces the summary — so send every chart you want "- "kept. Omit the field to leave the report's existing charts untouched."+ "kept. Omit the field (or send null) to leave the report's existing charts untouched, and "+ "send an empty list to take them all down."),)@@ -1057,7 +1059,12 @@ class EditReportResponseSerializer(serializers.Serializer):note_appended = serializers.BooleanField(help_text="Whether a note artefact was appended.")reviewers_set = serializers.BooleanField(help_text="Whether the report's suggested reviewers were replaced.")charts_set = serializers.IntegerField(- help_text="How many charts the report now shows, or 0 if charts were untouched."+ allow_null=True,+ help_text=(+ "How many charts the report now shows, or null if the edit left its charts as they were "+ "(the field omitted, or a re-send of what was already stored). 0 means the edit took the "+ "report's charts down."+ ),)diff --git a/products/signals/backend/scout_harness/tools/report.py b/products/signals/backend/scout_harness/tools/report.pyindex 5106438d3f67..ef6477b762aa 100644--- a/products/signals/backend/scout_harness/tools/report.py+++ b/products/signals/backend/scout_harness/tools/report.py@@ -161,7 +161,11 @@ class EditReportResult:updated_fields: list[str]note_appended: boolreviewers_set: bool = False- charts_set: int = 0+ # How many charts the report now shows, or None when the edit left its charts as they were (the+ # field omitted, or a re-send of what was already stored). Nullable rather than 0-for-untouched+ # because taking a report's charts down is itself a real outcome, and 0 would otherwise mean both+ # "cleared" and "never touched".+ charts_set: int | None = None# The report's effective title after the edit (the rewritten title, or the stored one for a# note/reviewer-only edit) — telemetry-only, so the edited lifecycle event can classify the report# (`_report_classification_props`) even when the edit didn't touch the title.@@ -175,8 +179,12 @@ class EditReportResult:rewritten to its current value, or the charts a previous call stored. Everything an edit sets inmotion downstream (the run tally, the work-log link, the Slack delivery, the lifecycle events)keys off this, so a call that changed nothing stays silent instead of telling the team their- report moved."""- return bool(self.updated_fields or self.note_appended or self.reviewers_set or self.charts_set)+ report moved.++ `charts_set` is checked against None, not truthiness: an edit that took the report's charts+ down reports 0, and reading that as "nothing happened" would keep the retraction off the run+ tally and out of both event streams."""+ return bool(self.updated_fields or self.note_appended or self.reviewers_set) or self.charts_set is not Nonedef _surfaced(status: SignalReport.Status) -> bool:@@ -248,6 +256,20 @@ def _build_charts(charts: list[ReportChartInput] | None) -> list[ReportChart]:return built+def _build_edit_charts(charts: list[ReportChartInput] | None) -> list[ReportChart] | None:+ """The charts an edit should write, or None when the edit supplied no `charts` at all.++ An edit has a third state emit does not: leaving the report's existing charts alone. So `None`+ (the field omitted, or sent as null) means "don't touch them", while an explicit empty list is a+ real instruction to clear them — the same way an empty `summary` would be a real rewrite rather+ than a no-op. `_build_charts` collapses both to `[]` because emit only ever authors a fresh set,+ which is why the distinction is drawn here instead of widening that contract.+ """+ if charts is None:+ return None+ return _build_charts(charts)++def _normalize_repository(repository: str | None) -> str | None:"""Validate + normalize the scout's `repository` input. `None` / the `NO_REPO` sentinel pass through;an explicit value is lowercased and format-checked as `owner/repo`. Raises `InvalidScoutReportError`@@ -856,7 +878,9 @@ def _capture_report_edited(# Charts are a valid *sole* input to an edit, so the same reasoning applies: two chart-only edits to# one report in a run carry no updated_fields and no title/summary/note, and would hash identically —# ingestion would collapse the second and the team would never see that chart land. Key on the charts- # too, only when charts were set, so every other edit keeps its existing uuid.+ # too, only when charts were set, so every other edit keeps its existing uuid. An edit that clears+ # the charts is keyed on its empty list for the same reason: it is a distinct instruction from the+ # edit that set them, and hashing it identically would drop the clear.## The key is the charts' *content*, not just their ids: re-sending an id under a newer window is how a# scout refreshes a chart, so keying on ids alone would collapse exactly the refresh the team wants to@@ -866,12 +890,12 @@ def _capture_report_edited(# arrive in says nothing, so sorting is what makes a retry hash the same. Charts render in the# order they were sent, so a reorder is a real change to what the report shows, and sorting them# here would hash it identically to the edit before it and let ingestion drop it.- if charts:+ if charts is not None:parts.append(json.dumps([_chart_event_key(c) for c in charts], separators=(",", ":")))return _ReportForward(event_name=CUSTOMER_REPORT_EDITED_EVENT,distinct_id=f"signals_scout:{run.skill_name}",- event_uuid=_report_event_uuid(*parts, charted=bool(charts)),+ event_uuid=_report_event_uuid(*parts, charted=charts is not None),properties=properties,)@@ -1126,7 +1150,7 @@ def _do_edit_report(summary: str | None,append_note: str | None,suggested_reviewers: list[ReviewerInput] | None,- charts: list[ReportChart],+ charts: list[ReportChart] | None,) -> EditReportResult:"""Fully-sync edit core (no LLM step). The async/sync entrypoints both funnel here — directly inthe sync path, via `database_sync_to_async` in the async path. Reviewer resolution does a DB read@@ -1182,9 +1206,10 @@ def _do_edit_report(team_id=team.id, report_id=report_id, note=append_note, attribution=attribution, author=run.skill_name)note_appended = True- # Replace the report's charts, the way a summary rewrite replaces the summary. Supplying- # none leaves the existing ones alone, so an edit that only appends a note keeps them.- if charts:+ # Replace the report's charts, the way a summary rewrite replaces the summary. Omitting the+ # field leaves the existing ones alone, so an edit that only appends a note keeps them; an+ # explicit empty list takes them down.+ if charts is not None:charts_changed = set_report_charts(team_id=team.id,report_id=report_id,@@ -1197,6 +1222,7 @@ def _do_edit_report(# draft PR. Fired outside any txn since it spawns a Task — mirrors emit's post-commit hand-off.if reviewers_set:async_to_sync(_maybe_autostart_report)(team_id=team.id, report_id=report_id)+ charts_set = len(charts) if charts is not None and charts_changed else Nonelogger.info("signals_scout.edit_report: edited",extra={@@ -1205,7 +1231,7 @@ def _do_edit_report("fields": updated_fields,"note": note_appended,"reviewers_set": reviewers_set,- "charts_set": len(charts),+ "charts_set": charts_set,},)# Resolve the report's effective title for the edited event's classification — the rewritten title@@ -1227,7 +1253,7 @@ def _do_edit_report(updated_fields=updated_fields,note_appended=note_appended,reviewers_set=reviewers_set,- charts_set=len(charts) if charts_changed else 0,+ charts_set=charts_set,report_title=report_title,)# Record the edit on the run tally only when something actually changed — a no-op edit (e.g. a@@ -1256,7 +1282,9 @@ def _validate_edit_inputs(team: Team, run: SignalScoutRun, title, summary, append_note, suggested_reviewers, charts) -> None:_assert_team_owns_run(team, run)- if title is None and summary is None and append_note is None and not suggested_reviewers and not charts:+ # `charts` is checked against None rather than falsiness: an explicit empty list clears the+ # report's charts, so a clear-only edit is a real edit and must not be rejected as an empty one.+ if title is None and summary is None and append_note is None and not suggested_reviewers and charts is None:raise InvalidScoutReportError("edit_report needs at least one of title, summary, append_note, suggested_reviewers, charts")@@ -1285,7 +1313,7 @@ async def edit_report(summary=summary,append_note=append_note,suggested_reviewers=suggested_reviewers,- charts=_build_charts(charts),+ charts=_build_edit_charts(charts),)forward = await database_sync_to_async(_capture_report_edited, thread_sensitive=False)(team=team,@@ -1322,7 +1350,7 @@ def edit_report_sync(summary=summary,append_note=append_note,suggested_reviewers=suggested_reviewers,- charts=_build_charts(charts),+ charts=_build_edit_charts(charts),)forward = _capture_report_edited(team=team,diff --git a/products/signals/backend/scout_harness/views.py b/products/signals/backend/scout_harness/views.pyindex 70b4e738cfd3..780c5f445e83 100644--- a/products/signals/backend/scout_harness/views.py+++ b/products/signals/backend/scout_harness/views.py@@ -343,8 +343,12 @@ def _canonical_team_id(view: TeamAndOrgViewSetMixin) -> int:def _to_report_charts(entries: list[dict] | None) -> list[ReportChartInput] | None:"""Map validated `charts` entries to `ReportChartInput`s for the report tools. Content validationlives in `ReportChart`, which the tools build from these; this only crosses the DRF boundary so a- malformed chart still surfaces as an invalid-report error. Empty/None yields None ("no charts")."""- if not entries:+ malformed chart still surfaces as an invalid-report error.++ An absent or null `charts` yields None, which an edit reads as "leave the report's charts alone".+ An empty list is preserved as an empty list, because on an edit that is the instruction to take+ the report's charts down (see `_build_edit_charts`). Emit treats both the same way."""+ if entries is None:return Nonereturn [ReportChartInput(diff --git a/products/signals/backend/scout_report/persistence.py b/products/signals/backend/scout_report/persistence.pyindex 120fa110f8ce..480a58f2d0cc 100644--- a/products/signals/backend/scout_report/persistence.py+++ b/products/signals/backend/scout_report/persistence.py@@ -368,8 +368,8 @@ def set_report_charts(Team-scoped fail-closed like `append_report_note`. `charts` is the full set the report shouldshow, the way `summary` is the whole summary — a caller passing one chart is left with one, not- with one added to whatever was there. Callers reach this only when the scout supplied charts;- omitting them leaves the report's charts alone.+ with one added to whatever was there. An empty sequence is therefore a real write that clears the+ report's charts; a caller that means "leave them alone" does not call this at all.Returns whether the stored charts actually changed. `edit_report` is non-idempotent, so the samecall can arrive twice; without this the caller counts a re-send of the charts already stored as an@@ -380,8 +380,6 @@ def set_report_charts(the charts are reader-visible content, `edit_report` can target any inbox report, and a rewrite ofwhat a report shows needs the same attributable trail its title and summary get."""- if not charts:- return False_validate_report_id(report_id)if batch_error := chart_batch_error(charts):raise InvalidScoutReportError(batch_error)@@ -753,6 +751,8 @@ def _content_edit_note(updated_fields: list[str]) -> str:def _chart_edit_note(count: int) -> str:+ if count == 0:+ return "Removed the report's charts via edit_report."return f"Replaced report charts ({count}) via edit_report."diff --git a/products/signals/backend/test/test_scout_harness_tools.py b/products/signals/backend/test/test_scout_harness_tools.pyindex 667da08914ea..850f5f309268 100644--- a/products/signals/backend/test/test_scout_harness_tools.py+++ b/products/signals/backend/test/test_scout_harness_tools.py@@ -48,6 +48,7 @@ from products.signals.backend.scout_harness.tools.report import (InvalidScoutReportError,ReportChartInput,_build_charts,+ _build_edit_charts,_chart_event_key,_forwarded_summary,_report_event_uuid,@@ -1232,6 +1233,13 @@ class TestBuildCharts:assert _build_charts(None) == []assert _build_charts([]) == []+ def test_an_edit_keeps_omitted_and_emptied_charts_apart(self) -> None:+ # Emit collapses both to "no charts", but an edit has to tell them apart: None leaves the+ # report's charts alone while an empty list takes them down. Collapsing them here is what+ # made a chart unretractable, since every clear read as "the scout didn't mention charts".+ assert _build_edit_charts(None) is None+ assert _build_edit_charts([]) == []+def test_duplicate_chart_id_in_one_call_raises(self) -> None:# Two charts sharing an id in a single call make a `[label](chart:id)` reference in the summary# ambiguous, and the scout is still holding both — so reject rather than pick one silently.diff --git a/products/signals/backend/test/test_scout_report_api.py b/products/signals/backend/test/test_scout_report_api.pyindex 894f64165fe9..da2ae22b4986 100644--- a/products/signals/backend/test/test_scout_report_api.py+++ b/products/signals/backend/test/test_scout_report_api.py@@ -704,6 +704,54 @@ class TestScoutReportAPI(APIBaseTest):signups_chart, churn_chart = chart("signups-drop"), chart("churn-spike")assert forward([signups_chart, churn_chart]) != forward([churn_chart, signups_chart])+ @parameterized.expand(+ [+ ("omitted", {}, 1, None),+ ("null", {"charts": None}, 1, None),+ ("empty_list", {"charts": []}, 0, 0),+ ]+ )+ def test_edit_charts_distinguishes_untouched_from_cleared(+ self, _name: str, chart_field: dict, expected_stored: int, expected_charts_set: int | None+ ) -> None:+ # A scout that no longer stands behind a chart has to be able to take it down, and the only+ # way it can say so is an empty list. Treating that as "didn't mention charts" leaves the+ # stale chart on the report with no way to retract it short of replacing it with a decoy.+ run = _make_run(self.team)+ charts = [{"chart_id": "signups-drop", "title": "Daily signups", "query": {"kind": "InsightVizNode"}}]+ with _safe_judge(), patch(EMBED_PATH), patch(AUTOSTART_PATH, new=AsyncMock()), patch(CAPTURE_PATH):+ created = self.client.post(+ self._emit_url(str(run.id)), data={**self._payload(), "charts": charts}, format="json"+ ).json()+ response = self.client.post(+ self._edit_url(str(run.id)),+ data={"report_id": created["report_id"], "append_note": "checked", **chart_field},+ format="json",+ )++ assert response.status_code == status.HTTP_200_OK, response.json()+ assert response.json()["charts_set"] == expected_charts_set+ assert len(SignalReport.objects.get(id=created["report_id"]).charts) == expected_stored++ def test_clearing_charts_is_a_valid_sole_edit(self) -> None:+ # `charts: []` is the whole instruction on a retraction, so the "needs at least one input"+ # guard has to count it as an input — checking it for falsiness rejects the retraction as an+ # empty edit and leaves the chart up.+ run = _make_run(self.team)+ charts = [{"chart_id": "signups-drop", "title": "Daily signups", "query": {"kind": "InsightVizNode"}}]+ with _safe_judge(), patch(EMBED_PATH), patch(AUTOSTART_PATH, new=AsyncMock()), patch(CAPTURE_PATH):+ created = self.client.post(+ self._emit_url(str(run.id)), data={**self._payload(), "charts": charts}, format="json"+ ).json()+ response = self.client.post(+ self._edit_url(str(run.id)),+ data={"report_id": created["report_id"], "charts": []},+ format="json",+ )++ assert response.status_code == status.HTTP_200_OK, response.json()+ assert SignalReport.objects.get(id=created["report_id"]).charts == []+def test_chart_counts_ride_the_lifecycle_events(self) -> None:# `charts_set` / `chart_count` are what a dashboard or CDP destination reads to tell a# chart-bearing report from a plain one; without them both event streams look identical.diff --git a/products/signals/backend/test/test_scout_report_persistence.py b/products/signals/backend/test/test_scout_report_persistence.pyindex ae7755ae0291..6330f469f022 100644--- a/products/signals/backend/test/test_scout_report_persistence.py+++ b/products/signals/backend/test/test_scout_report_persistence.py@@ -405,14 +405,16 @@ class TestScoutReportCharts(BaseTest):).values_list("content", flat=True)assert any("Replaced report charts" in str(content) for content in notes)- def test_setting_no_charts_leaves_the_report_s_charts_alone(self) -> None:- # An edit that only appends a note must not clear the report's charts — the tool reaches here- # for every edit, and "no charts supplied" means untouched, not emptied.+ def test_setting_an_empty_set_takes_the_report_s_charts_down(self) -> None:+ # An empty set is a real write, not a no-op: it's the only way a scout can retract a chart it+ # no longer stands behind. "Leave them alone" is expressed by not calling this at all, which+ # is `_build_edit_charts` returning None for an edit that supplied no `charts`. Clearing a+ # report that has no charts is still a re-send of what's stored, so it reports no change.report_id = self._create([self._chart("signups-drop", "Daily signups")])- set_report_charts(team_id=self.team.id, report_id=report_id, charts=[])-- assert len(self._stored_charts(report_id)) == 1+ assert set_report_charts(team_id=self.team.id, report_id=report_id, charts=[]) is True+ assert self._stored_charts(report_id) == []+ assert set_report_charts(team_id=self.team.id, report_id=report_id, charts=[]) is False@parameterized.expand([diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.tsindex e90ca1b89c42..772cec225374 100644--- a/products/signals/frontend/generated/api.schemas.ts+++ b/products/signals/frontend/generated/api.schemas.ts@@ -2880,10 +2880,11 @@ export interface EditReportRequestApi {*/suggested_reviewers?: SuggestedReviewerApi[]/**- * The full set of charts the report should show. Replaces the report's charts rather than adding to them, the way `summary` replaces the summary — so send every chart you want kept. Omit the field to leave the report's existing charts untouched.+ * The full set of charts the report should show. Replaces the report's charts rather than adding to them, the way `summary` replaces the summary — so send every chart you want kept. Omit the field (or send null) to leave the report's existing charts untouched, and send an empty list to take them all down.* @maxItems 20+ * @nullable*/- charts?: ReportChartApi[]+ charts?: ReportChartApi[] | null}export interface EditReportResponseApi {@@ -2895,8 +2896,11 @@ export interface EditReportResponseApi {note_appended: boolean/** Whether the report's suggested reviewers were replaced. */reviewers_set: boolean- /** How many charts the report now shows, or 0 if charts were untouched. */- charts_set: number+ /**+ * How many charts the report now shows, or null if the edit left its charts as they were (the field omitted, or a re-send of what was already stored). 0 means the edit took the report's charts down.+ * @nullable+ */+ charts_set: number | null}/**diff --git a/products/signals/frontend/generated/api.zod.ts b/products/signals/frontend/generated/api.zod.tsindex e69227a6a85a..7339f36aee5e 100644--- a/products/signals/frontend/generated/api.zod.ts+++ b/products/signals/frontend/generated/api.zod.ts@@ -633,9 +633,9 @@ export const SignalsScoutEditReportBody = /* @__PURE__ */ zod)).max(signalsScoutEditReportBodyChartsMax)- .optional()+ .nullish().describe(- "The full set of charts the report should show. Replaces the report's charts rather than adding to them, the way `summary` replaces the summary — so send every chart you want kept. Omit the field to leave the report's existing charts untouched."+ "The full set of charts the report should show. Replaces the report's charts rather than adding to them, the way `summary` replaces the summary — so send every chart you want kept. Omit the field (or send null) to leave the report's existing charts untouched, and send an empty list to take them all down."),}).describe(diff --git a/products/signals/skills/authoring-scouts/references/report-contract.md b/products/signals/skills/authoring-scouts/references/report-contract.mdindex 9ce64819d295..ccf2cc2847d0 100644--- a/products/signals/skills/authoring-scouts/references/report-contract.md+++ b/products/signals/skills/authoring-scouts/references/report-contract.md@@ -123,6 +123,7 @@ A reference inside a code span, a table cell, or a heading has no room to draw**`charts` on an edit is the report's whole set, not an addition.**It replaces what the report had, the way `summary` replaces the summary — so send every chart you want kept, and re-send an id under a newer window to refresh that chart.Leave `charts` out entirely and the report keeps the ones it has; read the report first (`inbox-reports-retrieve` returns its `charts`) when you mean to add to them.+Send `charts: []` to take every chart down, for when the finding has moved on and the old chart would now mislead.Cap is **20 charts per report** (and a combined query-size budget), which is far more than most reports should use. Each chart runs its query when the report is opened, so attach the ones that carry the argument rather than everything you looked at: three charts a reader studies beat a dozen they scroll past.### Opening a draft PR (autostart)diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 106571d7cb48..2e46b73cbe51 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -23103,10 +23103,11 @@ export namespace Schemas {*/suggested_reviewers?: SuggestedReviewer[];/**- * The full set of charts the report should show. Replaces the report's charts rather than adding to them, the way `summary` replaces the summary — so send every chart you want kept. Omit the field to leave the report's existing charts untouched.+ * The full set of charts the report should show. Replaces the report's charts rather than adding to them, the way `summary` replaces the summary — so send every chart you want kept. Omit the field (or send null) to leave the report's existing charts untouched, and send an empty list to take them all down.* @maxItems 20+ * @nullable*/- charts?: ReportChart[];+ charts?: ReportChart[] | null;}export interface EditReportResponse {@@ -23118,8 +23119,11 @@ export namespace Schemas {note_appended: boolean;/** Whether the report's suggested reviewers were replaced. */reviewers_set: boolean;- /** How many charts the report now shows, or 0 if charts were untouched. */- charts_set: number;+ /**+ * How many charts the report now shows, or null if the edit left its charts as they were (the field omitted, or a re-send of what was already stored). 0 means the edit took the report's charts down.+ * @nullable+ */+ charts_set: number | null;}export type EffectiveMembershipLevelEnum = typeof EffectiveMembershipLevelEnum[keyof typeof EffectiveMembershipLevelEnum];diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.tsindex f90d18825975..b815bdc01c02 100644--- a/services/mcp/src/generated/signals/api.ts+++ b/services/mcp/src/generated/signals/api.ts@@ -1092,9 +1092,9 @@ export const SignalsScoutEditReportBody = /* @__PURE__ */ zod)).max(signalsScoutEditReportBodyChartsMax)- .optional()+ .nullish().describe(- "The full set of charts the report should show. Replaces the report's charts rather than adding to them, the way `summary` replaces the summary — so send every chart you want kept. Omit the field to leave the report's existing charts untouched."+ "The full set of charts the report should show. Replaces the report's charts rather than adding to them, the way `summary` replaces the summary — so send every chart you want kept. Omit the field (or send null) to leave the report's existing charts untouched, and send an empty list to take them all down."),}).describe(diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-edit-report.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-edit-report.jsonindex 8e03bdebd85b..7ea35d5baba1 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-edit-report.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-edit-report.json@@ -13,54 +13,61 @@"description": "Optional free-form note to append to the report's work log (attributed to this scout)."},"charts": {- "description": "The full set of charts the report should show. Replaces the report's charts rather than adding to them, the way `summary` replaces the summary — so send every chart you want kept. Omit the field to leave the report's existing charts untouched.",- "items": {- "description": "One chart attached to a report — rendered in the inbox and referenceable from the summary.",- "properties": {- "caption": {- "anyOf": [- {- "maxLength": 500,- "type": "string"+ "anyOf": [+ {+ "items": {+ "description": "One chart attached to a report — rendered in the inbox and referenceable from the summary.",+ "properties": {+ "caption": {+ "anyOf": [+ {+ "maxLength": 500,+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "Optional one-line note on what to look at in the chart."},- {- "type": "null"- }- ],- "description": "Optional one-line note on what to look at in the chart."- },- "chart_id": {- "description": "Stable slug for this chart within the report (lowercase letters, numbers, underscores, hyphens; must start with a letter or number). Reference it from `summary` as a markdown link with a `chart:` target — `[Daily signups](chart:signups-drop)` — to place the chart at that point in the body. A chart you don't reference still renders, below the summary.",- "maxLength": 100,- "type": "string"- },- "query": {- "description": "The query node to render. `kind` must be `InsightVizNode` (an ad-hoc product analytics chart), `DataVisualizationNode` (a SQL series — a `HogQLQuery` source plus a `display`), or `SavedInsightNode` (an existing insight by `shortId`). Pin the window to absolute dates where the node supports it, so the reader sees the data you wrote about rather than whatever a relative range resolves to when they open the report."- },- "size": {- "anyOf": [- {- "description": "* `small` - small\n* `medium` - medium\n* `large` - large",- "enum": ["small", "medium", "large"],+ "chart_id": {+ "description": "Stable slug for this chart within the report (lowercase letters, numbers, underscores, hyphens; must start with a letter or number). Reference it from `summary` as a markdown link with a `chart:` target — `[Daily signups](chart:signups-drop)` — to place the chart at that point in the body. A chart you don't reference still renders, below the summary.",+ "maxLength": 100,"type": "string"},- {- "type": "null"+ "query": {+ "description": "The query node to render. `kind` must be `InsightVizNode` (an ad-hoc product analytics chart), `DataVisualizationNode` (a SQL series — a `HogQLQuery` source plus a `display`), or `SavedInsightNode` (an existing insight by `shortId`). Pin the window to absolute dates where the node supports it, so the reader sees the data you wrote about rather than whatever a relative range resolves to when they open the report."+ },+ "size": {+ "anyOf": [+ {+ "description": "* `small` - small\n* `medium` - medium\n* `large` - large",+ "enum": ["small", "medium", "large"],+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "How much height the chart gets: `small` for a single number or a short series, `medium` for an ordinary graph, `large` when there are rows or a grid to read (retention, paths, a wide breakdown). Leave it out unless the default looks wrong — the inbox sizes a chart from its query, and two charts referenced from the same paragraph sit side by side.\n\n* `small` - small\n* `medium` - medium\n* `large` - large"+ },+ "title": {+ "description": "Short heading shown above the chart.",+ "maxLength": 200,+ "type": "string"}- ],- "description": "How much height the chart gets: `small` for a single number or a short series, `medium` for an ordinary graph, `large` when there are rows or a grid to read (retention, paths, a wide breakdown). Leave it out unless the default looks wrong — the inbox sizes a chart from its query, and two charts referenced from the same paragraph sit side by side.\n\n* `small` - small\n* `medium` - medium\n* `large` - large"+ },+ "required": ["chart_id", "title", "query"],+ "type": "object"},- "title": {- "description": "Short heading shown above the chart.",- "maxLength": 200,- "type": "string"- }+ "maxItems": 20,+ "type": "array"},- "required": ["chart_id", "title", "query"],- "type": "object"- },- "maxItems": 20,- "type": "array"+ {+ "type": "null"+ }+ ],+ "description": "The full set of charts the report should show. Replaces the report's charts rather than adding to them, the way `summary` replaces the summary — so send every chart you want kept. Omit the field (or send null) to leave the report's existing charts untouched, and send an empty list to take them all down."},"report_id": {"description": "Id of the report to edit (must belong to this project).",diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-edit-report.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-edit-report.jsonindex 8e03bdebd85b..7ea35d5baba1 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-edit-report.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-edit-report.json@@ -13,54 +13,61 @@"description": "Optional free-form note to append to the report's work log (attributed to this scout)."},"charts": {- "description": "The full set of charts the report should show. Replaces the report's charts rather than adding to them, the way `summary` replaces the summary — so send every chart you want kept. Omit the field to leave the report's existing charts untouched.",- "items": {- "description": "One chart attached to a report — rendered in the inbox and referenceable from the summary.",- "properties": {- "caption": {- "anyOf": [- {- "maxLength": 500,- "type": "string"+ "anyOf": [+ {+ "items": {+ "description": "One chart attached to a report — rendered in the inbox and referenceable from the summary.",+ "properties": {+ "caption": {+ "anyOf": [+ {+ "maxLength": 500,+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "Optional one-line note on what to look at in the chart."},- {- "type": "null"- }- ],- "description": "Optional one-line note on what to look at in the chart."- },- "chart_id": {- "description": "Stable slug for this chart within the report (lowercase letters, numbers, underscores, hyphens; must start with a letter or number). Reference it from `summary` as a markdown link with a `chart:` target — `[Daily signups](chart:signups-drop)` — to place the chart at that point in the body. A chart you don't reference still renders, below the summary.",- "maxLength": 100,- "type": "string"- },- "query": {- "description": "The query node to render. `kind` must be `InsightVizNode` (an ad-hoc product analytics chart), `DataVisualizationNode` (a SQL series — a `HogQLQuery` source plus a `display`), or `SavedInsightNode` (an existing insight by `shortId`). Pin the window to absolute dates where the node supports it, so the reader sees the data you wrote about rather than whatever a relative range resolves to when they open the report."- },- "size": {- "anyOf": [- {- "description": "* `small` - small\n* `medium` - medium\n* `large` - large",- "enum": ["small", "medium", "large"],+ "chart_id": {+ "description": "Stable slug for this chart within the report (lowercase letters, numbers, underscores, hyphens; must start with a letter or number). Reference it from `summary` as a markdown link with a `chart:` target — `[Daily signups](chart:signups-drop)` — to place the chart at that point in the body. A chart you don't reference still renders, below the summary.",+ "maxLength": 100,"type": "string"},- {- "type": "null"+ "query": {+ "description": "The query node to render. `kind` must be `InsightVizNode` (an ad-hoc product analytics chart), `DataVisualizationNode` (a SQL series — a `HogQLQuery` source plus a `display`), or `SavedInsightNode` (an existing insight by `shortId`). Pin the window to absolute dates where the node supports it, so the reader sees the data you wrote about rather than whatever a relative range resolves to when they open the report."+ },+ "size": {+ "anyOf": [+ {+ "description": "* `small` - small\n* `medium` - medium\n* `large` - large",+ "enum": ["small", "medium", "large"],+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "How much height the chart gets: `small` for a single number or a short series, `medium` for an ordinary graph, `large` when there are rows or a grid to read (retention, paths, a wide breakdown). Leave it out unless the default looks wrong — the inbox sizes a chart from its query, and two charts referenced from the same paragraph sit side by side.\n\n* `small` - small\n* `medium` - medium\n* `large` - large"+ },+ "title": {+ "description": "Short heading shown above the chart.",+ "maxLength": 200,+ "type": "string"}- ],- "description": "How much height the chart gets: `small` for a single number or a short series, `medium` for an ordinary graph, `large` when there are rows or a grid to read (retention, paths, a wide breakdown). Leave it out unless the default looks wrong — the inbox sizes a chart from its query, and two charts referenced from the same paragraph sit side by side.\n\n* `small` - small\n* `medium` - medium\n* `large` - large"+ },+ "required": ["chart_id", "title", "query"],+ "type": "object"},- "title": {- "description": "Short heading shown above the chart.",- "maxLength": 200,- "type": "string"- }+ "maxItems": 20,+ "type": "array"},- "required": ["chart_id", "title", "query"],- "type": "object"- },- "maxItems": 20,- "type": "array"+ {+ "type": "null"+ }+ ],+ "description": "The full set of charts the report should show. Replaces the report's charts rather than adding to them, the way `summary` replaces the summary — so send every chart you want kept. Omit the field (or send null) to leave the report's existing charts untouched, and send an empty list to take them all down."},"report_id": {"description": "Id of the report to edit (must belong to this project).",