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): let report check lookups work with a report id alone (#107245)

posthog[bot]3727d83497aa
diff --git a/products/signals/backend/scout_harness/views.py b/products/signals/backend/scout_harness/views.py
index c108cf462db6..5232242363d9 100644
--- a/products/signals/backend/scout_harness/views.py
+++ b/products/signals/backend/scout_harness/views.py
@@ -1679,6 +1679,43 @@ class SignalScoutRunViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
status=status.HTTP_200_OK,
)
+ @validated_request(
+ query_serializer=ListReportChecksQuerySerializer,
+ responses={
+ 200: OpenApiResponse(
+ response=ScoutCheckSummarySerializer(many=True), description="The report's checks, newest first."
+ ),
+ 400: OpenApiResponse(description="The report does not exist for this project."),
+ },
+ summary="List a report's follow-up checks",
+ description=(
+ "Every check on one report, newest first. The `report_id` is the only input. Read this before "
+ "writing one: a report already carrying a check for the same claim needs no second one, and a "
+ "report holds at most five open checks at a time."
+ ),
+ operation_id="signals_scout_report_check_list",
+ )
+ # nosemgrep: api-path-underscore -- matches the per-run path it replaces
+ @action(
+ detail=False,
+ methods=["get"],
+ url_path="report-checks",
+ required_scopes=["signal_scout_report:write"],
+ pagination_class=None,
+ )
+ def report_check_list(self, request: Request, **kwargs) -> Response:
+ # A read needs no run: the project scope is the tenant boundary, and the REST
+ # report-checks endpoint shows the same rows to anyone who can read the report.
+ validated = getattr(request, "validated_query_data", {}) or {}
+ try:
+ checks = list_report_checks(team=_canonical_team(self), report_id=str(validated["report_id"]))
+ except InvalidCheckWriteError as exc:
+ raise exceptions.ValidationError({"detail": str(exc)})
+ return Response(
+ ScoutCheckSummarySerializer([dataclasses.asdict(check) for check in checks], many=True).data,
+ status=status.HTTP_200_OK,
+ )
+
@validated_request(
request_serializer=CancelReportCheckRequestSerializer,
parameters=[_RUN_ID_PATH_PARAMETER],
diff --git a/products/signals/backend/test/test_scout_report_api.py b/products/signals/backend/test/test_scout_report_api.py
index 21e4fe61397a..b602c337a9f8 100644
--- a/products/signals/backend/test/test_scout_report_api.py
+++ b/products/signals/backend/test/test_scout_report_api.py
@@ -2739,18 +2739,30 @@ class TestScoutReportCheckAPI(APIBaseTest):
assert response.status_code == status.HTTP_400_BAD_REQUEST, response.content
assert not SignalReportCheck.objects.for_team(other_team.id).exists()
- def test_listing_a_reports_checks_returns_what_the_run_wrote(self) -> None:
+ @parameterized.expand([("report_level", False), ("per_run", True)])
+ def test_listing_a_reports_checks_returns_what_the_run_wrote(self, _name: str, via_run: bool) -> None:
self._opt_in(REPORT_TOOLS)
created = self.client.post(self._create_url(), self._payload(), format="json").json()
+ run_segment = f"{self.scout_run.id}/" if via_run else ""
response = self.client.get(
- f"/api/projects/{self.team.id}/signals/scout/runs/{self.scout_run.id}/report-checks/",
+ f"/api/projects/{self.team.id}/signals/scout/runs/{run_segment}report-checks/",
{"report_id": str(self.report.id)},
)
assert response.status_code == status.HTTP_200_OK, response.content
assert [row["check_id"] for row in response.json()] == [created["check_id"]]
+ def test_report_level_listing_needs_no_run_and_stays_in_the_canonical_team(self) -> None:
+ child = Team.objects.create(organization=self.organization, parent_team=self.team, name="Child")
+ child_report = SignalReport.objects.create(team=child, status=SignalReport.Status.READY, title="Checkout")
+ other_team = Team.objects.create(organization=self.organization, project=self.team.project, name="Other")
+ other_report = SignalReport.objects.create(team=other_team, status=SignalReport.Status.READY, title="Other")
+ url = f"/api/projects/{self.team.id}/signals/scout/runs/report-checks/"
+
+ assert self.client.get(url, {"report_id": str(child_report.id)}).status_code == status.HTTP_200_OK
+ assert self.client.get(url, {"report_id": str(other_report.id)}).status_code == status.HTTP_400_BAD_REQUEST
+
def test_cancelling_stops_the_check(self) -> None:
self._opt_in(REPORT_TOOLS)
created = self.client.post(self._create_url(), self._payload(), format="json").json()
diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.ts
index 66dc26061048..de3a9846ca39 100644
--- a/products/signals/frontend/generated/api.schemas.ts
+++ b/products/signals/frontend/generated/api.schemas.ts
@@ -6605,6 +6605,13 @@ export type SignalsScoutRunsRecentPerScoutParams = {
per_scout_limit?: number
}
+export type SignalsScoutReportCheckListParams = {
+ /**
+ * The report whose checks to list.
+ */
+ report_id: string
+}
+
export type SignalsScoutScratchpadSearchParams = {
/**
* Truncate each entry's `content` to the first N characters (a preview). Omit for the full body. Ignored when `keys_only=true`.
diff --git a/products/signals/frontend/generated/api.ts b/products/signals/frontend/generated/api.ts
index 1244e14aaf90..79689f3a50d9 100644
--- a/products/signals/frontend/generated/api.ts
+++ b/products/signals/frontend/generated/api.ts
@@ -119,6 +119,7 @@ import type {
SignalsScoutMembersListParams,
SignalsScoutNotesListParams,
SignalsScoutProjectProfileGetParams,
+ SignalsScoutReportCheckListParams,
SignalsScoutReportChecksListParams,
SignalsScoutRunsCostsParams,
SignalsScoutRunsFindingsSummaryParams,
@@ -2012,6 +2013,37 @@ export const signalsScoutRunsRecentPerScout = async (
})
}
+export const getSignalsScoutReportCheckListUrl = (projectId: string, params: SignalsScoutReportCheckListParams) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : String(value))
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/projects/${projectId}/signals/scout/runs/report-checks/?${stringifiedParams}`
+ : `/api/projects/${projectId}/signals/scout/runs/report-checks/`
+}
+
+/**
+ * Every check on one report, newest first. The `report_id` is the only input. Read this before writing one: a report already carrying a check for the same claim needs no second one, and a report holds at most five open checks at a time.
+ * @summary List a report's follow-up checks
+ */
+export const signalsScoutReportCheckList = async (
+ projectId: string,
+ params: SignalsScoutReportCheckListParams,
+ options?: RequestInit
+): Promise<ScoutCheckSummaryApi[]> => {
+ return apiMutator<ScoutCheckSummaryApi[]>(getSignalsScoutReportCheckListUrl(projectId, params), {
+ ...options,
+ method: 'GET',
+ })
+}
+
export const getSignalsScoutRunsTokenCostsUrl = (projectId: string) => {
return `/api/projects/${projectId}/signals/scout/runs/token-costs/`
}
diff --git a/products/signals/mcp/tools.yaml b/products/signals/mcp/tools.yaml
index b3ff7b626424..a73663086722 100644
--- a/products/signals/mcp/tools.yaml
+++ b/products/signals/mcp/tools.yaml
@@ -954,7 +954,7 @@ tools:
the report as a `check_result` entry people read in the inbox. Check `scout-report-check-list` first: a
report holds at most five open checks, and a second check for the same claim is noise.
scout-report-check-list:
- operation: signals_scout_report_checks_list
+ operation: signals_scout_report_check_list
enabled: true
scopes:
- signal_scout_report:write
@@ -965,12 +965,12 @@ tools:
title: List a report's follow-up checks
description: >
Every follow-up check on one report, newest first, with its kind, status, next run and last verdict. Pass
- the `run_id` of your own in-progress run and the `report_id` of the report to read; both are required. Read
- this before writing a check: a report already carrying one for the same claim needs no second, and a report
- holds at most five open checks at a time. A `pending` check is waiting for the report to resolve before its
- clock starts; every status other than `pending` and `active` is terminal.
+ the `report_id` of the report to read; no `run_id` is needed. Read this before writing a check: a report
+ already carrying one for the same claim needs no second, and a report holds at most five open checks at a
+ time. A `pending` check is waiting for the report to resolve before its clock starts; every status other
+ than `pending` and `active` is terminal.
scout-report-checks-list:
- operation: signals_scout_report_checks_list
+ operation: signals_scout_report_check_list
enabled: true
scopes:
- signal_scout_report:write
@@ -1378,6 +1378,9 @@ tools:
description:
'DEPRECATED: renamed to scout-project-profile-get. This alias forwards to the same endpoint and will be
removed. Call scout-project-profile-get directly with the same arguments.'
+ signals-scout-report-checks-list:
+ operation: signals_scout_report_checks_list
+ enabled: false
signals-scout-run-now:
operation: signals_scout_config_run
enabled: true
diff --git a/products/signals/skills/authoring-scouts/references/report-checks.md b/products/signals/skills/authoring-scouts/references/report-checks.md
index ec1226bc3335..d6bbabd48fec 100644
--- a/products/signals/skills/authoring-scouts/references/report-checks.md
+++ b/products/signals/skills/authoring-scouts/references/report-checks.md
@@ -11,7 +11,7 @@ There is no create surface for a person or a task token: the `inbox-report-check
Always list the report's checks before you write one:
-- Inside a run: `posthog:scout-report-check-list {"run_id": "<your run>", "report_id": "<report>"}`.
+- Inside a run: `posthog:scout-report-check-list {"report_id": "<report>"}`. The `report_id` is the only input.
- Outside a run: `posthog:inbox-report-checks-list` (read-only, `task:read`).
Two reasons this is a hard step, not a courtesy:
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 4c553c0db854..c65f7f1b4225 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -10456,7 +10456,7 @@
}
},
"scout-report-check-list": {
- "description": "Every follow-up check on one report, newest first, with its kind, status, next run and last verdict. Pass the `run_id` of your own in-progress run and the `report_id` of the report to read; both are required. Read this before writing a check: a report already carrying one for the same claim needs no second, and a report holds at most five open checks at a time. A `pending` check is waiting for the report to resolve before its clock starts; every status other than `pending` and `active` is terminal.",
+ "description": "Every follow-up check on one report, newest first, with its kind, status, next run and last verdict. Pass the `report_id` of the report to read; no `run_id` is needed. Read this before writing a check: a report already carrying one for the same claim needs no second, and a report holds at most five open checks at a time. A `pending` check is waiting for the report to resolve before its clock starts; every status other than `pending` and `active` is terminal.",
"category": "Signals",
"feature": "signals",
"summary": "List a report's follow-up checks",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 6b06432237fd..480fca445099 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -11028,7 +11028,7 @@
}
},
"scout-report-check-list": {
- "description": "Every follow-up check on one report, newest first, with its kind, status, next run and last verdict. Pass the `run_id` of your own in-progress run and the `report_id` of the report to read; both are required. Read this before writing a check: a report already carrying one for the same claim needs no second, and a report holds at most five open checks at a time. A `pending` check is waiting for the report to resolve before its clock starts; every status other than `pending` and `active` is terminal.",
+ "description": "Every follow-up check on one report, newest first, with its kind, status, next run and last verdict. Pass the `report_id` of the report to read; no `run_id` is needed. Read this before writing a check: a report already carrying one for the same claim needs no second, and a report holds at most five open checks at a time. A `pending` check is waiting for the report to resolve before its clock starts; every status other than `pending` and `active` is terminal.",
"category": "Signals",
"feature": "signals",
"summary": "List a report's follow-up checks",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 74004dde44c0..ceeb724ea080 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -116260,6 +116260,13 @@ export namespace Schemas {
per_scout_limit?: number;
};
+ export type SignalsScoutReportCheckListParams = {
+ /**
+ * The report whose checks to list.
+ */
+ report_id: string;
+ };
+
export type SignalsScoutScratchpadSearchParams = {
/**
* Truncate each entry's `content` to the first N characters (a preview). Omit for the full body. Ignored when `keys_only=true`.
diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.ts
index 8d605c9669b3..fe42da7d0752 100644
--- a/services/mcp/src/generated/signals/api.ts
+++ b/services/mcp/src/generated/signals/api.ts
@@ -2689,23 +2689,6 @@ export const SignalsScoutReportCheckCreateBody = () => zod
'Request body for `scout-report-check-create`: one forward-looking check on a report.\n\nThe REST body plus the report it attaches to. Subclassed rather than restated so the schedule\nbounds a scout writes under are the ones the endpoint enforces, with no second copy to drift.'
)
-/**
- * Every check on one report, newest first. Read this before writing one: a report already carrying a check for the same claim needs no second one, and a report holds at most five open checks at a time.
- * @summary List a report's follow-up checks
- */
-export const SignalsScoutReportChecksListParams = () => zod.object({
- 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\/."
- ),
- run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
-})
-
-export const SignalsScoutReportChecksListQueryParams = () => zod.object({
- report_id: zod.string().describe('The report whose checks to list.'),
-})
-
/**
* Return the team's recently emitted scout findings across *every* run, newest first — the cross-run counterpart to the per-run `emissions` action. Each row carries its `run_id`, so you can regroup by run without first listing runs and fanning out one `emissions` call each. Pass `skill_name` to scope to a single scout, and `date_from` / `date_to` (a half-open window on `emitted_at`) to bound or paginate — set `date_to` to the oldest emission's `emitted_at` to walk back past the limit. Pure Postgres, no ClickHouse round-trip. Capped at 200 rows (default 50).
* @summary List recent emitted findings across all runs
@@ -2746,6 +2729,22 @@ export const SignalsScoutRunsRecentEmissionsQueryParams = () => zod.object({
),
})
+/**
+ * Every check on one report, newest first. The `report_id` is the only input. Read this before writing one: a report already carrying a check for the same claim needs no second one, and a report holds at most five open checks at a time.
+ * @summary List a report's follow-up checks
+ */
+export const SignalsScoutReportCheckListParams = () => zod.object({
+ 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 SignalsScoutReportCheckListQueryParams = () => zod.object({
+ report_id: zod.string().describe('The report whose checks to list.'),
+})
+
/**
* Return `SignalScratchpad` entries for this project, newest-first. ILIKE matches on `content` and `key`; pass `key` instead for an exact single-entry lookup. `date_from` / `date_to` are a half-open window on `updated_at` (`>= date_from`, `< date_to`); pass `date_to` (the `updated_at` of the oldest entry seen) on subsequent calls to walk past the cap. Entries whose `expires_at` has passed are excluded unless `include_expired=true`, and are hard-deleted by a daily janitor once their expiry is more than two weeks in the past. Pass `keys_only=true` to scan keys without pulling entry bodies, or `content_max_chars` to cap each `content` to a preview — both keep a wide orientation scan from returning every entry's full prose. Results capped at 1000.
* @summary Search the scout scratchpad
diff --git a/services/mcp/src/tools/generated/signals.ts b/services/mcp/src/tools/generated/signals.ts
index 6c42baec50cb..4911fd3c54bc 100644
--- a/services/mcp/src/tools/generated/signals.ts
+++ b/services/mcp/src/tools/generated/signals.ts
@@ -1453,11 +1453,8 @@ const scoutReportCheckCreate = (): ToolBase<
})
const ScoutReportCheckListSchema = () => {
- const SignalsScoutReportChecksListParams = orvalSchemas.SignalsScoutReportChecksListParams()
- const SignalsScoutReportChecksListQueryParams = orvalSchemas.SignalsScoutReportChecksListQueryParams()
- return SignalsScoutReportChecksListParams.omit({ project_id: true }).extend(
- SignalsScoutReportChecksListQueryParams.shape
- )
+ const SignalsScoutReportCheckListQueryParams = orvalSchemas.SignalsScoutReportCheckListQueryParams()
+ return SignalsScoutReportCheckListQueryParams
}
const scoutReportCheckList = (): ToolBase<
@@ -1470,7 +1467,7 @@ const scoutReportCheckList = (): ToolBase<
const projectId = await context.stateManager.getProjectId()
const result = await context.api.request<Schemas.ScoutCheckSummary[]>({
method: 'GET',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/scout/runs/${encodeURIComponent(String(params.run_id))}/report-checks/`,
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/scout/runs/report-checks/`,
query: {
report_id: params.report_id,
},
@@ -1480,11 +1477,8 @@ const scoutReportCheckList = (): ToolBase<
})
const ScoutReportChecksListSchema = () => {
- const SignalsScoutReportChecksListParams = orvalSchemas.SignalsScoutReportChecksListParams()
- const SignalsScoutReportChecksListQueryParams = orvalSchemas.SignalsScoutReportChecksListQueryParams()
- return SignalsScoutReportChecksListParams.omit({ project_id: true }).extend(
- SignalsScoutReportChecksListQueryParams.shape
- )
+ const SignalsScoutReportCheckListQueryParams = orvalSchemas.SignalsScoutReportCheckListQueryParams()
+ return SignalsScoutReportCheckListQueryParams
}
const scoutReportChecksList = (): ToolBase<
@@ -1497,7 +1491,7 @@ const scoutReportChecksList = (): ToolBase<
const projectId = await context.stateManager.getProjectId()
const result = await context.api.request<Schemas.ScoutCheckSummary[]>({
method: 'GET',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/scout/runs/${encodeURIComponent(String(params.run_id))}/report-checks/`,
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/scout/runs/report-checks/`,
query: {
report_id: params.report_id,
},