:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(aio): add self-driving scout templates (#79745)
Radu Raicea05f86e7bb0c6
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 7de64c0cf753..761a06fc0de4 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -182,7 +182,7 @@ export const FEATURE_FLAGS = {UX_HIDE_PROJECT_NOTICE: 'ux-hide-project-notice', // owner: #team-platform-ux, hides the project notice banner across all scenes// Feature flags used to control opt-in for different behaviors, should not be removed- AI_OBSERVABILITY_DAILY_DIGEST_SCOUT: 'ai-observability-daily-digest-scout', // owner: #team-ai-observability, gates the daily digest scout button+ AI_OBSERVABILITY_SELF_DRIVING: 'ai-observability-daily-digest-scout', // owner: #team-ai-observability, gates the AI observability Self-driving tabAI_TRAINING: 'ai-training', // owner: @nicowaltz #team-replay #ai-research, gates the AI training opt-out UI and API enforcementAUDIT_LOGS_ACCESS: 'audit-logs-access', // owner: #team-platform-features, used to control access to audit logsAUTH_FLOW_VARIANT: 'auth-flow-variant', // owner: @fercgomes #team-growth multivariate=legacy,paper-desk,glass; selects the auth flow experience across login, signup, invited signup, and email verificationdiff --git a/frontend/src/products.tsx b/frontend/src/products.tsxindex c856f8385c50..7971dffb8b0d 100644--- a/frontend/src/products.tsx+++ b/frontend/src/products.tsx@@ -61,6 +61,7 @@ export const productRoutes: Record<string, [string, string]> = {'/data-management/actions/new/': ['NewAction', 'actionNew'],'/ai-gateway': ['AIGateway', 'aiGateway'],'/ai-observability/dashboard': ['AIObservability', 'aiObservabilityDashboard'],+ '/ai-observability/self-driving': ['AIObservability', 'aiObservabilitySelfDriving'],'/ai-observability/generations': ['AIObservability', 'aiObservabilityGenerations'],'/ai-observability/reviews': ['AIObservability', 'aiObservabilityReviews'],'/ai-observability/traces': ['AIObservability', 'aiObservabilityTraces'],@@ -949,6 +950,7 @@ export const productUrls = {actions: (): string => '/data-management/actions',aiGateway: (): string => '/ai-gateway',aiObservabilityDashboard: (): string => '/ai-observability/dashboard',+ aiObservabilitySelfDriving: (): string => '/ai-observability/self-driving',aiObservabilityGenerations: (): string => '/ai-observability/generations',aiObservabilityReviews: (): string => '/ai-observability/reviews',aiObservabilityTraces: (): string => '/ai-observability/traces',diff --git a/products/ai_observability/frontend/AIObservabilityDigestScoutButton.test.tsx b/products/ai_observability/frontend/AIObservabilityDigestScoutButton.test.tsxindex 7378f2d8befa..223848789793 100644--- a/products/ai_observability/frontend/AIObservabilityDigestScoutButton.test.tsx+++ b/products/ai_observability/frontend/AIObservabilityDigestScoutButton.test.tsx@@ -1,55 +1,6 @@-import '@testing-library/jest-dom'--import { cleanup, render, screen } from '@testing-library/react'-import { Provider } from 'kea'-import type { ReactNode } from 'react'--import { FEATURE_FLAGS } from 'lib/constants'-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'--import { initKeaTests } from '~/test/init'--import {- AIObservabilityDigestScoutButton,- getAIObservabilityDigestScoutInitialValues,-} from './AIObservabilityDigestScoutButton'--jest.mock('products/signals/frontend/inbox/components/config/scouts/ScoutCreateButton', () => ({- ScoutCreateButton: ({ children }: { children: ReactNode }) => <button>{children}</button>,-}))--describe('AIObservabilityDigestScoutButton', () => {- let unmountFeatureFlagLogic: (() => void) | null = null-- beforeEach(() => {- initKeaTests()- unmountFeatureFlagLogic = featureFlagLogic.mount()- })-- afterEach(() => {- featureFlagLogic.actions.setFeatureFlags([], {})- unmountFeatureFlagLogic?.()- unmountFeatureFlagLogic = null- cleanup()- })-- it.each([- { enabled: false, visible: false },- { enabled: true, visible: true },- ])('is visible=$visible when the AI observability feature flag is enabled=$enabled', ({ enabled, visible }) => {- featureFlagLogic.actions.setFeatureFlags(enabled ? [FEATURE_FLAGS.AI_OBSERVABILITY_DAILY_DIGEST_SCOUT] : [], {- [FEATURE_FLAGS.AI_OBSERVABILITY_DAILY_DIGEST_SCOUT]: enabled,- })-- render(- <Provider>- <AIObservabilityDigestScoutButton />- </Provider>- )-- expect(Boolean(screen.queryByText('Create daily digest'))).toBe(visible)- })+import { getAIObservabilityDigestScoutInitialValues } from './AIObservabilityDigestScoutButton'+describe('AI observability daily digest scout template', () => {it('prefills a daily 9 a.m. scout that reviews canonical AI observability data and always produces one digest', () => {const initialValues = getAIObservabilityDigestScoutInitialValues()@@ -60,6 +11,7 @@ describe('AIObservabilityDigestScoutButton', () => {emit: true,run_interval_minutes: 1440,run_cron_schedule: '0 9 * * *',+ tags: ['ai-observability'],},})expect(initialValues.body).toEqual(expect.stringContaining('/project/{team_id}/ai-observability/dashboard'))diff --git a/products/ai_observability/frontend/AIObservabilityDigestScoutButton.tsx b/products/ai_observability/frontend/AIObservabilityDigestScoutButton.tsxindex 954c6d3be603..fa3e5589c9c5 100644--- a/products/ai_observability/frontend/AIObservabilityDigestScoutButton.tsx+++ b/products/ai_observability/frontend/AIObservabilityDigestScoutButton.tsx@@ -1,9 +1,3 @@-import { useValues } from 'kea'--import { FEATURE_FLAGS } from 'lib/constants'-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'--import { ScoutCreateButton } from 'products/signals/frontend/inbox/components/config/scouts/ScoutCreateButton'import type { ScoutCreateInitialValues } from 'products/signals/frontend/inbox/logics/scoutCreateModalLogic'const AI_OBSERVABILITY_DIGEST_SCOUT_NAME = 'signals-scout-ai-observability-daily-digest'@@ -69,24 +63,7 @@ Update the scratchpad with useful baselines, noise, and dedupe decisions so tomoemit: true,run_interval_minutes: 1440,run_cron_schedule: '0 9 * * *',+ tags: ['ai-observability'],},}}--export function AIObservabilityDigestScoutButton(): JSX.Element | null {- const { featureFlags } = useValues(featureFlagLogic)-- if (!featureFlags[FEATURE_FLAGS.AI_OBSERVABILITY_DAILY_DIGEST_SCOUT]) {- return null- }-- return (- <ScoutCreateButton- initialValues={getAIObservabilityDigestScoutInitialValues()}- type="secondary"- data-attr="create-ai-observability-digest-scout"- >- Create daily digest- </ScoutCreateButton>- )-}diff --git a/products/ai_observability/frontend/AIObservabilityScene.tsx b/products/ai_observability/frontend/AIObservabilityScene.tsxindex 39cb3908abc6..a6d5292f4227 100644--- a/products/ai_observability/frontend/AIObservabilityScene.tsx+++ b/products/ai_observability/frontend/AIObservabilityScene.tsx@@ -6,11 +6,13 @@ import { LemonButton, LemonTab, LemonTabs, Link, Spinner } from '@posthog/lemon-import { AccessControlAction } from 'lib/components/AccessControlAction'import { DateFilter } from 'lib/components/DateFilter/DateFilter'+import { NotFound } from 'lib/components/NotFound'import { PropertyFilters } from 'lib/components/PropertyFilters/PropertyFilters'import { keyBinds } from 'lib/components/Shortcuts/shortcuts'import { useShortcut } from 'lib/components/Shortcuts/useShortcut'import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'import { TestAccountFilterSwitch } from 'lib/components/TestAccountFiltersSwitch'+import { FEATURE_FLAGS } from 'lib/constants'import { dayjs } from 'lib/dayjs'import { Tooltip } from 'lib/lemon-ui/Tooltip'import { useAttachedLogic } from 'lib/logic/scenes/useAttachedLogic'@@ -33,7 +35,6 @@ import { isEventsQuery } from '~/queries/utils'import { AccessControlLevel, AccessControlResourceType, DashboardPlacement, EventType } from '~/types'import { aiObservabilityColumnRenderers } from './aiObservabilityColumnRenderers'-import { AIObservabilityDigestScoutButton } from './AIObservabilityDigestScoutButton'import { AIObservabilityErrors } from './AIObservabilityErrors'import { AIObservabilityReloadAction } from './AIObservabilityReloadAction'import { AIObservabilitySessionsPlaylist } from './AIObservabilitySessionsPlaylist'@@ -48,6 +49,7 @@ import { AIObservabilityUsers } from './AIObservabilityUsers'import { aiObservabilityEmptyState } from './emptyState/aiObservabilityEmptyState'import { useSortableColumns } from './hooks/useSortableColumns'import { llmPersonsLazyLoaderLogic } from './llmPersonsLazyLoaderLogic'+import { AIObservabilitySelfDriving } from './selfDriving/AIObservabilitySelfDriving'import { GENERATION_SENTIMENT_SELECT } from './sentimentResults'import { aiObservabilityDashboardLogic } from './tabs/aiObservabilityDashboardLogic'import { aiObservabilityErrorsLogic } from './tabs/aiObservabilityErrorsLogic'@@ -403,6 +405,7 @@ function AIObservabilityGenerations(): JSX.Element {const DEFAULT_DOCS_URL = 'https://posthog.com/docs/ai-observability/installation'const DOCS_URLS_BY_TAB: Record<string, string> = {+ 'self-driving': 'https://posthog.com/docs/self-driving/scouts',traces: 'https://posthog.com/docs/ai-observability/traces',reviews: 'https://posthog.com/docs/ai-observability/trace-reviews',generations: 'https://posthog.com/docs/ai-observability/generations',@@ -414,6 +417,7 @@ const DOCS_URLS_BY_TAB: Record<string, string> = {const TAB_DESCRIPTIONS: Record<string, string> = {dashboard: 'Overview of your AI usage, costs, and performance metrics.',+ 'self-driving': 'Create and manage scouts that monitor your AI observability data.',traces: 'Explore end-to-end traces of your LLM interactions.',reviews: 'Browse reviews, organize queues, and manage the scoring setup.',generations: 'View individual AI generations and their details.',@@ -457,10 +461,11 @@ export function AIObservabilityScene(): JSX.Element {}function AIObservabilitySceneContent(): JSX.Element {- const { activeTab } = useValues(aiObservabilitySharedLogic)+ const { activeTab, featureFlags } = useValues(aiObservabilitySharedLogic)const { searchParams } = useValues(router)const { push } = useActions(router)+ const selfDrivingEnabled = Boolean(featureFlags[FEATURE_FLAGS.AI_OBSERVABILITY_SELF_DRIVING])// Tab switching shortcutsuseShortcut({@@ -474,36 +479,64 @@ function AIObservabilitySceneContent(): JSX.Element {useShortcut({name: 'AIObservabilityTab2',keybind: [keyBinds.tab2],- intent: 'Go to Traces',+ intent: selfDrivingEnabled ? 'Go to Self-driving' : 'Go to Traces',interaction: 'function',- callback: () => push(combineUrl(urls.aiObservabilityTraces(), searchParams).url),+ callback: () =>+ push(+ combineUrl(+ selfDrivingEnabled ? urls.aiObservabilitySelfDriving() : urls.aiObservabilityTraces(),+ searchParams+ ).url+ ),scope: Scene.AIObservability,})useShortcut({name: 'AIObservabilityTab3',keybind: [keyBinds.tab3],- intent: 'Go to Generations',+ intent: selfDrivingEnabled ? 'Go to Traces' : 'Go to Generations',interaction: 'function',- callback: () => push(combineUrl(urls.aiObservabilityGenerations(), searchParams).url),+ callback: () =>+ push(+ combineUrl(+ selfDrivingEnabled ? urls.aiObservabilityTraces() : urls.aiObservabilityGenerations(),+ searchParams+ ).url+ ),scope: Scene.AIObservability,})useShortcut({name: 'AIObservabilityTab4',keybind: [keyBinds.tab4],- intent: 'Go to Users',+ intent: selfDrivingEnabled ? 'Go to Generations' : 'Go to Users',interaction: 'function',- callback: () => push(combineUrl(urls.aiObservabilityUsers(), searchParams).url),+ callback: () =>+ push(+ combineUrl(+ selfDrivingEnabled ? urls.aiObservabilityGenerations() : urls.aiObservabilityUsers(),+ searchParams+ ).url+ ),scope: Scene.AIObservability,})useShortcut({name: 'AIObservabilityTab5',keybind: [keyBinds.tab5],- intent: 'Go to Errors',+ intent: selfDrivingEnabled ? 'Go to Sessions' : 'Go to Errors',interaction: 'function',- callback: () => push(combineUrl(urls.aiObservabilityErrors(), searchParams).url),+ callback: () =>+ push(+ combineUrl(+ selfDrivingEnabled ? urls.aiObservabilitySessions() : urls.aiObservabilityErrors(),+ searchParams+ ).url+ ),scope: Scene.AIObservability,})+ if (activeTab === 'self-driving' && !selfDrivingEnabled) {+ return <NotFound object="page" />+ }+const tabs: LemonTab<string>[] = [{key: 'dashboard',@@ -535,6 +568,16 @@ function AIObservabilitySceneContent(): JSX.Element {},]+ if (selfDrivingEnabled) {+ tabs.splice(1, 0, {+ key: 'self-driving',+ label: 'Self-driving',+ content: <AIObservabilitySelfDriving />,+ link: combineUrl(urls.aiObservabilitySelfDriving(), searchParams).url,+ 'data-attr': 'self-driving-tab',+ })+ }+tabs.push({key: 'errors',label: 'Errors',@@ -602,17 +645,14 @@ function AIObservabilitySceneContent(): JSX.Element {type: sceneConfigurations[Scene.AIObservability].iconType || 'default_icon_type',}}actions={- <>- {activeTab === 'dashboard' ? <AIObservabilityDigestScoutButton /> : null}- <LemonButton- to={DOCS_URLS_BY_TAB[activeTab] || DEFAULT_DOCS_URL}- type="secondary"- targetBlank- size="small"- >- Documentation- </LemonButton>- </>+ <LemonButton+ to={DOCS_URLS_BY_TAB[activeTab] || DEFAULT_DOCS_URL}+ type="secondary"+ targetBlank+ size="small"+ >+ Documentation+ </LemonButton>}/>diff --git a/products/ai_observability/frontend/aiObservabilityLogic.test.ts b/products/ai_observability/frontend/aiObservabilityLogic.test.tsindex 6bd8d3edfdd7..4a838c7dc77b 100644--- a/products/ai_observability/frontend/aiObservabilityLogic.test.ts+++ b/products/ai_observability/frontend/aiObservabilityLogic.test.ts@@ -7,6 +7,7 @@ import api from 'lib/api'import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { emptySceneParams } from 'scenes/scenes'+import { Scene } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'import { productRedirects } from '~/products'@@ -38,6 +39,7 @@ const redirectUrl = (describe('LLM analytics URL split', () => {it('uses the new canonical product URLs', () => {expect(urls.aiObservabilityDashboard()).toBe('/ai-observability/dashboard')+ expect(urls.aiObservabilitySelfDriving()).toBe('/ai-observability/self-driving')expect(urls.aiObservabilityReviews()).toBe('/ai-observability/reviews')expect(urls.aiObservabilityTrace('trace-1')).toBe('/ai-observability/traces/trace-1')expect(urls.aiObservabilityDatasets()).toBe('/ai-evals/datasets')@@ -121,6 +123,12 @@ describe('aiObservabilitySharedLogic', () => {})})+ it('selects the Self-driving tab for its scene key', () => {+ sceneLogic.actions.setScene(Scene.AIObservability, 'aiObservabilitySelfDriving', emptySceneParams, false)++ expectLogic(logic).toMatchValues({ activeTab: 'self-driving' })+ })+it('preserves params owned by other logics when rewriting the URL', () => {// review_* / human_reviews_tab ride along on tab links — applying shared// state must not strip themdiff --git a/products/ai_observability/frontend/aiObservabilitySharedLogic.ts b/products/ai_observability/frontend/aiObservabilitySharedLogic.tsindex 5ab5f513d9b8..cffa0b0b3b11 100644--- a/products/ai_observability/frontend/aiObservabilitySharedLogic.ts+++ b/products/ai_observability/frontend/aiObservabilitySharedLogic.ts@@ -51,6 +51,7 @@ const STALE_PARAMS = new Set(['event', 'timestamp', 'msg'])export type AIObservabilityTabId =| 'dashboard'+ | 'self-driving'| 'generations'| 'reviews'| 'traces'@@ -357,7 +358,9 @@ export const aiObservabilitySharedLogic = kea<aiObservabilitySharedLogicType>([activeTab: [(s) => [s.sceneKey],(sceneKey: string | null): AIObservabilityTabId => {- if (sceneKey === 'aiObservabilityGenerations') {+ if (sceneKey === 'aiObservabilitySelfDriving') {+ return 'self-driving'+ } else if (sceneKey === 'aiObservabilityGenerations') {return 'generations'} else if (sceneKey === 'aiObservabilityReviews') {return 'reviews'@@ -474,6 +477,7 @@ export const aiObservabilitySharedLogic = kea<aiObservabilitySharedLogicType>([applySearchParams(searchParams)startDashboardTimer()},+ [urls.aiObservabilitySelfDriving()]: (_, searchParams) => applyNonDashboard(searchParams),[urls.aiObservabilityGenerations()]: (_, searchParams) => applyNonDashboard(searchParams),[urls.aiObservabilityReviews()]: (_, searchParams) => applyNonDashboard(searchParams),[urls.aiObservabilityTraces()]: (_, searchParams) => applyNonDashboard(searchParams),diff --git a/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.test.tsx b/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.test.tsxnew file mode 100644index 000000000000..0f40d16e7d30--- /dev/null+++ b/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.test.tsx@@ -0,0 +1,51 @@+import '@testing-library/jest-dom'++import { cleanup, render, screen } from '@testing-library/react'+import userEvent from '@testing-library/user-event'+import { Provider } from 'kea'+import type { ReactNode } from 'react'++import { initKeaTests } from '~/test/init'++import { AIObservabilitySelfDriving } from './AIObservabilitySelfDriving'++jest.mock('products/signals/frontend/generated/api', () => ({+ signalsScoutConfigList: jest.fn(() => new Promise(() => {})),+ signalsScoutMetadataGet: jest.fn(() => new Promise(() => {})),+}))++jest.mock('products/signals/frontend/inbox/components/config/scouts/ScoutCreateButton', () => ({+ ScoutCreateButton: ({ children }: { children: ReactNode }) => <button>{children}</button>,+}))++describe('AIObservabilitySelfDriving', () => {+ beforeEach(() => {+ initKeaTests()+ })++ afterEach(() => {+ cleanup()+ })++ it('renders scout templates and links to the self-driving docs', async () => {+ render(+ <Provider>+ <AIObservabilitySelfDriving />+ </Provider>+ )++ expect(screen.getAllByText('Use template')).toHaveLength(3)++ const tooltipTrigger = screen.getByText('What is this?')+ await userEvent.hover(tooltipTrigger)++ expect(await screen.findByText(/Each template is a pre-defined scout/)).toBeInTheDocument()++ const docsLink = screen.getByText('Read the docs')+ expect(docsLink).toHaveAttribute('href', 'https://posthog.com/docs/ai-observability/self-driving')+ expect(docsLink).toHaveAttribute('target', '_blank')+ expect(screen.getByText('ai-observability').closest('p')).toHaveTextContent(+ 'Add the ai-observability label to a scout for it to appear here.'+ )+ })+})diff --git a/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.tsx b/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.tsxnew file mode 100644index 000000000000..f81c1efdacba--- /dev/null+++ b/products/ai_observability/frontend/selfDriving/AIObservabilitySelfDriving.tsx@@ -0,0 +1,148 @@+import { useActions, useValues } from 'kea'++import { IconCalendar, IconQuestion, IconUser, IconWarning } from '@posthog/icons'+import { LemonBanner, LemonCard, LemonSkeleton, LemonTag, Tooltip } from '@posthog/lemon-ui'++import { ScoutCreateButton } from 'products/signals/frontend/inbox/components/config/scouts/ScoutCreateButton'+import { ScoutRowCard } from 'products/signals/frontend/inbox/components/config/scouts/ScoutRowCard'+import { scoutFleetLogic } from 'products/signals/frontend/inbox/logics/scoutFleetLogic'++import {+ AI_OBSERVABILITY_SCOUT_TEMPLATES,+ AIObservabilityScoutTemplate,+ isAIObservabilityScout,+} from './aiObservabilityScoutTemplates'++const SCOUTS_DOCS_URL = 'https://posthog.com/docs/ai-observability/self-driving'++const TEMPLATE_ICONS: Record<AIObservabilityScoutTemplate['key'], JSX.Element> = {+ 'daily-digest': <IconCalendar />,+ 'costly-users': <IconUser />,+ 'error-patterns': <IconWarning />,+}++function ScoutTemplateCard({ template }: { template: AIObservabilityScoutTemplate }): JSX.Element {+ const { loadScoutConfigs } = useActions(scoutFleetLogic)++ return (+ <LemonCard hoverEffect={false} className="flex flex-col gap-3 p-3">+ <div className="flex min-w-0 items-start gap-2">+ <span className="mt-0.5 shrink-0 text-muted">{TEMPLATE_ICONS[template.key]}</span>+ <div className="min-w-0">+ <h3 className="m-0 text-sm font-semibold">{template.title}</h3>+ <p className="m-0 text-xs text-muted">{template.description}</p>+ </div>+ </div>+ <div className="mt-auto flex items-center justify-between gap-2">+ <LemonTag type="muted" size="small">+ {template.schedule}+ </LemonTag>+ <ScoutCreateButton+ initialValues={template.initialValues}+ onCreated={() => loadScoutConfigs()}+ data-attr={`create-${template.key}-scout`}+ >+ Use template+ </ScoutCreateButton>+ </div>+ </LemonCard>+ )+}++export function AIObservabilitySelfDriving(): JSX.Element {+ const { scoutConfigs, scoutConfigsLoading, deletingScoutIds, updatingScoutIds } = useValues(scoutFleetLogic)+ const { deleteScout, loadScoutConfigs, updateScoutConfig } = useActions(scoutFleetLogic)++ const aiObservabilityScouts = scoutConfigs?.filter(isAIObservabilityScout) ?? []++ let scoutsContent: JSX.Element+ if (scoutConfigsLoading && scoutConfigs === null) {+ scoutsContent = (+ <div className="flex flex-col gap-2">+ <LemonSkeleton className="h-16 w-full rounded" />+ <LemonSkeleton className="h-16 w-full rounded" />+ </div>+ )+ } else if (scoutConfigs === null) {+ scoutsContent = (+ <LemonBanner+ type="error"+ action={{ children: 'Try again', onClick: () => loadScoutConfigs() }}+ data-attr="ai-observability-scouts-load-error"+ >+ We couldn't load your AI observability scouts. Try again in a moment.+ </LemonBanner>+ )+ } else if (aiObservabilityScouts.length === 0) {+ scoutsContent = (+ <LemonCard hoverEffect={false} className="p-4 text-sm text-muted">+ No AI observability scouts yet. Use a template above to create one.+ </LemonCard>+ )+ } else {+ scoutsContent = (+ <div className="flex flex-col gap-2">+ {aiObservabilityScouts.map((config) => (+ <ScoutRowCard+ key={config.id}+ config={config}+ rollup={undefined}+ onUpdate={updateScoutConfig}+ onDelete={deleteScout}+ deleting={deletingScoutIds.includes(config.id)}+ updating={updatingScoutIds.includes(config.id)}+ />+ ))}+ </div>+ )+ }++ return (+ <div className="flex flex-col gap-6">+ <section className="flex flex-col gap-2">+ <div>+ <div className="flex items-center gap-2">+ <h2 className="m-0 text-base font-semibold">Start with a template</h2>+ <Tooltip+ title="Each template is a pre-defined scout – a scheduled agent that explores your AI observability data and surfaces findings worth reviewing. Actionable scout reports land in your inbox."+ docLink={SCOUTS_DOCS_URL}+ >+ <span+ className="inline-flex items-center gap-1 text-xs text-muted hover:text-default cursor-pointer transition-colors"+ data-attr="ai-observability-scout-templates-what-is-this"+ >+ <IconQuestion className="text-sm" />+ What is this?+ </span>+ </Tooltip>+ </div>+ <p className="m-0 text-sm text-muted">+ Choose a starting point, then review and edit it before saving.+ </p>+ </div>+ <div className="grid gap-2 md:grid-cols-2 xl:grid-cols-3">+ {AI_OBSERVABILITY_SCOUT_TEMPLATES.map((template) => (+ <ScoutTemplateCard key={template.key} template={template} />+ ))}+ </div>+ </section>++ <section className="flex flex-col gap-2">+ <div>+ <div className="flex items-center gap-2">+ <h2 className="m-0 text-base font-semibold">Your AI observability scouts</h2>+ {scoutConfigs !== null ? (+ <LemonTag type="muted" size="small">+ {aiObservabilityScouts.length}+ </LemonTag>+ ) : null}+ </div>+ <p className="m-0 text-sm text-muted">+ Add the <code>ai-observability</code> label to a scout for it to appear here.+ </p>+ </div>+ {scoutsContent}+ </section>+ </div>+ )+}diff --git a/products/ai_observability/frontend/selfDriving/aiObservabilityScoutTemplates.test.ts b/products/ai_observability/frontend/selfDriving/aiObservabilityScoutTemplates.test.tsnew file mode 100644index 000000000000..d87548b0e4e0--- /dev/null+++ b/products/ai_observability/frontend/selfDriving/aiObservabilityScoutTemplates.test.ts@@ -0,0 +1,52 @@+import type { SignalScoutConfigApi } from 'products/signals/frontend/generated/api.schemas'++import {+ AI_OBSERVABILITY_SCOUT_TAG,+ AI_OBSERVABILITY_SCOUT_TEMPLATES,+ isAIObservabilityScout,+} from './aiObservabilityScoutTemplates'++describe('AI observability scout templates', () => {+ it('provides three uniquely named templates', () => {+ expect(AI_OBSERVABILITY_SCOUT_TEMPLATES).toHaveLength(3)++ const names = AI_OBSERVABILITY_SCOUT_TEMPLATES.map((template) => template.initialValues.name)+ expect(new Set(names).size).toBe(names.length)+ })++ it.each(AI_OBSERVABILITY_SCOUT_TEMPLATES)(+ '$title creates an enabled 9 a.m. daily scout with the product tag',+ ({ initialValues, schedule }) => {+ expect(initialValues.name).toMatch(/^signals-scout-ai-observability-/)+ expect(initialValues.body).toBeTruthy()+ expect(schedule).toBe('Daily at 9:00 AM')+ expect(initialValues.config).toMatchObject({+ enabled: true,+ emit: true,+ run_interval_minutes: 1440,+ run_cron_schedule: '0 9 * * *',+ tags: [AI_OBSERVABILITY_SCOUT_TAG],+ })+ }+ )++ it.each([+ {+ name: 'tagged scout',+ config: { skill_name: 'signals-scout-custom', tags: [AI_OBSERVABILITY_SCOUT_TAG] },+ expected: true,+ },+ {+ name: 'legacy digest without a tag',+ config: { skill_name: 'signals-scout-ai-observability-daily-digest', tags: [] },+ expected: false,+ },+ {+ name: 'unrelated scout',+ config: { skill_name: 'signals-scout-unrelated', tags: ['other'] },+ expected: false,+ },+ ])('includes $name=$expected', ({ config, expected }) => {+ expect(isAIObservabilityScout(config as SignalScoutConfigApi)).toBe(expected)+ })+})diff --git a/products/ai_observability/frontend/selfDriving/aiObservabilityScoutTemplates.ts b/products/ai_observability/frontend/selfDriving/aiObservabilityScoutTemplates.tsnew file mode 100644index 000000000000..9ea61e6f127c--- /dev/null+++ b/products/ai_observability/frontend/selfDriving/aiObservabilityScoutTemplates.ts@@ -0,0 +1,164 @@+import type { SignalScoutConfigApi } from 'products/signals/frontend/generated/api.schemas'+import type { ScoutCreateInitialValues } from 'products/signals/frontend/inbox/logics/scoutCreateModalLogic'+import { scoutTags } from 'products/signals/frontend/inbox/utils/scoutTags'++import { getAIObservabilityDigestScoutInitialValues } from '../AIObservabilityDigestScoutButton'++export const AI_OBSERVABILITY_SCOUT_TAG = 'ai-observability'++export interface AIObservabilityScoutTemplate {+ key: 'daily-digest' | 'costly-users' | 'error-patterns'+ title: string+ description: string+ schedule: string+ initialValues: ScoutCreateInitialValues+}++export const AI_OBSERVABILITY_SCOUT_TEMPLATES: AIObservabilityScoutTemplate[] = [+ {+ key: 'daily-digest',+ title: 'Daily digest',+ description: 'Summarize meaningful changes in AI usage, cost, errors, costly users, and evaluations.',+ schedule: 'Daily at 9:00 AM',+ initialValues: getAIObservabilityDigestScoutInitialValues(),+ },+ {+ key: 'costly-users',+ title: 'Costly or unusual users',+ description: 'Find unusual usage and very costly users, then trace the spend to a cause you can act on.',+ schedule: 'Daily at 9:00 AM',+ initialValues: {+ name: 'signals-scout-ai-observability-costly-users',+ description:+ 'Finds extraordinary user-level AI spend or usage, validates the cause in traces, and reports only patterns with a controllable next action.',+ body: `# AI observability costly or unusual users++Find extraordinary user-level cost or usage patterns in the most recent complete 24 hours. Compare them with the preceding 24 hours, the recent 7-day baseline, and the same weekday when traffic is seasonal. Never compare a complete period with a partial one.++A user ranking highly by spend is not a finding. Look for a material departure in unit economics or behavior with a controllable cause, validated in real traces. High volume with normal cost per trace may be healthy usage.++## Use the packaged analysis skills++Load these preinstalled skills through the runtime's packaged-skill mechanism when relevant:++- \`analyzing-expensive-users\`+- \`exploring-llm-costs\`+- \`exploring-llm-traces\`+- \`querying-posthog-data\`++These are packaged runtime skills, not project skill-store entries. Do not use \`skill-list\` or \`skill-get\` to load them.++## Avoid duplicate work++Read this Scout's last 14 days of run summaries with \`scout-runs-list\`, filtered by its exact \`skill_name\` and current \`skill_version\`. Retrieve relevant details with \`scout-runs-retrieve\`.++Search the scratchpad and recent Inbox reports for the user, segment, workflow, and suspected cause. If a live report already covers the same pattern, add only materially new evidence with \`scout-edit-report\`. Skip unchanged issues. Never create a second report for an unchanged issue.++## Investigate a bounded set++1. Rank identified users by generated-call spend. Include both \`$ai_generation\` and \`$ai_embedding\` when calculating full cost totals. Exclude rows where \`distinct_id = properties.$ai_trace_id\` when treating \`distinct_id\` as a user.+2. Establish the population baseline for cost share, traces, cost per generation, tokens, cache behavior, errors, and retries.+3. Select at most three candidates whose behavior materially differs from both the population and their own baseline.+4. Break each candidate down by model, provider, span, workflow, feature, or another property that exists in the project. Use \`read-data-schema\` before grouping by custom dimensions.+5. Open representative traces before explaining the cause. Aggregates identify candidates. Traces establish whether the cause is a retry loop, context growth, output growth, model choice, missing caching, abuse, or a product bug.++Minimize personal data. Use the least identifying stable label available. Never include raw prompts, responses, or full person-property objects in a report.++Close without a report when the highest-spend users are consistent with expected volume and normal unit economics.++## Report only actionable patterns++A report-worthy finding must be extraordinary against a relevant baseline, material and recent, supported by representative traces, and actionable through code, prompts, model choice, caching, limits, configuration, or product behavior.++Group users with the same root cause into one report. Create no more than two reports per run. Search the Inbox again before writing. Edit a matching live report instead of creating a duplicate.++Title a new report \`Unusual AI spend: <segment and cause>\`. Include the comparison window, the minimum numbers needed to judge the change, the trace-backed cause or best next investigation, and one specific next action. Include direct trace links or IDs as evidence.++Do not report routine top spenders, expected launches or batch jobs, test traffic, one costly trace without a repeatable problem, or a known provider incident already covered elsewhere.++Finish with a short run summary covering what you checked, what you reported or updated, and what you ruled out.`,+ config: {+ enabled: true,+ emit: true,+ run_interval_minutes: 1440,+ run_cron_schedule: '0 9 * * *',+ tags: [AI_OBSERVABILITY_SCOUT_TAG],+ },+ },+ },+ {+ key: 'error-patterns',+ title: 'Error patterns',+ description: 'Read real traces to find recurring errors and silent AI failures worth fixing.',+ schedule: 'Daily at 9:00 AM',+ initialValues: {+ name: 'signals-scout-ai-observability-error-patterns',+ description:+ 'Finds new or growing AI failure modes, including silent quality failures, and validates each pattern against real traces.',+ body: `# AI observability error patterns++Find new, growing, or recurring AI failure modes in the most recent complete 24 hours. Compare them with the preceding 24 hours and the recent 7-day baseline.++The main signal is a recurring failure mode within one use case, validated by real traces and tied to a concrete next action. Raw error counts are pointers to investigate, not findings. Important AI failures can return HTTP 200 with no exception.++## Use the packaged analysis skills++Load these preinstalled skills through the runtime's packaged-skill mechanism when relevant:++- \`exploring-ai-failures\`+- \`exploring-llm-traces\`+- \`exploring-llm-clusters\`+- \`exploring-llm-evaluations\`+- \`querying-posthog-data\`++These are packaged runtime skills, not project skill-store entries. Do not use \`skill-list\` or \`skill-get\` to load them.++## Avoid duplicate work++Read this Scout's last 14 days of run summaries with \`scout-runs-list\`, filtered by its exact \`skill_name\` and current \`skill_version\`. Retrieve relevant details with \`scout-runs-retrieve\`.++Search the scratchpad and recent Inbox reports for the use case, failure mode, error, evaluation, cluster, and suspected cause. If a live report already covers the same pattern, add only materially new evidence with \`scout-edit-report\`. Skip it when the evidence and impact are unchanged.++## Find and read failures++Work on one use case at a time because different trace types fail differently.++1. Discover the project's trace taxonomy from properties that actually exist, such as feature, workflow, model, or span name.+2. Choose the use case with the clearest recent change or the stalest prior coverage.+3. Select traces using the signals that fit the data: explicit errors, tool failures, retries, evaluation failures, negative feedback, latency or token outliers, semantic clusters, or a stratified sample.+4. Open and read real traces. Queries choose what to read but do not establish a failure mode.+5. Identify the first thing that went wrong in each failing trace and group traces by that root failure instead of downstream symptoms.+6. Continue until the common modes stabilize, with a maximum of 25 traces in one run.+7. Quantify each mode against the full use-case population. Keep sample counts and population estimates separate.++Look for loud errors and silent failures such as ignored instructions, wrong answers, missing context, tool misuse, loops, malformed output, or incomplete work. Do not infer a silent failure from text matching alone.++Minimize personal data. Summarize the relevant behavior and cite trace IDs or links without copying sensitive prompt or response content.++Close without a report when no repeated, materially changed, or actionable failure mode clears the bar.++## Report only actionable patterns++A report-worthy failure must appear across independent traces or have clear systemic impact, be new or materially worse than baseline, be validated by representative traces, and lead to a concrete action.++Create one report per root failure, not per trace or error string. Create no more than two reports per run. Search the Inbox again before writing. Edit a matching live report instead of creating a duplicate.++Title a new report \`AI error pattern: <specific mode>\`. Include the affected use case and comparison window, how often it appeared, what failed first, why it matters, and the best next action. Include one to three representative trace links or IDs.++Do not report expected cancellations, test or synthetic evaluation traffic presented as production impact, known provider incidents covered elsewhere, one-off traces without systemic impact, or error aggregates that were not validated by reading traces.++Finish with a short run summary covering what you reviewed, what you reported or updated, and what you ruled out.`,+ config: {+ enabled: true,+ emit: true,+ run_interval_minutes: 1440,+ run_cron_schedule: '0 9 * * *',+ tags: [AI_OBSERVABILITY_SCOUT_TAG],+ },+ },+ },+]++export function isAIObservabilityScout(config: SignalScoutConfigApi): boolean {+ return scoutTags(config).includes(AI_OBSERVABILITY_SCOUT_TAG)+}diff --git a/products/ai_observability/manifest.tsx b/products/ai_observability/manifest.tsxindex 3e3b399d884a..d6b1560f5691 100644--- a/products/ai_observability/manifest.tsx+++ b/products/ai_observability/manifest.tsx@@ -135,6 +135,7 @@ export const manifest: ProductManifest = {},routes: {'/ai-observability/dashboard': ['AIObservability', 'aiObservabilityDashboard'],+ '/ai-observability/self-driving': ['AIObservability', 'aiObservabilitySelfDriving'],'/ai-observability/generations': ['AIObservability', 'aiObservabilityGenerations'],'/ai-observability/reviews': ['AIObservability', 'aiObservabilityReviews'],'/ai-observability/traces': ['AIObservability', 'aiObservabilityTraces'],@@ -288,6 +289,7 @@ export const manifest: ProductManifest = {},urls: {aiObservabilityDashboard: (): string => '/ai-observability/dashboard',+ aiObservabilitySelfDriving: (): string => '/ai-observability/self-driving',aiObservabilityGenerations: (): string => '/ai-observability/generations',aiObservabilityReviews: (): string => '/ai-observability/reviews',aiObservabilityTraces: (): string => '/ai-observability/traces',