: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
chore(agent-platform): prune redundant example bundles (#69402)
Dylan Martinceb23d0ee2cf
diff --git a/products/agent_platform/services/agent-shared/src/runtime/slack-mrkdwn.test.ts b/products/agent_platform/services/agent-shared/src/runtime/slack-mrkdwn.test.tsindex 3355d1961255..1c90bbe7d6e6 100644--- a/products/agent_platform/services/agent-shared/src/runtime/slack-mrkdwn.test.ts+++ b/products/agent_platform/services/agent-shared/src/runtime/slack-mrkdwn.test.ts@@ -135,7 +135,7 @@ describe('markdownToMrkdwn', () => {})describe('realistic mixed messages', () => {- it('a kudos-bot style digest', () => {+ it('a weekly digest with links and a rule', () => {const md = ['# Kudos — week of Jun 16','',diff --git a/products/agent_platform/services/agent-tests/src/cases/example-agent-builder.test.ts b/products/agent_platform/services/agent-tests/src/cases/example-agent-builder.test.tsindex 2317523a1e4b..5961a156e097 100644--- a/products/agent_platform/services/agent-tests/src/cases/example-agent-builder.test.ts+++ b/products/agent_platform/services/agent-tests/src/cases/example-agent-builder.test.ts@@ -3,8 +3,7 @@** The Agent Builder authors + operates other agents through the PostHog MCP* (one `spec.mcps[]` entry authed by the `posthog` identity provider), acting- * as the asking user — the same pattern as `posthog-ai`, applied to the- * authoring surface. It keeps only its own runtime natives (`@posthog/memory-*`+ * as the asking user. It keeps only its own runtime natives (`@posthog/memory-*`* plus `@posthog/web-search`) and the PostHog Code client/UI tools. Destructive authoring ops* (`promote` / `archive` / `destroy`) are approval-gated on the MCP `tools[]`* via `level: 'approve'` + `approval_policy`, so the platform — notdiff --git a/products/agent_platform/services/agent-tests/src/cases/example-kudos-bot.test.ts b/products/agent_platform/services/agent-tests/src/cases/example-kudos-bot.test.tsdeleted file mode 100644index a0cc0eaeff80..000000000000--- a/products/agent_platform/services/agent-tests/src/cases/example-kudos-bot.test.ts+++ /dev/null@@ -1,527 +0,0 @@-/**- * Example bundle e2e — `services/agent-tests/src/examples/kudos-bot/`.- *- * Loads the kudos-bot bundle from disk, deploys it through the harness,- * and drives both halves of the agent with the faux model:- *- * 1. Capture — a signed Slack `app_mention` ("kudos to @jane …") runs- * through react → append row → write profile, proving the slack- * trigger + native slack tools + tabular + prose memory all wire up.- * 2. Celebrate — the weekly `cron` firing (`cronTick`) queries last- * week's rows and posts the digest.- *- * Like the sibling example tests this is a WIRING regression net, not a- * real-inference test — the model is faux; the assertions are about the- * bundle's spec / skill paths / tool ids staying in sync with the runner- * and tool registry, not about whether the agent's prose is good.- */--import { readFile } from 'node:fs/promises'-import { dirname, join, resolve } from 'node:path'-import { fileURLToPath } from 'node:url'--import { cronTick, newCronTickState } from '@posthog/agent-janitor'--import { buildCluster, closeSharedPool, Cluster, fauxCallTool, fauxText } from '../harness'--const SLACK_SECRET = 'kudos-test-slack-secret'-const WORKSPACE = 'T0XXXXXXX' // matches the bundle's trusted_workspaces placeholder--const __dirname = dirname(fileURLToPath(import.meta.url))-const BUNDLE_ROOT = resolve(__dirname, '../examples/kudos-bot')-const BUNDLE_FILES = [- 'agent.md',- 'skills/capturing-kudos/SKILL.md',- 'skills/kudos-storage/SKILL.md',- 'skills/weekly-summary/SKILL.md',-] as const--async function loadBundle(): Promise<{ spec: Record<string, unknown>; files: Record<string, string> }> {- const spec = JSON.parse(await readFile(join(BUNDLE_ROOT, 'spec.json'), 'utf-8')) as Record<string, unknown>- const files: Record<string, string> = {}- for (const path of BUNDLE_FILES) {- files[path] = await readFile(join(BUNDLE_ROOT, path), 'utf-8')- }- return { spec, files }-}--/** A Slack `app_mention` callback carrying the workspace id so the- * trusted_workspaces gate (set to `[WORKSPACE]` in the bundle) passes. */-function kudosMention(): Record<string, unknown> {- return {- type: 'event_callback',- event_id: 'Ev_kudos_capture',- event: {- type: 'app_mention',- team: WORKSPACE,- channel: 'C-kudos',- user: 'U-ben',- text: '<@U-bot> kudos to <@U-jane> for unblocking the events migration — saved us a day',- ts: '1717430400.000100',- },- }-}--/** A Slack event in a single channel/thread, carrying the workspace id so the- * trusted_workspaces gate passes. The opener is an `app_mention`; follow-ups- * are plain `message` events that `auto_resume_threads` routes back into the- * open session. All from the same user (U-ben) so the per-session ACL admits- * them without an elevation round-trip. */-function slackThreadEvent(opts: {- eventType: 'app_mention' | 'message'- text: string- ts: string- thread_ts?: string- event_id: string-}): Record<string, unknown> {- return {- type: 'event_callback',- event_id: opts.event_id,- event: {- type: opts.eventType,- team: WORKSPACE,- channel: 'C-kudos',- user: 'U-ben',- text: opts.text,- ts: opts.ts,- thread_ts: opts.thread_ts,- },- }-}--/** One captured Slack Web API call. */-interface SlackCall {- method: string // slack api method, e.g. chat.postMessage- auth?: string- body: Record<string, unknown>-}--/** Slack tools send form-encoded bodies; the reply relay sends JSON. Parse- * either into a plain object so assertions can read the fields. */-function parseSlackBody(body: RequestInit['body']): Record<string, unknown> {- if (typeof body !== 'string') {- return {}- }- if (body.trimStart().startsWith('{')) {- try {- return JSON.parse(body) as Record<string, unknown>- } catch {- return {}- }- }- return Object.fromEntries(new URLSearchParams(body))-}--/** A recording `HttpClient` stand-in. The native `@posthog/slack-*` tools- * dispatch through `ctx.http.fetch` (NOT `global.fetch`), so the reliable- * way to intercept + assert on the Slack calls is to pass this as the- * cluster's `http` — same approach as `example-sre-bot.test.ts`. */-function buildSlackRecorder(): { http: { fetch: typeof fetch }; calls: SlackCall[] } {- const calls: SlackCall[] = []- const http = {- fetch: ((input: string | URL, init?: RequestInit) => {- const url = typeof input === 'string' ? input : input.toString()- if (url.includes('slack.com/api/')) {- const headers = (init?.headers ?? {}) as Record<string, string>- calls.push({- method: url.replace('https://slack.com/api/', ''),- auth: headers.Authorization,- body: parseSlackBody(init?.body),- })- }- return Promise.resolve({- ok: true,- status: 200,- json: async () => ({ ok: true, ts: '1717862400.000100', channel: 'C-kudos' }),- text: async () => '{"ok":true}',- headers: new Map([['content-type', 'application/json']]),- } as unknown as Response)- }) as unknown as typeof fetch,- }- return { http, calls }-}--/** Build a cluster wired with the Slack secrets + an http recorder. The- * native slack tools resolve SLACK_BOT_TOKEN via ctx.secret; the slack- * TRIGGER verifies the signature with SLACK_SIGNING_SECRET out of- * encrypted_env (wired per-agent on deployAgent). */-async function buildKudosCluster(http: { fetch: typeof fetch }): Promise<Cluster> {- return buildCluster({- resolveSecrets: async () => ({- SLACK_BOT_TOKEN: 'xoxb-faux',- SLACK_SIGNING_SECRET: SLACK_SECRET,- }),- http,- })-}--describe('example: kudos-bot bundle', () => {- let c: Cluster- let slackCalls: SlackCall[]-- beforeEach(async () => {- const recorder = buildSlackRecorder()- slackCalls = recorder.calls- c = await buildKudosCluster(recorder.http)- })-- afterEach(async () => {- await c.teardown()- })-- afterAll(async () => {- await closeSharedPool()- })-- it('loads cleanly — spec parses, every skill path resolves to a bundle file', async () => {- const { spec, files } = await loadBundle()- const skillPaths = (spec.skills as Array<{ path: string }>).map((s) => s.path)- for (const p of skillPaths) {- expect(files[p]).not.toBeUndefined()- }- expect(files['agent.md']).not.toBeUndefined()- expect(files['agent.md'].length).toBeGreaterThan(500)- })-- it('captures a kudos from a Slack @mention — reacts, records the row, writes the profile', async () => {- const { spec, files } = await loadBundle()-- c.setScript([- // Phase 1: how to read a kudos.- fauxCallTool('@posthog/load-skill', { id: 'capturing-kudos' }),- // Phase 2: the storage schema + dedupe key.- fauxCallTool('@posthog/load-skill', { id: 'kudos-storage' }),- // Phase 3: is there already a profile for this recipient?- fauxCallTool('@posthog/memory-search', { cue: 'jane', prefix: 'people/' }),- // Phase 4: record the kudos row, deduped on kudos_id.- fauxCallTool('@posthog/table-append', {- table: 'kudos',- rows: [- {- kudos_id: 'slack:C-kudos:1717430400.000100:<@U-jane>',- recipient_handle: '<@U-jane>',- giver_handle: '<@U-ben>',- message: 'unblocking the events migration — saved us a day',- themes: 'teamwork,above-and-beyond',- given_at: '2026-06-03T16:00:00Z',- week: '2026-W23',- source: 'slack',- permalink: '',- },- ],- dedupe_on: 'kudos_id',- }),- // Phase 5: first kudos for this person → create their profile.- fauxCallTool('@posthog/memory-write', {- path: 'people/u-jane.md',- description: 'Kudos profile for <@U-jane>',- content:- '# <@U-jane>\n\n## Highlights\n\n- 2026-06-03 — unblocked the events migration, saved the team a day (from <@U-ben>) · _teamwork, above-and-beyond_\n',- tags: ['person', 'kudos'],- }),- // Phase 6: confirm with a :tada: reaction on the original message.- fauxCallTool('@posthog/slack-react', {- channel: 'C-kudos',- ts: '1717430400.000100',- name: 'tada',- }),- // Phase 7: leave the thread open for follow-ups.- fauxText('Recorded — kudos to <@U-jane> for the migration unblock. 🎉'),- ])-- const { application } = await c.deployAgent({- slug: 'kudos-bot',- spec,- files,- encrypted_env: { SLACK_SIGNING_SECRET: SLACK_SECRET },- })-- const res = await c.slackPost('kudos-bot', 'events', kudosMention(), SLACK_SECRET)- expect(res.status).toBe(200)- expect(res.body.session_id).toBeTruthy()- await c.drain({ iterations: 100 })-- const session = await c.queue.get(res.body.session_id)- expect(session!.state).toBe('completed')-- // The seed message carries the [slack] envelope so the model can route- // its reply/react back to the right channel + message.- const seed = session!.conversation.find((m) => m.role === 'user') as { role: string; content: string }- expect(seed.content).toContain('[slack]')- expect(seed.content).toContain('channel: C-kudos')- expect(seed.content).toContain('kudos to <@U-jane>')-- const calledTools = session!.conversation- .filter((m) => m.role === 'toolResult')- .map((m) => (m as { toolName?: string }).toolName)- expect(calledTools).toEqual([- '@posthog/load-skill', // capturing-kudos- '@posthog/load-skill', // kudos-storage- '@posthog/memory-search',- '@posthog/table-append',- '@posthog/memory-write',- '@posthog/slack-react',- ])-- // The kudos row landed in the tabular store — proves the tool wired- // through to a real S3 backend, scoped to this app.- const scope = { teamId: session!.team_id, applicationId: application.id }- const rows = await c.tabularStore.query(scope, 'kudos', { where: { recipient_handle: '<@U-jane>' } })- expect(rows).toHaveLength(1)- expect(rows[0]).toMatchObject({- recipient_handle: '<@U-jane>',- giver_handle: '<@U-ben>',- week: '2026-W23',- source: 'slack',- })-- // The recipient profile landed in prose memory (un-gated write).- const profile = await c.memoryStore.read(scope, 'people/u-jane.md')- expect(profile.content).toContain('unblocked the events migration')- expect(profile.frontmatter.tags).toContain('kudos')-- // The :tada: confirm reaction actually hit the Slack Web API with the- // resolved bot token (substitution fired, no leftover placeholder).- const react = slackCalls.find((s) => s.method === 'reactions.add')- expect(react).not.toBeUndefined()- expect(react!.auth).toBe('Bearer xoxb-faux')- expect(react!.body).toMatchObject({ channel: 'C-kudos', name: 'tada' })- })-- it('asks one clarifying question when the recipient is missing, then records on the in-thread reply', async () => {- const { spec, files } = await loadBundle()-- // Single script queue, consumed one entry per model call across BOTH- // turns (the faux provider walks it sequentially). Turn 1 ends on a- // natural-stop text → the session goes `completed` (open) and waits;- // the in-thread reply resumes it and the runner walks the rest.- c.setScript([- // --- Turn 1: opener has no recipient → ask, don't record. ---- fauxCallTool('@posthog/load-skill', { id: 'capturing-kudos' }),- fauxCallTool('@posthog/slack-post-message', {- channel: 'C-kudos',- thread_ts: '2000.000100',- text: '🙌 love it — who is this kudos for?',- }),- fauxText('Asked who the kudos is for; waiting for the reply in-thread.'),- // --- Turn 2: the reply names the recipient → record it. ---- fauxCallTool('@posthog/slack-read-thread', { channel: 'C-kudos', thread_ts: '2000.000100' }),- fauxCallTool('@posthog/load-skill', { id: 'kudos-storage' }),- fauxCallTool('@posthog/table-append', {- table: 'kudos',- rows: [- {- kudos_id: 'slack:C-kudos:2000.000100:<@U-jane>',- recipient_handle: '<@U-jane>',- giver_handle: '<@U-ben>',- message: 'shipping the on-call dashboard',- themes: 'shipping',- given_at: '2026-06-03T17:00:00Z',- week: '2026-W23',- source: 'slack',- permalink: '',- },- ],- dedupe_on: 'kudos_id',- }),- fauxCallTool('@posthog/memory-write', {- path: 'people/u-jane.md',- description: 'Kudos profile for <@U-jane>',- content:- '# <@U-jane>\n\n## Highlights\n\n- 2026-06-03 — shipped the on-call dashboard (from <@U-ben>) · _shipping_\n',- tags: ['person', 'kudos'],- }),- fauxCallTool('@posthog/slack-react', { channel: 'C-kudos', ts: '2000.000100', name: 'tada' }),- fauxText('Recorded — kudos to <@U-jane> for the on-call dashboard. 🎉'),- ])-- const { application } = await c.deployAgent({- slug: 'kudos-bot',- spec,- files,- encrypted_env: { SLACK_SIGNING_SECRET: SLACK_SECRET },- })- const scope = { teamId: 1, applicationId: application.id }-- // --- Turn 1: opener @mention with no recipient. ---- const opener = await c.slackPost(- 'kudos-bot',- 'events',- slackThreadEvent({- eventType: 'app_mention',- text: '<@U-bot> big kudos for shipping the on-call dashboard today!',- ts: '2000.000100',- event_id: 'Ev_clarify_open',- }),- SLACK_SECRET- )- expect(opener.status).toBe(200)- expect(opener.body.resumed).toBe(false)- const sessionId = opener.body.session_id as string- await c.drain({ iterations: 100 })-- // The bot asked instead of recording: a clarifying post went out, and- // NO kudos row exists yet. This is the behaviour that distinguishes the- // bot from a dumb form — it picks up the missing recipient.- const afterAsk = await c.queue.get(sessionId)- expect(afterAsk!.state).toBe('completed')- // Skip the runner's transient "Working on it…" status post — we want- // the agent's actual clarifying reply.- const question = slackCalls.find(- (s) => s.method === 'chat.postMessage' && !String(s.body.text ?? '').includes('Working on it')- )- expect(question).not.toBeUndefined()- expect(question!.body).toMatchObject({ channel: 'C-kudos', thread_ts: '2000.000100' })- expect(String(question!.body.text)).toContain('who is this kudos for')- expect(await c.tabularStore.count(scope, 'kudos')).toBe(0)-- // --- Turn 2: the user replies in-thread with the recipient. The reply- // is a plain `message` event (no @mention); auto_resume_threads routes- // it back into the open session. ---- const reply = await c.slackPost(- 'kudos-bot',- 'events',- slackThreadEvent({- eventType: 'message',- text: "oh — it's for <@U-jane>!",- ts: '2000.000300',- thread_ts: '2000.000100',- event_id: 'Ev_clarify_reply',- }),- SLACK_SECRET- )- expect(reply.status).toBe(200)- expect(reply.body.resumed).toBe(true)- expect(reply.body.session_id).toBe(sessionId)- await c.drain({ iterations: 100 })-- // Same session advanced; both user messages landed in the one thread.- const session = await c.queue.get(sessionId)- expect(session!.state).toBe('completed')- const userMsgs = session!.conversation.filter((m) => m.role === 'user')- expect(userMsgs.length).toBe(2)-- // The full tool order across both turns: ask → (reply) → read thread →- // record → confirm.- const calledTools = session!.conversation- .filter((m) => m.role === 'toolResult')- .map((m) => (m as { toolName?: string }).toolName)- expect(calledTools).toEqual([- '@posthog/load-skill', // capturing-kudos (turn 1)- '@posthog/slack-post-message', // the clarifying question- '@posthog/slack-read-thread', // turn 2: re-read the thread- '@posthog/load-skill', // kudos-storage- '@posthog/table-append',- '@posthog/memory-write',- '@posthog/slack-react',- ])-- // The kudos the user clarified now exists — recorded only after the- // missing recipient arrived.- const rows = await c.tabularStore.query(scope, 'kudos', { where: { recipient_handle: '<@U-jane>' } })- expect(rows).toHaveLength(1)- expect(rows[0]).toMatchObject({- recipient_handle: '<@U-jane>',- message: 'shipping the on-call dashboard',- week: '2026-W23',- })- })-- it('posts the weekly digest on the Monday cron firing, grouping last week’s kudos', async () => {- const { spec, files } = await loadBundle()-- c.setScript([- // Phase 1: the digest format + which-week logic.- fauxCallTool('@posthog/load-skill', { id: 'weekly-summary' }),- // Phase 2: pull last week's kudos (the ISO week before the firing week).- fauxCallTool('@posthog/table-query', {- table: 'kudos',- where: { week: '2026-W23' },- order_by: 'recipient_handle',- }),- // Phase 3: post the celebratory digest to the kudos channel.- fauxCallTool('@posthog/slack-post-message', {- channel: 'C-kudos',- text: ':tada: *Kudos — week of Jun 1–7* :tada:\n\n*<@U-jane>* — 2 kudos\n*<@U-raj>* — 1 kudos\n\n─────\n3 kudos this week. Keep ’em coming — @mention me.',- }),- // Phase 4: end the session; next firing is next Monday.- fauxText('Weekly digest posted.'),- ])-- const { application, revision } = await c.deployAgent({- slug: 'kudos-bot',- spec,- files,- encrypted_env: { SLACK_SIGNING_SECRET: SLACK_SECRET },- })-- // Seed last week's (2026-W23) kudos so the digest query finds rows.- const scope = { teamId: 1, applicationId: application.id }- await c.tabularStore.append(scope, 'kudos', [- {- kudos_id: 'slack:C-kudos:a:<@U-jane>',- recipient_handle: '<@U-jane>',- giver_handle: '<@U-ben>',- message: 'unblocked the migration',- week: '2026-W23',- source: 'slack',- },- {- kudos_id: 'slack:C-kudos:b:<@U-jane>',- recipient_handle: '<@U-jane>',- giver_handle: '<@U-raj>',- message: 'thorough PR review',- week: '2026-W23',- source: 'slack',- },- {- kudos_id: 'slack:C-kudos:c:<@U-raj>',- recipient_handle: '<@U-raj>',- giver_handle: '<@U-jane>',- message: 'paired on the flaky test',- week: '2026-W23',- source: 'slack',- },- ])-- // Fire the cron tick — the janitor's setInterval does this in prod.- // The schedule is `0 9 * * 1` (Monday 09:00) in America/Los_Angeles;- // 2026-06-08 is a Monday and 09:00 PDT = 16:00 UTC. Window is- // (lastTickAt, now], so t0 must land strictly before the firing.- const state = newCronTickState()- const deps = { revisions: c.revisions, queue: c.queue, encryption: c.encryption }- const t0 = new Date('2026-06-08T15:59:00Z') // 08:59 PT — seeds the window- await cronTick({ ...deps, now: () => t0 }, state)- const t1 = new Date('2026-06-08T16:01:00Z') // window (15:59, 16:01] catches 16:00- const r1 = await cronTick({ ...deps, now: () => t1 }, state)- expect(r1.fired).toBe(1)- expect(r1.errors).toBe(0)-- await c.drain({ iterations: 100 })-- const minute = Math.floor(new Date('2026-06-08T16:00:00Z').getTime() / 60_000)- const session = await c.queue.findByIdempotencyKey(- application.id,- `cron:${revision.id}:weekly-kudos-summary:${minute}`- )- expect(session).not.toBeNull()- expect(session!.state).toBe('completed')- expect(session!.trigger_metadata).toMatchObject({- kind: 'cron',- cron_name: 'weekly-kudos-summary',- })-- const calledTools = session!.conversation- .filter((m) => m.role === 'toolResult')- .map((m) => (m as { toolName?: string }).toolName)- expect(calledTools).toEqual(['@posthog/load-skill', '@posthog/table-query', '@posthog/slack-post-message'])-- // The digest actually went out to the kudos channel via the native- // slack tool (token substitution + Slack Web API call fired).- const posts = slackCalls.filter((s) => s.method === 'chat.postMessage')- expect(posts).toHaveLength(1)- expect(posts[0].auth).toBe('Bearer xoxb-faux')- expect(posts[0].body.channel).toBe('C-kudos')- expect(String(posts[0].body.text)).toContain('Kudos — week of')- })-})diff --git a/products/agent_platform/services/agent-tests/src/cases/example-posthog-ai.test.ts b/products/agent_platform/services/agent-tests/src/cases/example-posthog-ai.test.tsdeleted file mode 100644index dc89cf1a4c93..000000000000--- a/products/agent_platform/services/agent-tests/src/cases/example-posthog-ai.test.ts+++ /dev/null@@ -1,78 +0,0 @@-/**- * Example bundle wiring check — `services/agent-tests/src/examples/posthog-ai/`.- *- * PostHog AI answers questions via the PostHog MCP, acting as the asking user.- * The contract this pins: a Slack trigger that ISN'T a shared thread (so the- * asker's identity resolves), one MCP entry authed by the `posthog` identity- * provider, and a declared posthog identity provider for the link flow. Drift- * in any of those silently breaks "act as the user," so catch it here.- *- * Faux net — wiring, not inference quality.- */--import { readFile } from 'node:fs/promises'-import { dirname, join, resolve } from 'node:path'-import { fileURLToPath } from 'node:url'--import { AgentSpecSchema } from '@posthog/agent-shared'--const __dirname = dirname(fileURLToPath(import.meta.url))-const BUNDLE_ROOT = resolve(__dirname, '../examples/posthog-ai')--async function loadBundle(): Promise<{ spec: Record<string, unknown>; agentMd: string }> {- const spec = JSON.parse(await readFile(join(BUNDLE_ROOT, 'spec.json'), 'utf-8')) as Record<string, unknown>- const agentMd = await readFile(join(BUNDLE_ROOT, 'agent.md'), 'utf-8')- return { spec, agentMd }-}--describe('example: posthog-ai bundle', () => {- it('parses through AgentSpecSchema — the runner accepts it as-is', async () => {- const { spec } = await loadBundle()- expect(() => AgentSpecSchema.parse(spec)).not.toThrow()- })-- it('agent.md is present and non-trivial', async () => {- const { agentMd } = await loadBundle()- expect(agentMd.length).toBeGreaterThan(400)- })-- it('is Slack-triggered and owner-only (so the asker identity resolves, not a shared thread)', async () => {- const { spec } = await loadBundle()- const parsed = AgentSpecSchema.parse(spec)- const slack = parsed.triggers.find((t) => t.type === 'slack')- expect(slack).not.toBeUndefined()- // Shared participant threads fail closed in the identity model — a Q&A- // bot acting as the asker MUST be owner-only.- expect(slack?.type === 'slack' && slack.config.allow_workspace_participants).toBe(false)- })-- it('answers via one PostHog MCP authed by the posthog identity provider (no native tools)', async () => {- const { spec } = await loadBundle()- const parsed = AgentSpecSchema.parse(spec)- expect(parsed.tools).toHaveLength(0)- expect(parsed.mcps).toHaveLength(1)- expect(parsed.mcps[0].auth?.provider).toBe('posthog')- })-- it('declares a posthog identity provider with explicit read scopes for the link flow', async () => {- const { spec } = await loadBundle()- const parsed = AgentSpecSchema.parse(spec)- const posthog = parsed.identity_providers.find((p) => p.kind === 'posthog')- expect(posthog).not.toBeUndefined()- // Real scope objects, never the `*` wildcard — OAuth /authorize rejects- // `*` (it's a PAT/first-party concept, not an OAuth-grantable scope).- expect(posthog?.scopes).toContain('query:read')- expect(posthog?.scopes).not.toContain('*')- // principal binding (default) — per-asker, not a shared agent credential.- expect(posthog?.binding).toBe('principal')- })-- it('runs on an OpenAI model the local gateway supports', async () => {- const { spec } = await loadBundle()- expect(AgentSpecSchema.parse(spec).models).toEqual({- mode: 'manual',- models: [{ model: 'openai/gpt-5.5' }],- optimize_for: 'cost',- })- })-})diff --git a/products/agent_platform/services/agent-tests/src/examples/README.md b/products/agent_platform/services/agent-tests/src/examples/README.mdindex e5346e2c34cc..bcc87311a046 100644--- a/products/agent_platform/services/agent-tests/src/examples/README.md+++ b/products/agent_platform/services/agent-tests/src/examples/README.md@@ -17,7 +17,6 @@ walks through the deploy steps. But the source of truth for| ---------------------------------------------- | ---------------------------------------------------------------------------------------------- | ------ || [`sre-slack-bot/`](sre-slack-bot/) | [`../cases/example-sre-bot.test.ts`](../cases/example-sre-bot.test.ts) | infant || [`wake-me-up/`](wake-me-up/) | [`../cases/example-wake-me-up.test.ts`](../cases/example-wake-me-up.test.ts) | infant |-| [`kudos-bot/`](kudos-bot/) | [`../cases/example-kudos-bot.test.ts`](../cases/example-kudos-bot.test.ts) | infant || [`agent-approval-demo/`](agent-approval-demo/) | [`../cases/example-agent-approval-demo.test.ts`](../cases/example-agent-approval-demo.test.ts) | ready |"Infant" = buildable today against shipped primitives, butdiff --git a/products/agent_platform/services/agent-tests/src/examples/kudos-bot/README.md b/products/agent_platform/services/agent-tests/src/examples/kudos-bot/README.mddeleted file mode 100644index 9fd6e397c325..000000000000--- a/products/agent_platform/services/agent-tests/src/examples/kudos-bot/README.md+++ /dev/null@@ -1,197 +0,0 @@-# Kudos bot — peer-recognition collector + weekly digest--First-iteration ("infant") recognition bot.-People `@mention` it in Slack (or DM it, or chat from the console)-with "kudos to @jane for …"; it records each one, asks a single-clarifying question when the message is too thin, and every Monday-posts a celebratory digest of the week's kudos to a shared channel.--## Status--**Infant.** Buildable today on shipped primitives — Slack mention-trigger, cron trigger, the tabular + prose memory stores, the native-Slack tools. Capture is intentionally **mention- / chat-driven**:-people `@mention` the bot, DM it, or chat from the console. No value-loop is blocked; the items in [Gaps](#gaps-that-constrain-this-version)-are enhancements, not duct-tape.--## What it does--| Capability | How |-| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------- |-| Capture a kudos from a Slack `@mention` | `slack` trigger, `mention_only: true` + `auto_resume_threads: true` |-| Ask one clarifying question, then record | `auto_resume_threads` keeps the back-and-forth in one session; `skills/capturing-kudos` |-| Capture a kudos from the console | `chat` trigger |-| **Post a weekly digest every Monday** | `cron` trigger (`0 9 * * 1`, PT) → `@posthog/slack-post-message`; `skills/weekly-summary` |-| Store kudos as deterministic rows | `@posthog/table-append` / `-query` / `-count` on the `kudos` table, deduped on `kudos_id` |-| Build a per-person highlight reel | `@posthog/memory-write` / `-update` / `-read` / `-search` over `people/<handle>.md` |-| Acknowledge in Slack | `ack_reaction: raised_hands` (ingress, instant) + `@posthog/slack-react` `:tada:` (the "recorded" confirm) |-| Answer "what did @jane get?" | `@posthog/table-query` by `recipient_handle` + the person's profile memory |-| Follows a consistent capture flow | `skills/capturing-kudos/SKILL.md` |-| Follows a consistent storage schema | `skills/kudos-storage/SKILL.md` |-| Follows a consistent digest format | `skills/weekly-summary/SKILL.md` |--## Identity model — just the handle--The bot stores the **literal Slack handle** for both giver and-recipient and does no identity resolution: no email lookup, no-PostHog-person matching, no fuzzy dedupe of "Jane" vs "@jane". A-handle is the key. This is a deliberate v0 simplification — see-[Gaps](#gaps-that-constrain-this-version) for what stable identity-would buy.--## What it cannot do--- **Capture passively.** By design it only acts when `@mention`ed,- DM'd, or chatted — a "great work @jane!" said in a channel without- naming the bot is not picked up. This is the intended, affordable- default (one session per addressed message, not per channel message).-- Resolve a handle to a person, dedupe display-name changes, or work- across workspaces.-- Hand out rewards / points / gift cards. It records and celebrates;- it doesn't transact.--## Bundle layout--```text-kudos-bot/-├── README.md # this file-├── spec.json # AgentSpec — triggers, tools, skills, limits-├── agent.md # system prompt-└── skills/- ├── capturing-kudos/SKILL.md # how to read a kudos + when to ask- ├── kudos-storage/SKILL.md # the table + profile schema, dedupe key- └── weekly-summary/SKILL.md # the Monday digest format-```--## Data model--`kudos` table (one row per recipient per kudos; `dedupe_on: kudos_id`):--| Column | Type | Notes |-| ------------------ | ------ | ---------------------------------------------------------------- |-| `kudos_id` | string | Dedupe key, `slack:<channel>:<ts>:<recipient>` / `chat:<sid>:…`. |-| `recipient_handle` | string | Verbatim handle. |-| `giver_handle` | string | Verbatim handle. |-| `message` | string | The praise. |-| `themes` | string | Comma-separated tags, optional. |-| `given_at` | string | ISO timestamp (from the message, not "now"). |-| `week` | string | ISO week — the weekly digest filters on this. |-| `source` | string | `slack` / `chat`. |-| `permalink` | string | Slack link, optional. |--`people/<handle>.md` memory — a rolling highlight reel per recipient.-Writes here are **not** approval-gated (low-stakes, high-volume — the-opposite call from the SRE bot's runbook corpus).--## Prerequisites for deploying--1. **Your own Slack app** registered at api.slack.com. Two values:- - `SLACK_BOT_TOKEN` (`xoxb-…`) — used by the native `@posthog/slack-*`- tools to call the Slack Web API.- - `SLACK_SIGNING_SECRET` — verifies inbound event payloads for the- `slack` trigger.- - Scopes: `app_mentions:read`, `chat:write`, `reactions:write`,- `channels:history`, `groups:history`, plus `im:history` /- `im:read` if you want DM capture. Subscribe to `app_mention` and- (for thread follow-ups) `message.channels` / `message.im`. The- bot user must be a member of every channel it should hear.-2. **`spec.triggers[].slack.trusted_workspaces`** — replace the- placeholder `T0XXXXXXX` with your Slack team id.-3. **A kudos channel.** The weekly digest posts to whichever channel- you tell the bot about (today: bake it into the cron prompt or the- agent.md). The bot must be a member of it.-4. **PostHog access** for the platform itself (PAT) — the `chat`- trigger and console use the connected user's principal.--> **`ack_reaction` caveat.** The instant `:raised_hands:` ack the-> ingress adds the moment a mention lands resolves the bot token via-> the agent's Slack **integration**, not the `SLACK_BOT_TOKEN` secret-> the native tools use. Until a Slack integration row exists it logs-> `ack_reaction_no_bot_token` and skips the reaction (fire-and-forget,-> harmless). The model's own `:tada:` confirm — which goes through-> `@posthog/slack-react` + `SLACK_BOT_TOKEN` — is unaffected. Drop-> `ack_reaction` from the spec if you don't want the instant ack.--Set the two secrets via the [agent-builder](../agent-builder/)-`set_secret` punch-out so the values never transit the model's-tool-call history. The flow is the same as the-[sre-slack-bot](../sre-slack-bot/README.md#agent-builder-walkthrough--recommended-setup-flow);-swap the secret list for `SLACK_BOT_TOKEN` + `SLACK_SIGNING_SECRET`.--## A note on auth--Auth is per-trigger. The `slack` and `cron` triggers are intrinsic —-the `slack` trigger verifies inbound events with `SLACK_SIGNING_SECRET`-and carries no `auth` block; cron fires internally. The `chat` trigger-declares `auth.modes: [{ type: "posthog_internal" }, { type: "pat" }]`-— closed by default, so the console path uses a PostHog PAT. No-`public` exposure is needed — the bot only ever receives signed Slack-events or authenticated console traffic.--## Deploying--Through the authoring MCP (preferred) or the janitor REST API —-identical to the [sre-slack-bot deploy steps](../sre-slack-bot/README.md#deploying),-substituting `slug=kudos-bot`.--## Regression test--[`services/agent-tests/src/cases/example-kudos-bot.test.ts`](../../cases/example-kudos-bot.test.ts)-loads this bundle from disk, deploys it through the e2e harness, and-drives both flows with the faux model: a Slack-mention capture-(`@mention` → react → append row → write profile) and the Monday cron-digest (`cronTick` → query last week → post). Run with:--```bash-pnpm --filter @posthog/agent-tests test cases/example-kudos-bot-```--## Gaps that constrain this version--None block the bundle — each is an enhancement.--- **Reaction-as-trigger.** The most natural kudos UX is reacting to a- message with `:clap:` / `:trophy:`. Slack delivers `reaction_added`- events, but the `slack` trigger only routes `message` / `app_mention`- today. A `reaction_added` trigger variant (with an emoji allowlist)- would let people give kudos with one click — no typing, no mention.-- **Optional passive capture.** If a team ever wanted the bot to catch- kudos said in a channel without naming it, that needs- `mention_only: false` + `message.channels`, which today spins up a- **session per message**. An ingress-level content pre-filter (fire- only on messages matching `kudos` / `:clap:` / a regex) would make- that affordable. Not needed for this bundle — `mention_only: true`- is the right default — but it's the primitive a passive variant- would want.-- **Stable identity / a people directory.** Storing raw handles works- but is brittle: a display-name change splits a person's history, and- there's no cross-workspace identity. The existing **per-principal /- per-user memory scope** gap (`MemoryStore` keys on- `(team, application)` only — see `_APP_IDEAS.md` cross-cutting- status) is the same shortfall viewed from the storage side. v0- accepts the handle as the key; a directory primitive would make- aggregation reliable.-- **A first-class agent-config surface for the target channel.** The- digest channel is hard-coded into the prompt today — the same- "user-maintained config in memory" nice-to-have flagged on the- [wake-me-up](../wake-me-up/) bundle. A small console panel- (channel, schedule, emoji allowlist) would lift this to fully wired.-- **Native Slack `chat.getPermalink`.** To store a `permalink` back to- the original kudos message the bot would call `chat.getPermalink`;- there's no native wrapper, so v0 leaves `permalink` empty or- reaches for `@posthog/http-request`. Cosmetic.--## Tuning notes--- `reasoning: medium` — kudos parsing is light; the only judgement is- "is this a kudos and what's missing." Drop to `low` if cost matters;- bump to `high` only if you add richer theme inference.-- `resume.enabled: true` with a 7-day TTL keeps a capture thread open- so "oh, also for the docs" resumes cleanly. Without it the platform- would close the thread at the 24h default and a late addition would- start a fresh, context-less session.-- `mention_only: true` is the right default — the bot acts only when- addressed. Flipping it to `false` (passive capture) would wake the- agent on every channel message; don't, unless the content pre-filter- in [Gaps](#gaps-that-constrain-this-version) lands first.diff --git a/products/agent_platform/services/agent-tests/src/examples/kudos-bot/agent.md b/products/agent_platform/services/agent-tests/src/examples/kudos-bot/agent.mddeleted file mode 100644index 977860b8c84d..000000000000--- a/products/agent_platform/services/agent-tests/src/examples/kudos-bot/agent.md+++ /dev/null@@ -1,110 +0,0 @@-# Kudos bot--You collect **kudos** — small notes of appreciation one person sends-another — and once a week you celebrate them publicly. Your whole job-is to make giving recognition frictionless and to make sure it doesn't-get lost. Two halves:--1. **Capture.** Someone tells you "kudos to @jane for unblocking the- migration" and you record it. If they left out who it's for or- what it's for, you ask — once, in-thread — and then record it.-2. **Celebrate.** Every Monday morning you post a digest of the past- week's kudos to a shared Slack channel.--You receive sessions in three shapes:--1. **Slack `@mention`.** The default capture path. Someone mentions- you in a channel or DMs you a kudos. The session resumes on every- later message in that thread (`auto_resume_threads`), so a- clarifying back-and-forth all lands in one session.-2. **Weekly cron firing.** A `cron` trigger fires Monday at 09:00 PT- with the summary prompt. This is the celebrate half.-3. **Chat from the console.** Ad-hoc — either someone giving a kudos- or asking "what kudos did @jane get this quarter?". No Slack- thread context.--## Identity is just the handle--You do **not** resolve people to real identities. Store the literal-Slack handle exactly as written — `@jane`, `@ben.white`, or the-`<@U0123>` mention form Slack delivers. Both the **giver** and the-**recipient** are stored as handles. Don't guess email addresses,-don't dedupe "Jane" against "@jane", don't reach for PostHog person-data. A handle is the key. (See [Gaps](README.md) — stable identity-is a known limitation, deliberately out of scope for v0.)--## The capture loop--When a mention or chat arrives that looks like a kudos:--1. **Load `capturing-kudos`.** It tells you how to pull the recipient- handle(s), the praise, and any themes, and — crucially — when the- message is too thin to record (no recipient, or no actual praise).-2. **If something's missing, ask once.** Reply in-thread with a- single, specific question ("Who's this for?" / "Nice — what did- they do?"). Then stop and wait; the next message resumes this- session. Don't interrogate; one round of clarification is the cap.-3. **Load `kudos-storage`.** It pins the `kudos` table columns and the- `kudos_id` dedupe key so you never double-record the same message.-4. **Append the kudos row.** `@posthog/table-append` to `kudos`,- `dedupe_on: kudos_id`. One row per (recipient, message) — a kudos- to two people is two rows sharing nothing but the praise text.-5. **Update the recipient's profile.** `@posthog/memory-write` (or- `-update` if it exists) to `people/<handle>.md` — a short rolling- highlight reel per person. This is what powers "what has @jane been- recognised for?" without scanning the whole table.-6. **Acknowledge.** React with `:tada:` (or reply in-thread for a- chat session) so the giver knows it landed. The ingress already- added a `:raised_hands:` ack reaction the moment the mention- arrived; your `:tada:` is the "recorded" confirmation.-7. **Don't end the session.** Leave it open so a follow-up ("oh, also- for the docs") resumes the same thread. The platform closes idle- threads on its own.--If the message clearly isn't a kudos (someone @mentioned you to ask a-question, or it's chatter in a thread you're watching), say so briefly-and don't write anything.--## The weekly summary loop--When the cron fires (or someone asks for a summary):--1. **Load `weekly-summary`.** It carries the digest format and the- "quiet week" fallback.-2. **Query last week.** `@posthog/table-query` on `kudos` filtered to- the relevant `week` value. On the Monday firing that's the ISO week- _before_ the firing week — compute it from the prompt. Group by- `recipient_handle`.-3. **Post the digest.** `@posthog/slack-post-message` to the kudos- channel. Celebratory, scannable, every recipient called out by- handle with what they were recognised for. On a quiet week post a- short nudge instead of an empty digest.-4. **End the session.** The next firing is next Monday.--## Tools you have--| Tool | Use when |-| ----------------------------- | ---------------------------------------------------------------------------------- |-| `@posthog/slack-read-thread` | Pull the full thread when a kudos spans several messages or you asked a follow-up. |-| `@posthog/slack-read-channel` | Rarely — to grab surrounding context if a kudos references "that thing above". |-| `@posthog/slack-post-message` | Post a clarifying question, the weekly digest, or a chat-session reply. |-| `@posthog/slack-react` | `:tada:` to confirm a kudos was recorded. |-| `@posthog/table-append` | Record a kudos row (dedupe on `kudos_id`). |-| `@posthog/table-query` | Pull kudos for the weekly digest, or for a "what did @jane get?" lookup. |-| `@posthog/table-count` | Cheap counts — "how many kudos last week", leaderboard tallies. |-| `@posthog/memory-search` | Find a recipient's profile by handle or theme. |-| `@posthog/memory-read` | Read one `people/<handle>.md` profile in full. |-| `@posthog/memory-write` | Create a recipient's profile the first time they're recognised. |-| `@posthog/memory-update` | Append a highlight to an existing profile. |--## Style--- **Warm, never corporate.** "🎉 @jane unblocked the migration —- saved the whole team a day" not "Recognition logged for stakeholder- Jane."-- **Always name the handle and the what.** A kudos with no "what"- isn't worth recording; that's why you ask.-- **One clarifying question, max.** Friction kills the habit. If after- one question it's still vague, record what you have and move on.-- **The Slack post is the product.** The table and profiles are- plumbing; the Monday digest is the thing people read. Make it land.diff --git a/products/agent_platform/services/agent-tests/src/examples/kudos-bot/skills/capturing-kudos/SKILL.md b/products/agent_platform/services/agent-tests/src/examples/kudos-bot/skills/capturing-kudos/SKILL.mddeleted file mode 100644index 55ab6a211275..000000000000--- a/products/agent_platform/services/agent-tests/src/examples/kudos-bot/skills/capturing-kudos/SKILL.md+++ /dev/null@@ -1,58 +0,0 @@-----description: How to read a kudos out of a message — pull the recipient handle(s), the praise, and themes; decide when to ask ONE clarifying question vs record straight away. Load at the start of every capture.------# Capturing a kudos--A kudos has exactly two things that matter: **who it's for** and-**what they did**. Everything else (themes, the giver, the link) is-metadata you can derive. Your job here is to extract those two things,-or notice that one is missing and ask for it.--## Pull these fields--| Field | From |-| ------------------ | ------------------------------------------------------------------------------------------------- |-| `recipient_handle` | The `@handle` / `<@U…>` the praise is aimed at. **Required.** |-| `message` | The praise itself, cleaned of the @bot mention and filler. Required. |-| `giver_handle` | Who sent the message — `user:` in the `[slack]` envelope, or the chat principal. |-| `themes` | 0–3 lowercase tags you infer (`teamwork`, `shipping`, `mentoring`, `above-and-beyond`). Optional. |--Store handles **verbatim** — don't normalise `<@U0123>` to a name,-don't strip a `.` out of `@ben.white`. The handle is the key.--## Multiple recipients--"kudos to @jane and @raj for the launch" → **two rows**, same praise-text, one per recipient. They share nothing in the store but the-`message`; each gets its own `kudos_id` (see `kudos-storage`).--## When to ask vs record--Ask **one** clarifying question, in-thread, only when a required field-is genuinely missing:--- **No recipient** ("big kudos for today's deploy!") → "Nice — who's- this for?"-- **No praise** ("kudos to @jane") → "Love it — what did @jane do?"--Then **stop and wait**. The thread resumes this session when they-reply. Do not stack questions, and do not ask about optional fields-(themes, links) — infer or skip those.--Record straight away (no question) when both required fields are-present, even if terse. "kudos @raj solid review" is recordable:-recipient `@raj`, message "solid review".--## What is NOT a kudos--Don't write a row for:--- A question to the bot ("@kudos-bot how many did I give?").-- General thread chatter where you were auto-resumed but not- addressed (the seed message is flagged `mention: false`).-- A request to retract or edit — handle that explicitly, don't append.--When in doubt and it reads like appreciation, lean toward capturing —-a missing-recipient question is cheap; a lost kudos is the failure-mode this bot exists to prevent.diff --git a/products/agent_platform/services/agent-tests/src/examples/kudos-bot/skills/kudos-storage/SKILL.md b/products/agent_platform/services/agent-tests/src/examples/kudos-bot/skills/kudos-storage/SKILL.mddeleted file mode 100644index de4f93f30e9f..000000000000--- a/products/agent_platform/services/agent-tests/src/examples/kudos-bot/skills/kudos-storage/SKILL.md+++ /dev/null@@ -1,75 +0,0 @@-----description: The data model — the `kudos` table columns, the `kudos_id` dedupe/idempotency scheme, and the per-recipient `people/<handle>.md` profile memory. Load before any table-append or memory-write.------# Kudos storage--Two stores, two jobs:--- **`kudos` table** (`@posthog/table-*`) — the deterministic record.- One row per (recipient, kudos). This is what the weekly digest- queries. Never enters your context wholesale.-- **`people/<handle>.md` memory** (`@posthog/memory-*`) — a per-person- highlight reel. Free-form prose, accretes over time. This is what- answers "what has @jane been recognised for?" without scanning the- table.--## The `kudos` table--| Column | Type | Notes |-| ------------------ | ------ | ------------------------------------------------------------------------------- |-| `kudos_id` | string | **Dedupe key.** See scheme below. Always `dedupe_on: kudos_id`. |-| `recipient_handle` | string | Verbatim handle, e.g. `@jane` or `<@U0123>`. |-| `giver_handle` | string | Verbatim handle of the sender. |-| `message` | string | The praise, cleaned. |-| `themes` | string | Comma-separated tags, e.g. `teamwork,shipping`. Empty string if none. |-| `given_at` | string | ISO 8601 timestamp. |-| `week` | string | ISO week of `given_at`, e.g. `2026-W23`. **The weekly digest filters on this.** |-| `source` | string | `slack` or `chat`. |-| `permalink` | string | Slack message link if you have one, else empty string. |--### The `kudos_id` scheme — idempotency--Slack retries event deliveries; a thread can resume and re-process.-A stable `kudos_id` + `dedupe_on: kudos_id` makes re-recording a no-op.--- **Slack:** `slack:<channel>:<ts>:<recipient_handle>` — the message- `ts` from the `[slack]` envelope, suffixed with the recipient so a- two-person kudos in one message yields two distinct ids.-- **Chat:** `chat:<session_id>:<recipient_handle>` — plus a short- suffix (`#2`) if the same session records several kudos.--`given_at` and `week` come from the message timestamp, not "now" — a-kudos captured Monday for something said Friday belongs to Friday's-week. For Slack, derive both from the message `ts`.--## The `people/<handle>.md` profile--Path: `people/<handle>.md` where `<handle>` is the recipient handle-lowercased with the leading `@` dropped and `<@U…>` kept as-is but-lowercased (`people/jane.md`, `people/u0123.md`). Keep it stable so a-person maps to exactly one file.--First kudos for a person → `memory-write` to create it:--```markdown-----description: Kudos profile for @jane-tags: [person, kudos]------# @jane--## Highlights--- 2026-06-03 — unblocked the events migration, saved the team a day (from @ben) · _teamwork, above-and-beyond_-```--Later kudos → `memory-read` then `memory-update`, appending one bullet-under `## Highlights`. Keep the newest at the top, cap at ~20 bullets-(trim the oldest); this file is a highlight reel, not an audit log —-the `kudos` table is the complete record.--Writes here are **not** approval-gated (unlike the SRE bot's runbook-corpus) — kudos are low-stakes and high-volume, and a human-in-the-loop-on every "@jane is great" would kill the habit.diff --git a/products/agent_platform/services/agent-tests/src/examples/kudos-bot/skills/weekly-summary/SKILL.md b/products/agent_platform/services/agent-tests/src/examples/kudos-bot/skills/weekly-summary/SKILL.mddeleted file mode 100644index 29d7f7c5084e..000000000000--- a/products/agent_platform/services/agent-tests/src/examples/kudos-bot/skills/weekly-summary/SKILL.md+++ /dev/null@@ -1,74 +0,0 @@-----description: The Monday digest — how to query last week's kudos, group by recipient, format the celebratory mrkdwn post, and what to do on a quiet week. Load when the weekly cron fires or someone asks for a summary.------# Weekly kudos summary--The Monday digest is the product. The table and profiles exist to make-this post good. Keep it warm, scannable, and complete — every kudos-from the week shows up, every recipient is named.--## Which week--The cron fires Monday 09:00 PT. "Last week" is the ISO week **before**-the firing week. The prompt gives you `{fired_at:week}` (the current-week); subtract one to get the target `week` value. E.g. fired in-`2026-W24` → query `week = 2026-W23`.--On-demand ("summarise this month") — widen the filter accordingly-(`week` with an `in: [...]` set, or `given_at` with a `gte`).--## Query--```text-@posthog/table-query- table: kudos- where: { week: "2026-W23" }- order_by: recipient_handle-```--Then group the rows by `recipient_handle` in your head. Use-`@posthog/table-count` if you just want a headline number.--## Format--mrkdwn (Slack flavour — `*bold*`, `_italics_`, `•` bullets). Aim for-scannable: a header, one block per recipient, a light footer.--```text-:tada: *Kudos — week of Jun 1–5* :tada:--*@jane* — 2 kudos- • unblocked the events migration, saved the team a day _(@ben)_- • thorough PR review on the billing refactor _(@raj)_--*@raj* — 1 kudos- • paired for two hours to debug the flaky test _(@jane)_--─────-12 kudos from 8 people this week. Keep 'em coming — just @mention me.-```--Rules:--- **Every recipient, every kudos.** Don't summarise or drop. People- notice when their shout-out is missing.-- **Attribute the giver** in `_italics_` — recognition is a two-way- signal.-- **Lead with the busiest recipients** (most kudos first) so the post- has shape, but never omit the long tail.-- **Footer = a number + a nudge.** The count is social proof; the- nudge ("@mention me to add one") is how the habit spreads.--## Quiet week--If the query returns zero rows, do **not** post an empty digest. Post-a short nudge instead:--```text-:wave: Quiet week for kudos — nobody got a shout-out. If a teammate-helped you out last week, @mention me with a quick "kudos to @them-for …" and I'll make sure it's celebrated next Monday.-```--One nudge, not a guilt trip. Then end the session.diff --git a/products/agent_platform/services/agent-tests/src/examples/kudos-bot/spec.json b/products/agent_platform/services/agent-tests/src/examples/kudos-bot/spec.jsondeleted file mode 100644index 7b65de96b45f..000000000000--- a/products/agent_platform/services/agent-tests/src/examples/kudos-bot/spec.json+++ /dev/null@@ -1,73 +0,0 @@-{- "models": { "mode": "manual", "models": [{ "model": "anthropic/claude-sonnet-4-6" }] },- "reasoning": "medium",- "triggers": [- {- "type": "slack",- "config": {- "mention_only": true,- "auto_resume_threads": true,- "ack_reaction": "raised_hands",- "allow_direct_messages": true,- "trusted_workspaces": ["T0XXXXXXX"]- }- },- {- "type": "cron",- "config": {- "name": "weekly-kudos-summary",- "schedule": "0 9 * * 1",- "timezone": "America/Los_Angeles",- "prompt": "Post the weekly kudos summary for the week that just ended (the ISO week BEFORE {fired_at:week}). Query the `kudos` table for that week, group by recipient, and post a single celebratory digest to the configured kudos channel. If nobody gave any kudos last week, post a short nudge instead of an empty digest.",- "external_key": "weekly-kudos:{fired_at:week}",- "catch_up": "most_recent",- "max_catch_up_age_seconds": 7200- }- },- {- "type": "chat",- "config": {},- "auth": { "modes": [{ "type": "posthog" }, { "type": "posthog_internal" }] }- }- ],- "tools": [- { "kind": "native", "id": "@posthog/slack-post-message" },- { "kind": "native", "id": "@posthog/slack-read-thread" },- { "kind": "native", "id": "@posthog/slack-read-channel" },- { "kind": "native", "id": "@posthog/slack-react" },- { "kind": "native", "id": "@posthog/table-append" },- { "kind": "native", "id": "@posthog/table-query" },- { "kind": "native", "id": "@posthog/table-count" },- { "kind": "native", "id": "@posthog/memory-search" },- { "kind": "native", "id": "@posthog/memory-read" },- { "kind": "native", "id": "@posthog/memory-write" },- { "kind": "native", "id": "@posthog/memory-update" }- ],- "secrets": ["SLACK_BOT_TOKEN", "SLACK_SIGNING_SECRET"],- "skills": [- {- "id": "capturing-kudos",- "path": "skills/capturing-kudos/SKILL.md",- "description": "How to read a kudos out of a message — pull the recipient handle(s), the praise, and any themes; decide when info is missing and ask ONE clarifying question in-thread vs record straight away. Load at the START of every capture (Slack mention or chat), before you touch the store."- },- {- "id": "kudos-storage",- "path": "skills/kudos-storage/SKILL.md",- "description": "The data model — the `kudos` table columns, the `kudos_id` dedupe/idempotency scheme, and the per-recipient `people/<handle>.md` profile memory. Load before any table-append / memory-write so the row shape and dedupe key stay consistent."- },- {- "id": "weekly-summary",- "path": "skills/weekly-summary/SKILL.md",- "description": "The Monday digest — how to query last week's kudos, group by recipient, format the celebratory mrkdwn post, and what to do on a quiet week. Load when the weekly cron fires (or when someone asks for a summary on demand)."- }- ],- "limits": {- "max_turns": 20,- "max_tool_calls": 60,- "max_wall_seconds": 300- },- "resume": {- "enabled": true,- "max_completed_age_ms": 604800000- }-}diff --git a/products/agent_platform/services/agent-tests/src/examples/mcp-shared-vs-per-asker/agent.md b/products/agent_platform/services/agent-tests/src/examples/mcp-shared-vs-per-asker/agent.mddeleted file mode 100644index 5de22b5d4f66..000000000000--- a/products/agent_platform/services/agent-tests/src/examples/mcp-shared-vs-per-asker/agent.md+++ /dev/null@@ -1,49 +0,0 @@-# MCP auth demo — shared connection vs per-asker identity--This agent exists to show the **two ways an agent reaches an MCP server**, side-by side. Open it in the agent config UI: each entry under `mcps[]` renders-differently and the descriptions spell out how each is set up.--## 1. Agent-level — one shared connection (`mcps[].connection`)--`incident` is an **agent-level** MCP. The agent owner connects the server-**once** (OAuth incl. dynamic client registration, or an API key) and stores it-as a native MCP connection; **every asker of this agent reuses that one-credential** and never signs in themselves.--- **Set it up:** in the agent config, open the `incident` MCP → pick (or- "Connect new") a connection. The shipped spec points at a placeholder- connection id, so a fresh project shows _"Referenced connection isn't in this- project — reconnect it or pick another"_. Connect incident.io once and select- it; from then on it's shared.-- **Tool permissions** are set per agent, right here: a connection-wide default- (`default_tool_approval`, here `approve` = ask before every call) plus- per-tool overrides (allow / approve / deny). The runner loads the shared- bearer from the connection row and applies these.-- **Use it when:** the agent should act as _one team identity_ (a service- account), not as the individual asking.--## 2. Principal-level — per-asker identity (`mcps[].auth.provider`)--`posthog` is a **principal-level** MCP. It references an entry in-`identity_providers[]` (here a `posthog` OAuth provider). There is **no shared-credential** — instead, **each asker authenticates as themselves** the first-time they hit a tool that needs it (an auth-required link is surfaced; they-complete the OAuth and the agent then acts _as that user_).--- **Set it up:** declare the provider in `identity_providers[]` and point the- MCP's `auth.provider` at it. Askers link their own account on first use;- nobody pre-connects anything.-- **Use it when:** the agent must act _as the person asking_ (their data, their- permissions) — e.g. querying PostHog as the requesting user.--## TL;DR--| | Agent-level (`connection`) | Principal-level (`auth.provider`) |-| ----------- | ------------------------------------------ | --------------------------------------------- |-| Credential | one shared, owner connects once | per-asker, each links their own |-| Acts as | a team/service identity | the individual asking |-| Setup | owner picks a connection in the UI | declare a provider; askers OAuth on first use |-| Tool gating | `default_tool_approval` + per-tool `level` | (per the tool's own approval) |--Keep replies short; this agent is a reference, not a worker.diff --git a/products/agent_platform/services/agent-tests/src/examples/mcp-shared-vs-per-asker/spec.json b/products/agent_platform/services/agent-tests/src/examples/mcp-shared-vs-per-asker/spec.jsondeleted file mode 100644index e82b23edc5b4..000000000000--- a/products/agent_platform/services/agent-tests/src/examples/mcp-shared-vs-per-asker/spec.json+++ /dev/null@@ -1,29 +0,0 @@-{- "models": { "mode": "manual", "models": [{ "model": "anthropic/claude-sonnet-4-6" }] },- "reasoning": "low",- "triggers": [- {- "type": "chat",- "config": {},- "auth": { "modes": [{ "type": "posthog", "scopes": ["agents:read"] }] }- }- ],- "mcps": [- {- "kind": "agent",- "id": "incident",- "url": "https://mcp.incident.io/mcp",- "connection": "00000000-0000-0000-0000-000000000000",- "default_tool_approval": "approve"- },- {- "kind": "principal",- "id": "posthog",- "url": "http://localhost:8787/mcp",- "default_tool_approval": "allow",- "auth": { "provider": "posthog" }- }- ],- "identity_providers": [{ "kind": "posthog", "scopes": ["openid", "profile", "email", "user:read"] }],- "limits": { "max_turns": 10, "max_tool_calls": 20, "max_wall_seconds": 120 }-}diff --git a/products/agent_platform/services/agent-tests/src/examples/posthog-ai/README.md b/products/agent_platform/services/agent-tests/src/examples/posthog-ai/README.mddeleted file mode 100644index 87cbff7817cb..000000000000--- a/products/agent_platform/services/agent-tests/src/examples/posthog-ai/README.md+++ /dev/null@@ -1,59 +0,0 @@-# PostHog AI — ask PostHog anything, from Slack--A Slack-triggered agent with the **full PostHog MCP** tool surface. It answers-questions about a user's PostHog data — insights, HogQL, dashboards, flags,-error tracking — by calling the MCP **as the asking user** (their linked PostHog-identity), never as PostHog.--This is the MCP counterpart to the `agent-builder` example: instead of the-native `@posthog/*` tools, everything flows through one MCP entry.--## How it's wired--- **Trigger:** `slack` (mention + DM). `allow_workspace_participants: false` —- required, so the asker is the session owner and their identity resolves; a- shared thread would fail closed (you can't act as the user for someone else).-- **MCP:** one entry pointing at the PostHog MCP with `auth.provider: "posthog"`.- The runner resolves the **asking user's** PostHog bearer and stamps it on every- MCP request. Unlinked → the tool returns an `auth_required` link the agent- relays in the thread.-- **Identity provider:** `{ kind: "posthog", scopes: [<read scopes>] }`. On- promote the backend provisions a normal (user-consented) OAuth app and the- link requests these scopes. They must be **explicit OAuth scope objects** —- the `*` wildcard is a PAT/first-party concept and OAuth `/authorize` rejects- it (`invalid_scope`). The set here is broad read access (query, insights,- dashboards, flags, experiments, error tracking, …); add more `:read` scopes- if the user asks about a surface that 403s. The OAuth app's scope ceiling is- provisioned from this list, so changing it requires a re-promote.-- **No native tools, no `spec.secrets`.** Replies post to the thread via the- platform Slack relay (no `@posthog/slack-*` needed). The Slack- `SLACK_SIGNING_SECRET` + `SLACK_BOT_TOKEN` are trigger-required secrets — set- them in the agent's `encrypted_env`, not the spec.--## The MCP URL tracks the seed target--`spec.json` ships the localhost URL (`http://localhost:8787/mcp`). `seed.py`-rewrites any `auth.provider: "posthog"` MCP entry to match the host it's seeding-into: `localhost` → local, `*.us.posthog.com` → `mcp.us.posthog.com`,-`*.eu.posthog.com` → `mcp.eu.posthog.com`. An explicit `MCP_URL` /-`MCP_URL_posthog` env still wins.--## Set it up + test in Slack--1. Create a Slack app from the generated manifest:- `agent-applications-revisions-slack-manifest` (its scopes + event- subscriptions are derived from this spec). Paste the `events_url` /- `interactivity_url` it returns into the Slack app dashboard.-2. Set `SLACK_SIGNING_SECRET` + `SLACK_BOT_TOKEN` in the agent's env editor- (both are required before promote).-3. Lock `trusted_workspaces` from `"*"` to your workspace id.-4. Seed + promote: `PAT=phx_… python services/agent-tests/src/examples/seed.py posthog-ai`-5. In Slack, @-mention or DM the bot. First call → it relays a "connect your- PostHog account" link; after you link, ask it real questions ("how many- signups this week?").--## Regression test--[`services/agent-tests/src/cases/example-posthog-ai.test.ts`](../../cases/example-posthog-ai.test.ts)-asserts the wiring (slack trigger, the posthog-provider MCP, the posthog-identity provider, a non-trivial `agent.md`) — a faux net, not a quality bar.diff --git a/products/agent_platform/services/agent-tests/src/examples/posthog-ai/agent.md b/products/agent_platform/services/agent-tests/src/examples/posthog-ai/agent.mddeleted file mode 100644index a90f8e9873ac..000000000000--- a/products/agent_platform/services/agent-tests/src/examples/posthog-ai/agent.md+++ /dev/null@@ -1,41 +0,0 @@-# PostHog AI--You are **PostHog AI**, a Slack bot that answers questions about a user's-PostHog data. You have the full PostHog MCP tool surface (insights, HogQL-queries, dashboards, feature flags, error tracking, experiments, …) and you-call it **as the user who is talking to you** — never as PostHog, never as-anyone else.--## How you act--- Every PostHog MCP call runs with the asking user's linked PostHog identity.- If they haven't linked yet, the tool hands you back an `auth_required` link —- relay that link in plain language ("Connect your PostHog account: <url>") and- stop. Once they link, retry.-- A 403/permission error is the **user's** access speaking, not a bug. Surface- it plainly; never try to route around it.-- Resolve which project to act in from the user's question or the MCP's project- tools. If it's ambiguous and the MCP exposes a project list, ask which one.--## Answering--- Reach for the most specific MCP tool for the question (a saved insight, a- HogQL query, the error list, …) rather than guessing.-- Lead with the answer, then the supporting number/query. Keep it to a few- lines — this is Slack, not a report.-- Show the HogQL or the insight you used when it helps the user trust or reuse- the result.-- If you can't answer with the tools you have, say so and say what you'd need —- don't invent numbers.--## Replying in Slack--The platform posts your reply into the thread automatically — just answer in-natural language. Don't repeat yourself through a tool. Use Slack-flavored-formatting (`*bold*`, `_italic_`, inline code) and @-mention sparingly.--## Hard rules--1. **Act only as the asking user.** You hold no fallback credential.-2. **Never paste secrets or tokens** into the thread.-3. **Don't guess data.** Every number comes from a tool call you actually made.diff --git a/products/agent_platform/services/agent-tests/src/examples/posthog-ai/spec.json b/products/agent_platform/services/agent-tests/src/examples/posthog-ai/spec.jsondeleted file mode 100644index 45c012fb08a9..000000000000--- a/products/agent_platform/services/agent-tests/src/examples/posthog-ai/spec.json+++ /dev/null@@ -1,59 +0,0 @@-{- "models": { "mode": "manual", "models": [{ "model": "openai/gpt-5.5" }] },- "triggers": [- {- "type": "slack",- "config": {- "mention_only": true,- "auto_resume_threads": true,- "allow_workspace_participants": false,- "allow_direct_messages": true,- "trusted_workspaces": "*",- "ack_reaction": "eyes"- }- }- ],- "tools": [],- "mcps": [- {- "kind": "principal",- "id": "posthog",- "url": "http://localhost:8787/mcp",- "default_tool_approval": "allow",- "auth": { "provider": "posthog" }- }- ],- "skills": [],- "identity_providers": [- {- "kind": "posthog",- "scopes": [- "openid",- "profile",- "email",- "user:read",- "query:read",- "insight:read",- "dashboard:read",- "feature_flag:read",- "experiment:read",- "error_tracking:read",- "event_definition:read",- "property_definition:read",- "cohort:read",- "person:read",- "session_recording:read",- "survey:read",- "action:read",- "annotation:read"- ]- }- ],- "secrets": [],- "limits": {- "max_turns": 30,- "max_tool_calls": 100,- "max_wall_seconds": 600- },- "reasoning": "medium"-}diff --git a/products/agent_platform/services/agent-tests/src/examples/pull.py b/products/agent_platform/services/agent-tests/src/examples/pull.pyindex 5f101099e505..f2261101db31 100644--- a/products/agent_platform/services/agent-tests/src/examples/pull.py+++ b/products/agent_platform/services/agent-tests/src/examples/pull.py@@ -34,20 +34,20 @@ Usage:python services/agent-tests/src/examples/pull.py# One bundle (selector matches slug exactly or as a substring):- python services/agent-tests/src/examples/pull.py kudos-bot+ python services/agent-tests/src/examples/pull.py wake-me-up# Comma-separated, or show what would change without writing:- python services/agent-tests/src/examples/pull.py --only kudos-bot,wake-me-up- DRY_RUN=1 python services/agent-tests/src/examples/pull.py kudos-bot+ python services/agent-tests/src/examples/pull.py --only agent-builder,wake-me-up+ DRY_RUN=1 python services/agent-tests/src/examples/pull.py wake-me-up# Also pull spec.json (triggers / tools / limits), not just content:- python services/agent-tests/src/examples/pull.py --spec kudos-bot+ python services/agent-tests/src/examples/pull.py --spec wake-me-up# Pull the newest revision even if it isn't promoted to live:- python services/agent-tests/src/examples/pull.py --latest kudos-bot+ python services/agent-tests/src/examples/pull.py --latest wake-me-up# Also delete on-disk skills/tools that no longer exist on the platform:- python services/agent-tests/src/examples/pull.py --prune kudos-bot+ python services/agent-tests/src/examples/pull.py --prune wake-me-upEnv vars: the same as `seed.py` — PAT (optional in a flox dev env; otherwiseauto-minted via `manage.py setup_local_api_key`), POSTHOG_API, PROJECT_ID,@@ -314,7 +314,7 @@ def parse_args(argv: list[str]) -> tuple[bool, bool, bool, bool, list[str]]:elif arg.startswith("--only="):selectors.extend(s for s in arg.split("=", 1)[1].split(",") if s)elif arg == "--only":- seed.die("--only needs a value, e.g. --only=kudos-bot")+ seed.die("--only needs a value, e.g. --only=wake-me-up")elif arg.startswith("--"):seed.die(f"unknown flag {arg!r}")else: