: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(signals): close telemetry gaps on the suggested scouts strip (#110138)
posthog[bot]20d9cd00d368
diff --git a/products/signals/backend/scout_harness/serializers.py b/products/signals/backend/scout_harness/serializers.pyindex c358345b289e..84e691e84f54 100644--- a/products/signals/backend/scout_harness/serializers.py+++ b/products/signals/backend/scout_harness/serializers.py@@ -3738,6 +3738,16 @@ class SignalScoutConfigUpdateSerializer(_ScoutConfigCapabilityFieldsMixin, seria),)+ suggestion_id = serializers.CharField(+ required=False,+ write_only=True,+ max_length=64,+ help_text=(+ "Optional id of the canonical scout suggestion this request turns on. It records that the "+ "scout came from that suggestion. An id this project's batch does not hold is ignored."+ ),+ )+def validate_output_destinations(self, value: dict) -> dict:return _validate_output_destinations(value, self.context)@@ -3842,6 +3852,7 @@ class SignalScoutConfigUpdateSerializer(_ScoutConfigCapabilityFieldsMixin, seria"mcp_gateway_server_ids","repositories","write_scopes",+ "suggestion_id",]diff --git a/products/signals/backend/scout_harness/suggestions.py b/products/signals/backend/scout_harness/suggestions.pyindex 89b4ac00b27a..f1eaba1e0dde 100644--- a/products/signals/backend/scout_harness/suggestions.py+++ b/products/signals/backend/scout_harness/suggestions.py@@ -829,6 +829,7 @@ def _item_record(item: ScoutSuggestionItem, *, prior: dict[str, Any] | None) ->record["dismissed_at"] = prior.get("dismissed_at")record["dismissed_by_id"] = prior.get("dismissed_by_id")record["created_config_id"] = prior.get("created_config_id")+ record["created_skill_name"] = prior.get("created_skill_name")return record@@ -847,6 +848,7 @@ def _tombstone(record: dict[str, Any]) -> dict[str, Any]:"dismissed_at": record.get("dismissed_at"),"dismissed_by_id": record.get("dismissed_by_id"),"created_config_id": record.get("created_config_id"),+ "created_skill_name": record.get("created_skill_name"),}@@ -1031,8 +1033,22 @@ def dismiss_suggestion(team_id: int, suggestion_id: str, *, user_id: int | None))-def mark_suggestion_created(team_id: int, suggestion_id: str, *, config_id: str) -> dict[str, Any] | None:- return _update_item(team_id, suggestion_id, {"created_config_id": config_id})+def mark_suggestion_created(+ team_id: int, suggestion_id: str, *, kind: str, config_id: str, skill_name: str+) -> dict[str, Any] | None:+ """Record the scout a suggestion became, or return None when the id names no such pick.++ Only an item of `kind` with no scout yet is marked, so a client cannot move the mark to another+ pick. A custom draft can be renamed in the form, so it matches by id alone. A canonical scout+ keeps its name, so its item must also name `skill_name`. The final name is stored next to the+ config id, which keeps a rename visible.+ """+ record = find_suggestion(team_id, suggestion_id)+ if record is None or record.get("kind") != kind or record.get("created_config_id"):+ return None+ if kind == "canonical" and record.get("skill_name") != skill_name:+ return None+ return _update_item(team_id, suggestion_id, {"created_config_id": config_id, "created_skill_name": skill_name})def mark_stale_if_fleet_changed(team_id: int) -> None:diff --git a/products/signals/backend/scout_harness/views.py b/products/signals/backend/scout_harness/views.pyindex 5b0b0c776468..f41584c8e5cf 100644--- a/products/signals/backend/scout_harness/views.py+++ b/products/signals/backend/scout_harness/views.py@@ -159,7 +159,7 @@ from products.signals.backend.scout_harness.skill_loader import (load_skill_for_run,resolve_scout_acting_user_id,)-from products.signals.backend.scout_harness.suggestions import find_suggestion, mark_suggestion_created+from products.signals.backend.scout_harness.suggestions import mark_suggestion_createdfrom products.signals.backend.scout_harness.team_limits import (max_enabled_scouts_for_team,resolve_team_metadata,@@ -3041,21 +3041,8 @@ class SignalScoutViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):)# Hides the suggestion the moment its scout exists, rather than waiting for the read to# notice the name is taken — which it only does for enabled scouts and custom drafts.- # The scout is committed by here, so a failed marker must not answer 500 for a scout that- # exists; the read still hides the item once the name is taken. Only the draft this scout- # was created from is marked, so an unrelated id cannot retire another pick.if suggestion_id := validated.get("suggestion_id"):- try:- record = find_suggestion(canonical_team.id, suggestion_id)- if record is not None and record.get("skill_name") == outcome.skill.name:- mark_suggestion_created(canonical_team.id, suggestion_id, config_id=str(outcome.config.id))- except Exception:- logger.warning(- "scout_suggestions: failed to mark suggestion created",- team_id=canonical_team.id,- suggestion_id=suggestion_id,- exc_info=True,- )+ _mark_suggestion_created(canonical_team.id, suggestion_id, kind="custom", config=outcome.config)response = SignalScoutCreateResponseSerializer({"created": outcome.created, "skill": outcome.skill, "config": outcome.config},context=scout_config_context(canonical_team, [outcome.skill.name], request),@@ -3066,6 +3053,22 @@ class SignalScoutViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):)+def _mark_suggestion_created(team_id: int, suggestion_id: str, *, kind: str, config: SignalScoutConfig) -> None:+ # The scout is committed by here, so a failed marker must not answer 500 for a scout that+ # exists. The read still hides the item once the scout is enabled or its name is taken.+ try:+ mark_suggestion_created(+ team_id, suggestion_id, kind=kind, config_id=str(config.id), skill_name=config.skill_name+ )+ except Exception:+ logger.warning(+ "scout_suggestions: failed to mark suggestion created",+ team_id=team_id,+ suggestion_id=suggestion_id,+ exc_info=True,+ )++@lru_cache(maxsize=1)def _scout_tool_catalogue_payload() -> dict[str, Any]:"""The rendered tool catalogue.@@ -3353,6 +3356,8 @@ class SignalScoutConfigViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):},)serializer.is_valid(raise_exception=True)+ # Attribution only, not a config field, so it must not count as an edit of the config.+ suggestion_id = serializer.validated_data.pop("suggestion_id", None)enabling = not config.enabled and serializer.validated_data.get("enabled")if enabling:_reject_if_enabled_cap_reached(team_id, config.skill_name, cap=max_enabled_scouts)@@ -3361,6 +3366,8 @@ class SignalScoutConfigViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):if enabling:save_kwargs["enabled_by"] = request.userinstance = serializer.save(**save_kwargs)+ if suggestion_id and instance.enabled:+ _mark_suggestion_created(team_id, suggestion_id, kind="canonical", config=instance)context = scout_config_context(team, [instance.skill_name], request)return Response(SignalScoutConfigSerializer(instance, context=context).data)diff --git a/products/signals/backend/test/test_scout_suggestions.py b/products/signals/backend/test/test_scout_suggestions.pyindex f2150fcf518b..7df2ed408c7d 100644--- a/products/signals/backend/test/test_scout_suggestions.py+++ b/products/signals/backend/test/test_scout_suggestions.py@@ -197,7 +197,11 @@ class TestSuggestionPersistence(BaseTest):)first_id, custom_id = (record["id"] for record in row.items)self.assertIsNotNone(dismiss_suggestion(self.team.id, first_id, user_id=self.user.id))- self.assertIsNotNone(mark_suggestion_created(self.team.id, custom_id, config_id="cfg-1"))+ self.assertIsNotNone(+ mark_suggestion_created(+ self.team.id, custom_id, kind="custom", config_id="cfg-1", skill_name="signals-scout-checkout-drop"+ )+ )row.refresh_from_db()self.assertEqual(visible_items(row), [])@@ -975,13 +979,38 @@ class TestScoutSuggestionsAPI(APIBaseTest):config = SignalScoutConfig.all_teams.get(team=self.team, skill_name="signals-scout-checkout-drop")self.assertEqual(created["created_config_id"], str(config.id))- def test_a_suggestion_id_only_marks_the_draft_it_names(self):- # A client can send any id it holds; only the draft the new scout was made from is retired.+ def test_a_renamed_draft_is_still_marked_with_its_final_name(self):row = persist_suggestion_batch(self.team.id, [_item(), _custom()], task_run_id=None, model="m", fleet_snapshot=[])suggestion_id = next(item["id"] for item in row.items if item["kind"] == "custom")+ response = self.client.post(+ f"/api/projects/{self.team.id}/signals/scout/",+ {+ "name": "signals-scout-checkout-renamed",+ "description": "Watches the checkout funnel.",+ "body": "# Checkout drop\n\nCheck the checkout funnel daily.",+ "suggestion_id": suggestion_id,+ },+ format="json",+ )++ self.assertEqual(response.status_code, status.HTTP_201_CREATED)+ row.refresh_from_db()+ created = next(item for item in row.items if item["id"] == suggestion_id)+ self.assertEqual(created["created_config_id"], response.json()["config"]["id"])+ self.assertEqual(created["created_skill_name"], "signals-scout-checkout-renamed")+ body = self.client.get(f"/api/projects/{self.team.id}/signals/scout/suggestions/").json()+ self.assertNotIn(suggestion_id, [item["id"] for item in body["items"]])++ def test_a_create_does_not_mark_a_canonical_suggestion(self):+ # A canonical pick becomes a scout by turning its config on, so a create naming one is not it.+ row = persist_suggestion_batch(+ self.team.id, [_item(), _custom()], task_run_id=None, model="m", fleet_snapshot=[]+ )+ suggestion_id = next(item["id"] for item in row.items if item["kind"] == "canonical")+response = self.client.post(f"/api/projects/{self.team.id}/signals/scout/",{@@ -998,6 +1027,32 @@ class TestScoutSuggestionsAPI(APIBaseTest):untouched = next(item for item in row.items if item["id"] == suggestion_id)self.assertIsNone(untouched["created_config_id"])+ @parameterized.expand(+ [+ ("turned_on", "signals-scout-error-tracking", True, True),+ ("left_off", "signals-scout-error-tracking", False, False),+ ("another_scout", "signals-scout-web-vitals", True, False),+ ]+ )+ def test_turning_on_a_canonical_suggestion_marks_it(self, _name, skill_name, enabled, marked):+ row = persist_suggestion_batch(+ self.team.id, [_item(), _custom()], task_run_id=None, model="m", fleet_snapshot=[]+ )+ suggestion_id = next(item["id"] for item in row.items if item["kind"] == "canonical")+ config = SignalScoutConfig.objects.create(team=self.team, skill_name=skill_name, enabled=False)++ response = self.client.patch(+ f"/api/projects/{self.team.id}/signals/scout/configs/{config.id}/",+ {"enabled": enabled, "suggestion_id": suggestion_id},+ format="json",+ )++ self.assertEqual(response.status_code, status.HTTP_200_OK)+ self.assertNotIn("suggestion_id", response.json())+ row.refresh_from_db()+ item = next(item for item in row.items if item["id"] == suggestion_id)+ self.assertEqual(item["created_config_id"], str(config.id) if marked else None)+def test_an_unknown_suggestion_id_still_creates_the_scout(self):# The batch can compact a record away between the strip reading it and the create landing;# losing the scout over a bookkeeping id would be the worse failure.diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.tsindex 56224b460005..c420629a3a88 100644--- a/products/signals/frontend/generated/api.schemas.ts+++ b/products/signals/frontend/generated/api.schemas.ts@@ -3840,6 +3840,11 @@ export interface PatchedSignalScoutConfigUpdateApi {* @maxItems 10*/write_scopes?: string[]+ /**+ * Optional id of the canonical scout suggestion this request turns on. It records that the scout came from that suggestion. An id this project's batch does not hold is ignored.+ * @maxLength 64+ */+ suggestion_id?: string}/**diff --git a/products/signals/frontend/generated/api.zod.ts b/products/signals/frontend/generated/api.zod.tsindex f0ec09b978c2..67b97ed56a96 100644--- a/products/signals/frontend/generated/api.zod.ts+++ b/products/signals/frontend/generated/api.zod.ts@@ -1105,6 +1105,8 @@ export const signalsScoutConfigUpdateBodyRepositoriesMax = 10export const signalsScoutConfigUpdateBodyWriteScopesMax = 10+export const signalsScoutConfigUpdateBodySuggestionIdMax = 64+export const SignalsScoutConfigUpdateBody = /* @__PURE__ */ zod.object({display_name: zod@@ -1257,6 +1259,13 @@ export const SignalsScoutConfigUpdateBody = /* @__PURE__ */ zod.describe("Extra write access granted to this one scout, as scope strings. The grantable set is `alert:write`, `annotation:write`, `customer_task:write`, `dashboard:write`, `hog_flow_proposal:write`, `insight:write`, `llm_skill:write`, `replay_scanner:write`, `warehouse_table:write`, `warehouse_view:write`. Empty (the default) means the scout reads the project and writes only what every scout may write: notebooks, its findings, and its own memory. Each scope is project-wide and object-level, so a scout holding `dashboard:write` can update or delete any dashboard in the project, not only ones it made. Grant only what this scout maintains. Only the person the scout's runs act as (whoever authored it) or a project admin can set it, and a scoped API key must itself carry each scope it grants. A dry run (`emit=false`) never holds the grant. Applies from the scout's next run."),+ suggestion_id: zod+ .string()+ .max(signalsScoutConfigUpdateBodySuggestionIdMax)+ .optional()+ .describe(+ "Optional id of the canonical scout suggestion this request turns on. It records that the scout came from that suggestion. An id this project's batch does not hold is ignored."+ ),}).describe('Editable display name, schedule, enablement, and emit posture for one scout config.')diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionCreateHost.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionCreateHost.tsxindex be8392b9aa21..fac48eef7eda 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionCreateHost.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutSuggestionCreateHost.tsx@@ -1,5 +1,7 @@import { useActions, useValues } from 'kea'+import type { SignalScoutConfigApi } from 'products/signals/frontend/generated/api.schemas'+import type { ScoutSuggestionSurface } from '../../../inboxAnalytics'import { scoutFleetLogic } from '../../../logics/scoutFleetLogic'import { scoutSuggestionsLogic } from '../../../logics/scoutSuggestionsLogic'@@ -17,9 +19,9 @@ export function ScoutSuggestionCreateHost({ surface }: { surface: ScoutSuggestioconst { closeCreateFromSuggestion, suggestionCreated } = useActions(scoutSuggestionsLogic)const { loadScoutConfigs } = useActions(scoutFleetLogic)- const handleDone = (): void => {+ const handleDone = (config: SignalScoutConfigApi): void => {if (createFromSuggestion) {- suggestionCreated(createFromSuggestion.item, surface)+ suggestionCreated(createFromSuggestion.item, surface, config)}loadScoutConfigs()}@@ -32,7 +34,7 @@ export function ScoutSuggestionCreateHost({ surface }: { surface: ScoutSuggestio: null}onClose={closeCreateFromSuggestion}- onCreated={handleDone}+ onCreated={(scout) => handleDone(scout.config)}onEnabled={handleDone}/>)diff --git a/products/signals/frontend/inbox/inboxAnalytics.ts b/products/signals/frontend/inbox/inboxAnalytics.tsindex 2e0441599e21..0cc4165a3df9 100644--- a/products/signals/frontend/inbox/inboxAnalytics.ts+++ b/products/signals/frontend/inbox/inboxAnalytics.ts@@ -936,6 +936,9 @@ export type ScoutSuggestionKind = 'canonical' | 'custom'/** What the person did with a suggestion card, beyond creating or dismissing it. */export type ScoutSuggestionClickTarget = 'turn_on' | 'create' | 'refine_with_ai'+/** What the person did with the strip itself. Desktop sends the same values as click targets. */+export type ScoutSuggestionsStripClickTarget = 'expand' | 'collapse' | 'close'+/** What the person pressed to reach that target: the action row's button, or the card body. */export type ScoutSuggestionClickVia = 'button' | 'card'@@ -971,6 +974,7 @@ export function captureScoutSuggestionsShown(params: {/** One of a suggestion card's actions was pressed. `via` separates the card body from the button. */export function captureScoutSuggestionClicked(params: {+ suggestionId: stringkind: ScoutSuggestionKindskillName: stringtarget: ScoutSuggestionClickTarget@@ -978,6 +982,7 @@ export function captureScoutSuggestionClicked(params: {surface: ScoutSuggestionSurface}): void {captureInboxEvent(INBOX_EVENTS.SCOUT_SUGGESTION_CLICKED, {+ suggestion_id: params.suggestionId,suggestion_kind: params.kind,skill_name: params.skillName,click_target: params.target,@@ -986,14 +991,38 @@ export function captureScoutSuggestionClicked(params: {})}-/** A suggestion turned into a running scout. `via` separates the one-click paths from the chat. */+/**+ * The strip was expanded, collapsed or closed. It opens collapsed, so an expand is what shows that+ * a person saw the cards and their buttons. It names no suggestion, because it acts on all of them.+ */+export function captureScoutSuggestionsStripClicked(params: {+ target: ScoutSuggestionsStripClickTarget+ count: number+ status: string+}): void {+ captureInboxEvent(INBOX_EVENTS.SCOUT_SUGGESTION_CLICKED, {+ click_target: params.target,+ suggestion_count: params.count,+ batch_status: params.status,+ surface: 'strip' satisfies ScoutSuggestionSurface,+ })+}++/**+ * A suggestion turned into a running scout. `via` separates the one-click paths from the chat.+ * `skillName` is the scout's final name, which a custom draft can change in the form.+ */export function captureScoutSuggestionCreated(params: {+ suggestionId: string+ configId: stringkind: ScoutSuggestionKindskillName: stringvia: ScoutSuggestionCreatedViasurface: ScoutSuggestionSurface}): void {captureInboxEvent(INBOX_EVENTS.SCOUT_SUGGESTION_CREATED, {+ suggestion_id: params.suggestionId,+ config_id: params.configId,suggestion_kind: params.kind,skill_name: params.skillName,via: params.via,@@ -1003,11 +1032,13 @@ export function captureScoutSuggestionCreated(params: {/** A suggestion was hidden. Dismissals are remembered by skill name, so this is the rejection signal. */export function captureScoutSuggestionDismissed(params: {+ suggestionId: stringkind: ScoutSuggestionKindskillName: stringsurface: ScoutSuggestionSurface}): void {captureInboxEvent(INBOX_EVENTS.SCOUT_SUGGESTION_DISMISSED, {+ suggestion_id: params.suggestionId,suggestion_kind: params.kind,skill_name: params.skillName,surface: params.surface,diff --git a/products/signals/frontend/inbox/logics/scoutCreateModalLogic.ts b/products/signals/frontend/inbox/logics/scoutCreateModalLogic.tsindex df3fbdcc1be2..bec5d361e18a 100644--- a/products/signals/frontend/inbox/logics/scoutCreateModalLogic.ts+++ b/products/signals/frontend/inbox/logics/scoutCreateModalLogic.ts@@ -428,6 +428,7 @@ export const scoutCreateModalLogic: LogicWrapper<scoutCreateModalLogicType> = keconst config = await signalsScoutConfigUpdate(String(values.currentTeamId), existingConfigId, {...runSettings,enabled: true,+ suggestion_id: logicProps.initialValues?.suggestionId,})actions.resetScoutCreateForm()actions.resetMcpServersDefaulted()diff --git a/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.ts b/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.tsindex 9726c994eac6..218bac6b1e8f 100644--- a/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.ts+++ b/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.ts@@ -471,4 +471,58 @@ describe('scoutSuggestionsLogic', () => {expect(logic.values.stripHidden).toBe(false)expect(logic.values.collapsed).toBe(false)})++ it('reports each expand, collapse and close of the strip once, and nothing for a remembered state', async () => {+ await mountWithBatch()+ ;(posthog.capture as jest.Mock).mockClear()++ logic.actions.setCollapsed(false)+ logic.actions.setCollapsed(true)+ logic.actions.hideStrip()++ const clicks = (posthog.capture as jest.Mock).mock.calls.filter(+ ([event]) => event === INBOX_EVENTS.SCOUT_SUGGESTION_CLICKED+ )+ expect(clicks.map(([, properties]) => properties)).toEqual(+ ['expand', 'collapse', 'close'].map((target) =>+ expect.objectContaining({+ click_target: target,+ suggestion_count: 2,+ batch_status: 'fresh',+ surface: 'strip',+ })+ )+ )+ expect(clicks[0][1]).not.toHaveProperty('skill_name')++ // A reload restores the closed strip from storage, and that is not a press.+ logic.unmount()+ ;(posthog.capture as jest.Mock).mockClear()+ await mountWithBatch()+ expect(logic.values.stripHidden).toBe(true)+ expect(+ (posthog.capture as jest.Mock).mock.calls.filter(+ ([event]) => event === INBOX_EVENTS.SCOUT_SUGGESTION_CLICKED+ )+ ).toEqual([])+ })++ it('ties a created scout to its suggestion and config, under the name it was created with', async () => {+ await mountWithBatch()+ ;(posthog.capture as jest.Mock).mockClear()++ logic.actions.suggestionCreated(CUSTOM_ITEM, 'strip', { ...CONFIG, id: 'config-9', skill_name: 'renamed' })++ const created = (posthog.capture as jest.Mock).mock.calls.filter(+ ([event]) => event === INBOX_EVENTS.SCOUT_SUGGESTION_CREATED+ )+ expect(created.map(([, properties]) => properties)).toEqual([+ expect.objectContaining({+ suggestion_id: CUSTOM_ITEM.id,+ config_id: 'config-9',+ skill_name: 'renamed',+ suggestion_kind: 'custom',+ }),+ ])+ })})diff --git a/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.ts b/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.tsindex 1683ba1ea5c2..fe7860f0c6ba 100644--- a/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.ts+++ b/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.ts@@ -19,6 +19,7 @@ import {import type { ScoutSuggestionItemApi, ScoutSuggestionSetApi } from 'products/signals/frontend/generated/api.schemas'import { llmSkillsNameRetrieve } from 'products/skills/frontend/generated/api'+import type { SignalScoutConfigApi } from '../../generated/api.schemas'import {captureScoutSuggestionClicked,captureScoutSuggestionCreated,@@ -26,6 +27,7 @@ import {captureScoutSuggestionsChatOpened,captureScoutSuggestionsRefreshed,captureScoutSuggestionsShown,+ captureScoutSuggestionsStripClicked,ScoutSuggestionKind,ScoutSuggestionSurface,} from '../inboxAnalytics'@@ -218,8 +220,10 @@ export interface scoutSuggestionsLogicActions {}suggestionCreated: (item: ScoutSuggestionItemApi,- surface: ScoutSuggestionSurface+ surface: ScoutSuggestionSurface,+ config: SignalScoutConfig) => {+ config: SignalScoutConfigApiitem: ScoutSuggestionItemApisurface: ScoutSuggestionSurface}@@ -231,7 +235,7 @@ export interface scoutSuggestionsLogicMeta {suggestions: (suggestionSet: ScoutSuggestionSetApi | null,hiddenSuggestionIds: string[],- scoutConfigs: import('products/signals/frontend/generated/api.schemas').SignalScoutConfigApi[] | null+ scoutConfigs: SignalScoutConfigApi[] | null) => ScoutSuggestionItemApi[]batchStatus: (suggestionSet: ScoutSuggestionSetApi | null) => stringbatchAgeHours: (suggestionSet: ScoutSuggestionSetApi | null) => number | null@@ -309,7 +313,15 @@ export const scoutSuggestionsLogic = kea<scoutSuggestionsLogicType>([) => ({ item, surface, via }),closeCreateFromSuggestion: true,askForSuggestions: true,- suggestionCreated: (item: ScoutSuggestionItemApi, surface: ScoutSuggestionSurface) => ({ item, surface }),+ suggestionCreated: (+ item: ScoutSuggestionItemApi,+ surface: ScoutSuggestionSurface,+ config: SignalScoutConfig+ ) => ({+ item,+ surface,+ config,+ }),requestRefresh: (source: ScoutSuggestionsRefreshSource) => ({ source }),refreshRequestRefused: true,refreshFinished: true,@@ -519,6 +531,7 @@ export const scoutSuggestionsLogic = kea<scoutSuggestionsLogicType>([await signalsScoutSuggestionsDismiss(String(teamId), item.id)// Reported once the server holds it, so a failed dismissal is not counted as one.captureScoutSuggestionDismissed({+ suggestionId: item.id,kind: suggestionKind(item),skillName: item.skill_name,surface,@@ -536,6 +549,7 @@ export const scoutSuggestionsLogic = kea<scoutSuggestionsLogicType>([},refineSuggestionWithAi: async ({ item, surface }) => {captureScoutSuggestionClicked({+ suggestionId: item.id,kind: suggestionKind(item),skillName: item.skill_name,target: 'refine_with_ai',@@ -562,6 +576,7 @@ export const scoutSuggestionsLogic = kea<scoutSuggestionsLogicType>([},openCreateFromSuggestion: async ({ item, surface, via }) => {captureScoutSuggestionClicked({+ suggestionId: item.id,kind: suggestionKind(item),skillName: item.skill_name,target: item.kind === 'canonical' ? 'turn_on' : 'create',@@ -600,18 +615,36 @@ export const scoutSuggestionsLogic = kea<scoutSuggestionsLogicType>([actions.suggestionActionFinished(item.id)}},- suggestionCreated: ({ item, surface }) => {+ suggestionCreated: ({ item, surface, config }) => {// Both one-click paths land here — turning a canonical scout on, and a custom draft// coming back from the create modal. A refinement chat only opens on the draft, so it// is a click, not a creation.captureScoutSuggestionCreated({+ suggestionId: item.id,+ configId: config.id,kind: suggestionKind(item),- skillName: item.skill_name,+ skillName: config.skill_name,via: 'api',surface,})actions.loadSuggestions()},+ // Only the strip's own buttons dispatch these. A remembered state comes back through+ // persistence, which dispatches no action, so a reload reports nothing.+ setCollapsed: ({ collapsed }) => {+ captureScoutSuggestionsStripClicked({+ target: collapsed ? 'collapse' : 'expand',+ count: values.suggestions.length,+ status: values.batchStatus,+ })+ },+ hideStrip: () => {+ captureScoutSuggestionsStripClicked({+ target: 'close',+ count: values.suggestions.length,+ status: values.batchStatus,+ })+ },reportSuggestionsShown: ({ surface }) => {captureScoutSuggestionsShown({count: values.suggestions.length,diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 2890ecc7184a..9e9023c3c7ac 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -80506,6 +80506,11 @@ export namespace Schemas {* @maxItems 10*/write_scopes?: string[];+ /**+ * Optional id of the canonical scout suggestion this request turns on. It records that the scout came from that suggestion. An id this project's batch does not hold is ignored.+ * @maxLength 64+ */+ suggestion_id?: string;}/**diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.tsindex c9155fd283ef..58506bcae1ac 100644--- a/services/mcp/src/generated/signals/api.ts+++ b/services/mcp/src/generated/signals/api.ts@@ -1144,6 +1144,8 @@ export const signalsScoutConfigUpdateBodyRepositoriesMax = 10export const signalsScoutConfigUpdateBodyWriteScopesMax = 10+export const signalsScoutConfigUpdateBodySuggestionIdMax = 64+export const SignalsScoutConfigUpdateBody = () => zod.object({display_name: zod@@ -1296,6 +1298,13 @@ export const SignalsScoutConfigUpdateBody = () => zod.describe("Extra write access granted to this one scout, as scope strings. The grantable set is `alert:write`, `annotation:write`, `customer_task:write`, `dashboard:write`, `hog_flow_proposal:write`, `insight:write`, `llm_skill:write`, `replay_scanner:write`, `warehouse_table:write`, `warehouse_view:write`. Empty (the default) means the scout reads the project and writes only what every scout may write: notebooks, its findings, and its own memory. Each scope is project-wide and object-level, so a scout holding `dashboard:write` can update or delete any dashboard in the project, not only ones it made. Grant only what this scout maintains. Only the person the scout's runs act as (whoever authored it) or a project admin can set it, and a scoped API key must itself carry each scope it grants. A dry run (`emit=false`) never holds the grant. Applies from the scout's next run."),+ suggestion_id: zod+ .string()+ .max(signalsScoutConfigUpdateBodySuggestionIdMax)+ .optional()+ .describe(+ "Optional id of the canonical scout suggestion this request turns on. It records that the scout came from that suggestion. An id this project's batch does not hold is ignored."+ ),}).describe('Editable display name, schedule, enablement, and emit posture for one scout config.')diff --git a/services/mcp/src/tools/generated/signals.ts b/services/mcp/src/tools/generated/signals.tsindex f4221eb7e3a7..251600ad4abe 100644--- a/services/mcp/src/tools/generated/signals.ts+++ b/services/mcp/src/tools/generated/signals.ts@@ -953,6 +953,9 @@ const scoutConfigUpdate = (): ToolBase<if (params.write_scopes !== undefined) {body['write_scopes'] = params.write_scopes}+ if (params.suggestion_id !== undefined) {+ body['suggestion_id'] = params.suggestion_id+ }const result = await context.api.request<Schemas.SignalScoutConfig>({method: 'PATCH',path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/scout/configs/${encodeURIComponent(String(params.id))}/`,@@ -1933,6 +1936,9 @@ const signalsScoutConfigUpdate = (): ToolBase<if (params.write_scopes !== undefined) {body['write_scopes'] = params.write_scopes}+ if (params.suggestion_id !== undefined) {+ body['suggestion_id'] = params.suggestion_id+ }const result = await context.api.request<Schemas.SignalScoutConfig>({method: 'PATCH',path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/scout/configs/${encodeURIComponent(String(params.id))}/`,diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.jsonindex ec615f642641..ff9811416593 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.json@@ -166,6 +166,11 @@],"description": "Optional JSON Schema (draft 2020-12) describing ONE structured record this scout produces via `scout-record-output` — e.g. a per-report quality judgment (`{\"type\": \"object\", \"properties\": {\"verdict\": {\"enum\": [\"good\", \"bad\", \"unsure\"]}, \"reason\": {\"type\": \"string\"}}, \"required\": [\"verdict\", \"reason\"]}`). The root must be `\"type\": \"object\"`. Setting a schema turns the structured-output channel on: the run prompt renders the schema and every submitted record is validated against it and recorded in the project as a `$scout_structured_output` event, queryable like any event. The channel also requires emit — a dry-run scout has nowhere to record to. Cardinality is the scout's call (one record per run, one per judged entity, ...). Null = channel off. Setting a schema requires skill-authoring authorization (the `llm_skill:write` scope and skill editor access) since the scout reads it verbatim in its prompt; clearing it needs only the config write. Records validate against the schema in force when the run was dispatched."},+ "suggestion_id": {+ "description": "Optional id of the canonical scout suggestion this request turns on. It records that the scout came from that suggestion. An id this project's batch does not hold is ignored.",+ "maxLength": 64,+ "type": "string"+ },"tags": {"description": "Free-form labels for grouping the fleet, e.g. `[\"revenue\", \"on-call\"]`. Normalized to lowercase kebab-case (`On Call` and `on_call` both become `on-call`), deduped, and stored sorted; at most 10 tags, each at most 50 characters once normalized. Pass the full desired set — a write replaces the existing tags rather than merging into them. Filter the config list with the `tags` query parameter.","items": {diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.jsonindex ec615f642641..ff9811416593 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.json@@ -166,6 +166,11 @@],"description": "Optional JSON Schema (draft 2020-12) describing ONE structured record this scout produces via `scout-record-output` — e.g. a per-report quality judgment (`{\"type\": \"object\", \"properties\": {\"verdict\": {\"enum\": [\"good\", \"bad\", \"unsure\"]}, \"reason\": {\"type\": \"string\"}}, \"required\": [\"verdict\", \"reason\"]}`). The root must be `\"type\": \"object\"`. Setting a schema turns the structured-output channel on: the run prompt renders the schema and every submitted record is validated against it and recorded in the project as a `$scout_structured_output` event, queryable like any event. The channel also requires emit — a dry-run scout has nowhere to record to. Cardinality is the scout's call (one record per run, one per judged entity, ...). Null = channel off. Setting a schema requires skill-authoring authorization (the `llm_skill:write` scope and skill editor access) since the scout reads it verbatim in its prompt; clearing it needs only the config write. Records validate against the schema in force when the run was dispatched."},+ "suggestion_id": {+ "description": "Optional id of the canonical scout suggestion this request turns on. It records that the scout came from that suggestion. An id this project's batch does not hold is ignored.",+ "maxLength": 64,+ "type": "string"+ },"tags": {"description": "Free-form labels for grouping the fleet, e.g. `[\"revenue\", \"on-call\"]`. Normalized to lowercase kebab-case (`On Call` and `on_call` both become `on-call`), deduped, and stored sorted; at most 10 tags, each at most 50 characters once normalized. Pass the full desired set — a write replaces the existing tags rather than merging into them. Filter the config list with the `tags` query parameter.","items": {