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(subscriptions): drop ai_report_prompt from deliveries list rows (#88215)

posthog[bot]9ddf4e376654
diff --git a/products/subscriptions/mcp/tools.yaml b/products/subscriptions/mcp/tools.yaml
index 7088afb80a44..67b8c6e2840e 100644
--- a/products/subscriptions/mcp/tools.yaml
+++ b/products/subscriptions/mcp/tools.yaml
@@ -93,15 +93,17 @@ tools:
completed, failed, skipped), trigger_type (scheduled, manual, target_change), and timestamps (created_at,
finished_at). Filter with status=failed to quickly surface failed deliveries. Results are cursor-paginated
newest first. content_snapshot, recipient_results, and error are excluded to avoid leaking recipient
- identifiers or upstream response bodies that may contain tokens / PII. ai_report (the full report markdown)
- and ai_report_diagnostics (per-query debug detail) are also excluded here to keep list responses small —
- fetch a single delivery with subscriptions-deliveries-retrieve to read the report.
+ identifiers or upstream response bodies that may contain tokens / PII. ai_report (the full report markdown),
+ ai_report_prompt (the prompt it was generated from), and ai_report_diagnostics (per-query debug detail) are
+ also excluded here to keep list responses small — fetch a single delivery with
+ subscriptions-deliveries-retrieve to read the report and its prompt.
response:
exclude:
- content_snapshot
- recipient_results
- error
- ai_report
+ - ai_report_prompt
- ai_report_diagnostics
subscriptions-deliveries-retrieve:
operation: subscriptions_deliveries_retrieve
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 6b49d8a8c197..5b27265b6802 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -10168,7 +10168,7 @@
}
},
"subscriptions-deliveries-list": {
- "description": "List delivery history for a subscription — one row per send attempt. Each entry includes status (starting, completed, failed, skipped), trigger_type (scheduled, manual, target_change), and timestamps (created_at, finished_at). Filter with status=failed to quickly surface failed deliveries. Results are cursor-paginated newest first. content_snapshot, recipient_results, and error are excluded to avoid leaking recipient identifiers or upstream response bodies that may contain tokens / PII. ai_report (the full report markdown) and ai_report_diagnostics (per-query debug detail) are also excluded here to keep list responses small — fetch a single delivery with subscriptions-deliveries-retrieve to read the report.",
+ "description": "List delivery history for a subscription — one row per send attempt. Each entry includes status (starting, completed, failed, skipped), trigger_type (scheduled, manual, target_change), and timestamps (created_at, finished_at). Filter with status=failed to quickly surface failed deliveries. Results are cursor-paginated newest first. content_snapshot, recipient_results, and error are excluded to avoid leaking recipient identifiers or upstream response bodies that may contain tokens / PII. ai_report (the full report markdown), ai_report_prompt (the prompt it was generated from), and ai_report_diagnostics (per-query debug detail) are also excluded here to keep list responses small — fetch a single delivery with subscriptions-deliveries-retrieve to read the report and its prompt.",
"category": "Subscriptions",
"feature": "subscriptions",
"summary": "List subscription deliveries",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 0c9668c86a35..318f96786df6 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -10709,7 +10709,7 @@
}
},
"subscriptions-deliveries-list": {
- "description": "List delivery history for a subscription — one row per send attempt. Each entry includes status (starting, completed, failed, skipped), trigger_type (scheduled, manual, target_change), and timestamps (created_at, finished_at). Filter with status=failed to quickly surface failed deliveries. Results are cursor-paginated newest first. content_snapshot, recipient_results, and error are excluded to avoid leaking recipient identifiers or upstream response bodies that may contain tokens / PII. ai_report (the full report markdown) and ai_report_diagnostics (per-query debug detail) are also excluded here to keep list responses small — fetch a single delivery with subscriptions-deliveries-retrieve to read the report.",
+ "description": "List delivery history for a subscription — one row per send attempt. Each entry includes status (starting, completed, failed, skipped), trigger_type (scheduled, manual, target_change), and timestamps (created_at, finished_at). Filter with status=failed to quickly surface failed deliveries. Results are cursor-paginated newest first. content_snapshot, recipient_results, and error are excluded to avoid leaking recipient identifiers or upstream response bodies that may contain tokens / PII. ai_report (the full report markdown), ai_report_prompt (the prompt it was generated from), and ai_report_diagnostics (per-query debug detail) are also excluded here to keep list responses small — fetch a single delivery with subscriptions-deliveries-retrieve to read the report and its prompt.",
"category": "Subscriptions",
"feature": "subscriptions",
"summary": "List subscription deliveries",
diff --git a/services/mcp/src/tools/generated/subscriptions.ts b/services/mcp/src/tools/generated/subscriptions.ts
index fe2614571de4..7f0e1e9f6a10 100644
--- a/services/mcp/src/tools/generated/subscriptions.ts
+++ b/services/mcp/src/tools/generated/subscriptions.ts
@@ -142,6 +142,7 @@ const subscriptionsDeliveriesList = (): ToolBase<
'recipient_results',
'error',
'ai_report',
+ 'ai_report_prompt',
'ai_report_diagnostics',
])
),
diff --git a/services/mcp/tests/unit/subscriptions-deliveries-response-shape.test.ts b/services/mcp/tests/unit/subscriptions-deliveries-response-shape.test.ts
new file mode 100644
index 000000000000..a08b9689c632
--- /dev/null
+++ b/services/mcp/tests/unit/subscriptions-deliveries-response-shape.test.ts
@@ -0,0 +1,75 @@
+import { describe, expect, it, vi } from 'vitest'
+
+import { GENERATED_TOOLS } from '@/tools/generated/subscriptions'
+import type { Context } from '@/tools/types'
+
+function createMockContext(requestMock: ReturnType<typeof vi.fn>): Context {
+ return {
+ api: {
+ request: requestMock,
+ getProjectBaseUrl: (projectId: string) => `https://us.posthog.com/project/${projectId}`,
+ } as any,
+ stateManager: { getProjectId: vi.fn().mockResolvedValue('42') } as any,
+ env: {} as any,
+ sessionManager: {} as any,
+ cache: {} as any,
+ getDistinctId: async () => 'test-distinct-id',
+ trackEvent: async () => {},
+ }
+}
+
+const aiDelivery = (id: string): Record<string, unknown> => ({
+ id,
+ status: 'completed',
+ trigger_type: 'scheduled',
+ created_at: '2026-08-25T00:00:00Z',
+ finished_at: '2026-08-25T00:01:00Z',
+ ai_report: '# Weekly report\n\nfull markdown body',
+ ai_report_prompt: 'Summarize the weekly product usage in detail',
+ ai_report_diagnostics: [{ query: 'SELECT 1', error: null }],
+ content_snapshot: { insight: 'frozen state' },
+ recipient_results: [{ email: '[email protected]', status: 'sent' }],
+ error: null,
+})
+
+describe('subscriptions deliveries response shape', () => {
+ it('list strips the AI report prompt and report content from every row', async () => {
+ const request = vi.fn().mockResolvedValue({
+ results: [aiDelivery('d1'), aiDelivery('d2')],
+ next: null,
+ previous: null,
+ })
+
+ const result = await GENERATED_TOOLS['subscriptions-deliveries-list']!().handler(createMockContext(request), {
+ subscription_id: 107463,
+ })
+
+ for (const row of (result as any).results) {
+ // Metadata a history view needs stays present.
+ expect(row.id).toBeTruthy()
+ expect(row.status).toBe('completed')
+ expect(row.trigger_type).toBe('scheduled')
+ // Bulky and sensitive fields are excluded to keep list responses small.
+ expect(row).not.toHaveProperty('ai_report_prompt')
+ expect(row).not.toHaveProperty('ai_report')
+ expect(row).not.toHaveProperty('ai_report_diagnostics')
+ expect(row).not.toHaveProperty('content_snapshot')
+ expect(row).not.toHaveProperty('recipient_results')
+ expect(row).not.toHaveProperty('error')
+ }
+ })
+
+ it('retrieve keeps the AI report and its prompt for a single delivery', async () => {
+ const request = vi.fn().mockResolvedValue(aiDelivery('d1'))
+
+ const result = await GENERATED_TOOLS['subscriptions-deliveries-retrieve']!().handler(
+ createMockContext(request),
+ { subscription_id: 107463, id: 'd1' }
+ )
+
+ expect(result).toHaveProperty('ai_report')
+ expect(result).toHaveProperty('ai_report_prompt')
+ // Diagnostics stay excluded to keep the response focused on the report.
+ expect(result).not.toHaveProperty('ai_report_diagnostics')
+ })
+})