Skip to content

: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.

fix(signals): scope bulk inbox changes to the user and confirm first (#130442)

posthog[bot]596e32dde2b4
diff --git a/products/signals/backend/scout_report/trial_inbox.py b/products/signals/backend/scout_report/trial_inbox.py
index 94676e583fbe..492769e7623f 100644
--- a/products/signals/backend/scout_report/trial_inbox.py
+++ b/products/signals/backend/scout_report/trial_inbox.py
@@ -31,6 +31,7 @@ class TrialInboxReads:
{
"search",
"created_after",
+ "created_before",
"priority",
"actionability",
"already_addressed",
@@ -283,6 +284,11 @@ class TrialInboxReads:
if query.get("created_after")
else None
)
+ created_before = (
+ serializers.DateTimeField().to_internal_value(query["created_before"])
+ if query.get("created_before")
+ else None
+ )
priorities = [priority.upper() for priority in self._tokens(query.get("priority"))]
actionabilities = self._tokens(query.get("actionability"))
already_addressed = self.view._bool_query_param("already_addressed")
@@ -303,11 +309,12 @@ class TrialInboxReads:
continue
if search and not any(search in str(document.get(field, "")).casefold() for field in ("title", "summary")):
continue
- if (
- created_after is not None
- and datetime.fromisoformat(str(document["created_at"]).replace("Z", "+00:00")) < created_after
- ):
- continue
+ if created_after is not None or created_before is not None:
+ created_at = datetime.fromisoformat(str(document["created_at"]).replace("Z", "+00:00"))
+ if created_after is not None and created_at < created_after:
+ continue
+ if created_before is not None and created_at >= created_before:
+ continue
if priorities and document.get("priority") not in priorities:
continue
if actionabilities and document.get("actionability") not in actionabilities:
diff --git a/products/signals/backend/test/test_signal_report_api.py b/products/signals/backend/test/test_signal_report_api.py
index eb608d79858c..bc746b87d8a5 100644
--- a/products/signals/backend/test/test_signal_report_api.py
+++ b/products/signals/backend/test/test_signal_report_api.py
@@ -1890,6 +1890,7 @@ class TestSignalReportListAPI(APIBaseTest):
[
("ordering", {"ordering": "-ranking_open,status"}, "ordering"),
("created_after", {"created_after": "last week"}, "created_after"),
+ ("created_before", {"created_before": "3 days ago"}, "created_before"),
]
)
def test_list_rejects_invalid_params_with_400(self, _name, query, attr):
@@ -1899,15 +1900,15 @@ class TestSignalReportListAPI(APIBaseTest):
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert response.json()["attr"] == attr
- def test_created_after_keeps_reports_created_since(self):
- recent = self._create_report(title="Recent")
- old = self._create_report(title="Old")
- SignalReport.objects.filter(pk=old.pk).update(created_at=timezone.now() - timedelta(days=5))
+ @parameterized.expand([("created_after", "recent"), ("created_before", "old")])
+ def test_created_at_filters_split_reports_at_cutoff(self, param, expected):
+ reports = {"recent": self._create_report(title="Recent"), "old": self._create_report(title="Old")}
+ SignalReport.objects.filter(pk=reports["old"].pk).update(created_at=timezone.now() - timedelta(days=5))
cutoff = (timezone.now() - timedelta(days=3)).isoformat()
- response = self.client.get(self._list_url(created_after=cutoff, sort="newest"))
+ response = self.client.get(self._list_url(**{param: cutoff}, sort="newest"))
assert response.status_code == status.HTTP_200_OK
- assert [r["id"] for r in response.json()["results"]] == [str(recent.id)]
+ assert [r["id"] for r in response.json()["results"]] == [str(reports[expected].id)]
@parameterized.expand(
[
diff --git a/products/signals/backend/views.py b/products/signals/backend/views.py
index 5a73ec874f89..25db0af5ccfb 100644
--- a/products/signals/backend/views.py
+++ b/products/signals/backend/views.py
@@ -5,7 +5,7 @@ import time
import uuid
from collections.abc import Callable, Iterable, Sequence
from contextlib import ExitStack
-from datetime import UTC, timedelta
+from datetime import UTC, datetime, timedelta
from functools import cached_property, partial
from typing import Any, Literal, cast
@@ -1677,6 +1677,16 @@ _REPORT_LIST_PARAMETERS = [
required=False,
description="ISO 8601 datetime. Keeps reports created at or after this time.",
),
+ OpenApiParameter(
+ name="created_before",
+ type=OpenApiTypes.DATETIME,
+ location=OpenApiParameter.QUERY,
+ required=False,
+ description=(
+ "ISO 8601 datetime. Keeps reports created before this time. Use it for reports older than a "
+ "cutoff, instead of reading every page."
+ ),
+ ),
OpenApiParameter(
name="task_id",
type=OpenApiTypes.UUID,
@@ -1992,7 +2002,7 @@ class SignalReportViewSet(
qs = self._apply_signal_report_status_filter(qs)
qs = self._apply_signal_report_listed_filter(qs)
qs = self._apply_signal_report_search_filter(qs)
- qs = self._apply_signal_report_created_after_filter(qs)
+ qs = self._apply_signal_report_created_at_filters(qs)
unread = self.request.query_params.get("unread")
if unread is not None:
if unread not in {"true", "false"}:
@@ -2227,15 +2237,23 @@ class SignalReportViewSet(
return queryset
return queryset.filter(Q(title__icontains=search) | Q(summary__icontains=search))
- def _apply_signal_report_created_after_filter(self, queryset):
- raw = self.request.query_params.get("created_after")
+ def _datetime_query_param(self, name: str) -> datetime | None:
+ raw = self.request.query_params.get(name)
if not raw:
- return queryset
+ return None
try:
- created_after = serializers.DateTimeField().to_internal_value(raw)
+ return serializers.DateTimeField().to_internal_value(raw)
except serializers.ValidationError:
- raise serializers.ValidationError({"created_after": "Use an ISO 8601 datetime."})
- return queryset.filter(created_at__gte=created_after)
+ raise serializers.ValidationError({name: "Use an ISO 8601 datetime."})
+
+ def _apply_signal_report_created_at_filters(self, queryset):
+ created_after = self._datetime_query_param("created_after")
+ if created_after is not None:
+ queryset = queryset.filter(created_at__gte=created_after)
+ created_before = self._datetime_query_param("created_before")
+ if created_before is not None:
+ queryset = queryset.filter(created_at__lt=created_before)
+ return queryset
def _apply_signal_report_source_product_filter(self, queryset):
source_product_filter = self.request.query_params.get("source_product")
diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.ts
index f112d4f44d17..0c68a068ebbe 100644
--- a/products/signals/frontend/generated/api.schemas.ts
+++ b/products/signals/frontend/generated/api.schemas.ts
@@ -11254,6 +11254,10 @@ export type SignalsReportsListParams = {
* ISO 8601 datetime. Keeps reports created at or after this time.
*/
created_after?: string
+ /**
+ * ISO 8601 datetime. Keeps reports created before this time. Use it for reports older than a cutoff, instead of reading every page.
+ */
+ created_before?: string
/**
* Report ids to leave out of the results and counts, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.
* @maxItems 100
@@ -11518,6 +11522,10 @@ export type SignalsReportsSectionCountsRetrieveParams = {
* ISO 8601 datetime. Keeps reports created at or after this time.
*/
created_after?: string
+ /**
+ * ISO 8601 datetime. Keeps reports created before this time. Use it for reports older than a cutoff, instead of reading every page.
+ */
+ created_before?: string
/**
* Report ids to leave out of the results and counts, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.
* @maxItems 100
diff --git a/products/signals/mcp/tools.yaml b/products/signals/mcp/tools.yaml
index 3e053425406d..905cdbd0c2af 100644
--- a/products/signals/mcp/tools.yaml
+++ b/products/signals/mcp/tools.yaml
@@ -388,7 +388,10 @@ tools:
one. Each id is processed independently, so the call returns 200 even on partial failure: read `results`
(one entry per id, in request order) and the `transitioned_count`, `skipped_count`, `failed_count`, and
`not_found_count` summary. An id whose current status does not allow the transition comes back as `skipped`,
- and the rest still go through.
+ and the rest still go through. Before a bulk change, count the matching reports with inbox-reports-list and
+ `count_only=true`, tell the user the count and the filters, and get their confirmation. Keep a request that
+ names "my inbox" inside `view=for_you`. Do not page through the project to change more reports than the user
+ confirmed.
inbox-reports-claim:
operation: signals_reports_claim
enabled: true
@@ -537,7 +540,9 @@ tools:
List inbox reports in the current project. A report groups related findings into one issue or trend. Each
parameter's description says how it filters.
- For "what needs me", pass `view=for_you` with `sort=priority`. For the next fixable work across the project,
+ Without `view`, the list holds reports from the whole project, not only the user's. When the user says "my
+ inbox", "my reports", or "what needs me", pass `view=for_you` with `sort=priority`. For reports older than a
+ cutoff, pass `created_before` instead of reading every page. For the next fixable work across the project,
pass `view=actionable` with `use_priority_preference=true`, `sort=priority`, and `limit=10`. For a personal
ranked shortlist, such as "my top 10", the prioritizing-my-inbox skill combines these rows with the user's
activity summary. For the work this agent claimed, pass `assignee=me`.
diff --git a/products/signals/skills/inbox-exploration/SKILL.md b/products/signals/skills/inbox-exploration/SKILL.md
index 441f7436dc53..087c960e28e6 100644
--- a/products/signals/skills/inbox-exploration/SKILL.md
+++ b/products/signals/skills/inbox-exploration/SKILL.md
@@ -41,6 +41,11 @@ the user's actual question.
- You are about to investigate an error, bug, metric change, or support ticket in code — see
_Workflow: check for existing work before you investigate_
+**"My inbox" means `view=for_you`.**
+Without a `view`, `inbox-reports-list` returns reports from the whole project, not only the user's.
+When the user says "my inbox", "my reports", or "what needs me", pass `view: "for_you"`.
+Use project scope only when the user asks for the whole project or the team's inbox.
+
When the user wants a personal shortlist ("let's look at my inbox", "my top 10 inbox reports"), use the
**`prioritizing-my-inbox`** skill. It ranks reports by the user's activity summary, the ranking model, and
what waits on them.
@@ -647,6 +652,26 @@ inbox-reports-set-state
transition isn't allowed comes back as `skipped` (the single-report `409`) while the rest go
through. Inspect the per-id outcomes rather than assuming the whole batch succeeded.
+### Bulk changes need a count and a confirmation
+
+A bulk dismiss or resolve closes each report's open implementation PR, and every dismissal note steers later scout runs.
+Before you change more than one report:
+
+1. Find the scope. "My inbox" is `view: "for_you"`. Use the whole project only when the user asks for it.
+2. Narrow the list on the server. For "older than N days", pass `created_before` with the cutoff. Do not read every page and filter on your side.
+3. Count the matches. Call `inbox-reports-list` with the same filters and `count_only: true`.
+4. Tell the user the count, the scope, and the filters, and get their confirmation before the first `inbox-reports-bulk-set-state` call.
+5. Change only the reports that the user confirmed. If the count grows while you work, or you find reports outside the confirmed scope, stop and ask again.
+
+```json
+inbox-reports-list
+{
+ "view": "for_you",
+ "created_before": "<ISO 8601 cutoff>",
+ "count_only": true
+}
+```
+
## Workflow: filter by topic or source
"Are there any reports about <topic>?" — start with `search`:
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 2c5513f0752f..306a18810ed1 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -8027,7 +8027,7 @@
}
},
"inbox-reports-bulk-set-state": {
- "description": "Transition up to 100 inbox reports to the same state in one call, the bulk form of `inbox-reports-set-state`. Dismissing or resolving closes each report's open implementation PR, if it has one. Each id is processed independently, so the call returns 200 even on partial failure: read `results` (one entry per id, in request order) and the `transitioned_count`, `skipped_count`, `failed_count`, and `not_found_count` summary. An id whose current status does not allow the transition comes back as `skipped`, and the rest still go through.",
+ "description": "Transition up to 100 inbox reports to the same state in one call, the bulk form of `inbox-reports-set-state`. Dismissing or resolving closes each report's open implementation PR, if it has one. Each id is processed independently, so the call returns 200 even on partial failure: read `results` (one entry per id, in request order) and the `transitioned_count`, `skipped_count`, `failed_count`, and `not_found_count` summary. An id whose current status does not allow the transition comes back as `skipped`, and the rest still go through. Before a bulk change, count the matching reports with inbox-reports-list and `count_only=true`, tell the user the count and the filters, and get their confirmation. Keep a request that names \"my inbox\" inside `view=for_you`. Do not page through the project to change more reports than the user confirmed.",
"category": "Signals",
"feature": "signals",
"summary": "Resolve, dismiss, or snooze inbox reports in bulk",
@@ -8120,7 +8120,7 @@
}
},
"inbox-reports-list": {
- "description": "List inbox reports in the current project. A report groups related findings into one issue or trend. Each parameter's description says how it filters.\nFor \"what needs me\", pass `view=for_you` with `sort=priority`. For the next fixable work across the project, pass `view=actionable` with `use_priority_preference=true`, `sort=priority`, and `limit=10`. For a personal ranked shortlist, such as \"my top 10\", the prioritizing-my-inbox skill combines these rows with the user's activity summary. For the work this agent claimed, pass `assignee=me`.\nWithout `limit`, a page holds up to 100 reports, each with its summary. Read a report's work log with inbox-report-artefacts-list before you act on it.\nEach row's `ranking.predictions` gives the ranking model's probability and lift for `open`, `action`, and `fix`. Lift 1.0 is an average report. A prediction is a forecast, not the report's state, and `status: unscored` is not a low score. inbox-ranking-outcomes-list explains each outcome.",
+ "description": "List inbox reports in the current project. A report groups related findings into one issue or trend. Each parameter's description says how it filters.\nWithout `view`, the list holds reports from the whole project, not only the user's. When the user says \"my inbox\", \"my reports\", or \"what needs me\", pass `view=for_you` with `sort=priority`. For reports older than a cutoff, pass `created_before` instead of reading every page. For the next fixable work across the project, pass `view=actionable` with `use_priority_preference=true`, `sort=priority`, and `limit=10`. For a personal ranked shortlist, such as \"my top 10\", the prioritizing-my-inbox skill combines these rows with the user's activity summary. For the work this agent claimed, pass `assignee=me`.\nWithout `limit`, a page holds up to 100 reports, each with its summary. Read a report's work log with inbox-report-artefacts-list before you act on it.\nEach row's `ranking.predictions` gives the ranking model's probability and lift for `open`, `action`, and `fix`. Lift 1.0 is an average report. A prediction is a forecast, not the report's state, and `status: unscored` is not a low score. inbox-ranking-outcomes-list explains each outcome.",
"category": "Signals",
"feature": "signals",
"summary": "List inbox reports",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 8d1b48b34060..2d416494045e 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -8259,7 +8259,7 @@
}
},
"inbox-reports-bulk-set-state": {
- "description": "Transition up to 100 inbox reports to the same state in one call, the bulk form of `inbox-reports-set-state`. Dismissing or resolving closes each report's open implementation PR, if it has one. Each id is processed independently, so the call returns 200 even on partial failure: read `results` (one entry per id, in request order) and the `transitioned_count`, `skipped_count`, `failed_count`, and `not_found_count` summary. An id whose current status does not allow the transition comes back as `skipped`, and the rest still go through.",
+ "description": "Transition up to 100 inbox reports to the same state in one call, the bulk form of `inbox-reports-set-state`. Dismissing or resolving closes each report's open implementation PR, if it has one. Each id is processed independently, so the call returns 200 even on partial failure: read `results` (one entry per id, in request order) and the `transitioned_count`, `skipped_count`, `failed_count`, and `not_found_count` summary. An id whose current status does not allow the transition comes back as `skipped`, and the rest still go through. Before a bulk change, count the matching reports with inbox-reports-list and `count_only=true`, tell the user the count and the filters, and get their confirmation. Keep a request that names \"my inbox\" inside `view=for_you`. Do not page through the project to change more reports than the user confirmed.",
"category": "Signals",
"feature": "signals",
"summary": "Resolve, dismiss, or snooze inbox reports in bulk",
@@ -8352,7 +8352,7 @@
}
},
"inbox-reports-list": {
- "description": "List inbox reports in the current project. A report groups related findings into one issue or trend. Each parameter's description says how it filters.\nFor \"what needs me\", pass `view=for_you` with `sort=priority`. For the next fixable work across the project, pass `view=actionable` with `use_priority_preference=true`, `sort=priority`, and `limit=10`. For a personal ranked shortlist, such as \"my top 10\", the prioritizing-my-inbox skill combines these rows with the user's activity summary. For the work this agent claimed, pass `assignee=me`.\nWithout `limit`, a page holds up to 100 reports, each with its summary. Read a report's work log with inbox-report-artefacts-list before you act on it.\nEach row's `ranking.predictions` gives the ranking model's probability and lift for `open`, `action`, and `fix`. Lift 1.0 is an average report. A prediction is a forecast, not the report's state, and `status: unscored` is not a low score. inbox-ranking-outcomes-list explains each outcome.",
+ "description": "List inbox reports in the current project. A report groups related findings into one issue or trend. Each parameter's description says how it filters.\nWithout `view`, the list holds reports from the whole project, not only the user's. When the user says \"my inbox\", \"my reports\", or \"what needs me\", pass `view=for_you` with `sort=priority`. For reports older than a cutoff, pass `created_before` instead of reading every page. For the next fixable work across the project, pass `view=actionable` with `use_priority_preference=true`, `sort=priority`, and `limit=10`. For a personal ranked shortlist, such as \"my top 10\", the prioritizing-my-inbox skill combines these rows with the user's activity summary. For the work this agent claimed, pass `assignee=me`.\nWithout `limit`, a page holds up to 100 reports, each with its summary. Read a report's work log with inbox-report-artefacts-list before you act on it.\nEach row's `ranking.predictions` gives the ranking model's probability and lift for `open`, `action`, and `fix`. Lift 1.0 is an average report. A prediction is a forecast, not the report's state, and `status: unscored` is not a low score. inbox-ranking-outcomes-list explains each outcome.",
"category": "Signals",
"feature": "signals",
"summary": "List inbox reports",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 49fd84d2f6f8..ac7a80e92254 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -133423,6 +133423,10 @@ export namespace Schemas {
* ISO 8601 datetime. Keeps reports created at or after this time.
*/
created_after?: string;
+ /**
+ * ISO 8601 datetime. Keeps reports created before this time. Use it for reports older than a cutoff, instead of reading every page.
+ */
+ created_before?: string;
/**
* Report ids to leave out of the results and counts, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.
* @maxItems 100
@@ -133686,6 +133690,10 @@ export namespace Schemas {
* ISO 8601 datetime. Keeps reports created at or after this time.
*/
created_after?: string;
+ /**
+ * ISO 8601 datetime. Keeps reports created before this time. Use it for reports older than a cutoff, instead of reading every page.
+ */
+ created_before?: string;
/**
* Report ids to leave out of the results and counts, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.
* @maxItems 100
diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.ts
index 6c6bd78845a6..9f0127e2984d 100644
--- a/services/mcp/src/generated/signals/api.ts
+++ b/services/mcp/src/generated/signals/api.ts
@@ -443,6 +443,12 @@ export const SignalsReportsListQueryParams = () => zod.object({
.datetime({ offset: true })
.optional()
.describe('ISO 8601 datetime. Keeps reports created at or after this time.'),
+ created_before: zod.iso
+ .datetime({ offset: true })
+ .optional()
+ .describe(
+ 'ISO 8601 datetime. Keeps reports created before this time. Use it for reports older than a cutoff, instead of reading every page.'
+ ),
exclude: zod
.array(zod.string())
.max(signalsReportsListQueryExcludeMax)
diff --git a/services/mcp/src/tools/generated/signals.ts b/services/mcp/src/tools/generated/signals.ts
index 2973cbcc36be..d8f8b462c227 100644
--- a/services/mcp/src/tools/generated/signals.ts
+++ b/services/mcp/src/tools/generated/signals.ts
@@ -816,6 +816,7 @@ const inboxReportsList = (): ToolBase<
channel_id: params.channel_id,
count_only: params.count_only,
created_after: params.created_after,
+ created_before: params.created_before,
exclude: params.exclude,
has_implementation_pr: params.has_implementation_pr,
include_all_statuses: params.include_all_statuses,
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-list.json
index 06693024951b..94e1ed72c6f7 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-list.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-list.json
@@ -29,6 +29,12 @@
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
"type": "string"
},
+ "created_before": {
+ "description": "ISO 8601 datetime. Keeps reports created before this time. Use it for reports older than a cutoff, instead of reading every page.",
+ "format": "date-time",
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
+ "type": "string"
+ },
"exclude": {
"description": "Report ids to leave out of the results and counts, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.",
"items": {