: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): surface scout description on config API/MCP surface (#62853)
Andrew Maguirecaed8e7baff3
diff --git a/products/signals/backend/scout_harness/serializers.py b/products/signals/backend/scout_harness/serializers.pyindex 84e369defed2..7934ab265ede 100644--- a/products/signals/backend/scout_harness/serializers.py+++ b/products/signals/backend/scout_harness/serializers.py@@ -8,6 +8,8 @@ in `scout_harness/tools/` so the wire shape and Python shape stay in lockstep.from __future__ import annotations+from drf_spectacular.types import OpenApiTypes+from drf_spectacular.utils import extend_schema_fieldfrom rest_framework import serializersfrom posthog.schema import Severity@@ -945,6 +947,14 @@ class SignalScoutConfigSerializer(serializers.ModelSerializer):read_only=True,help_text="The `signals-scout-*` skill this config controls. Set at creation, not editable.",)+ description = serializers.SerializerMethodField(+ help_text=(+ "Human-readable summary of what this scout investigates, sourced from the scout "+ "skill's `description` metadata. Use it for a quick steer on the scout's focus "+ "without loading the full skill body. Empty if the skill is not currently present "+ "on the team or carries no description."+ ),+ )enabled = serializers.BooleanField(required=False,help_text="Whether this scout runs on its schedule. Disabled scouts are skipped by the coordinator.",@@ -965,7 +975,23 @@ class SignalScoutConfigSerializer(serializers.ModelSerializer):help_text="When the coordinator last dispatched this scout. Null if it has never run.",)+ @extend_schema_field(OpenApiTypes.STR)+ def get_description(self, obj: SignalScoutConfig) -> str:+ # Resolved by the view into `skill_descriptions` (skill_name -> description) so the+ # list endpoint stays a single LLMSkill query rather than one lookup per config row.+ descriptions = self.context.get("skill_descriptions") or {}+ return descriptions.get(obj.skill_name, "")+class Meta:model = SignalScoutConfig- fields = ["id", "skill_name", "enabled", "emit", "run_interval_minutes", "last_run_at", "created_at"]+ fields = [+ "id",+ "skill_name",+ "description",+ "enabled",+ "emit",+ "run_interval_minutes",+ "last_run_at",+ "created_at",+ ]read_only_fields = ["id", "created_at"]diff --git a/products/signals/backend/scout_harness/views.py b/products/signals/backend/scout_harness/views.pyindex 1fa64b882bca..95bb9d6298df 100644--- a/products/signals/backend/scout_harness/views.py+++ b/products/signals/backend/scout_harness/views.py@@ -40,6 +40,7 @@ from posthog.api.routing import TeamAndOrgViewSetMixinfrom posthog.auth import OAuthAccessTokenAuthentication, PersonalAPIKeyAuthentication, SessionAuthenticationfrom posthog.permissions import APIScopePermission+from products.ai_observability.backend.models.skills import LLMSkillfrom products.signals.backend.models import SignalProjectProfile, SignalScoutConfig, SignalScoutEmission, SignalScoutRunfrom products.signals.backend.scout_harness.serializers import (EmitFindingRequestSerializer,@@ -568,6 +569,22 @@ class SignalProjectProfileViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSereturn Response(ProjectProfileSerializer(profile.as_dict()).data)+def _skill_descriptions_for(team_id: int, skill_names: list[str]) -> dict[str, str]:+ """Map each scout `skill_name` to the latest `LLMSkill.description` on the team.++ One query for the whole config list — feeds the serializer's `description` field so+ callers get a quick steer on each scout without loading the full skill body. Skills the+ team no longer has simply drop out of the map (serializer falls back to "").+ """+ names = list(set(skill_names))+ if not names:+ return {}+ rows = LLMSkill.objects.filter(team_id=team_id, name__in=names, is_latest=True, deleted=False).values_list(+ "name", "description"+ )+ return dict(rows)++class SignalScoutConfigViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):"""Per-scout config: list and tune each scout's schedule, enablement, and emit posture.@@ -599,8 +616,11 @@ class SignalScoutConfigViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):operation_id="signals_scout_config_list",)def list(self, request: Request, *args, **kwargs) -> Response:- configs = SignalScoutConfig.objects.unscoped().filter(team_id=_canonical_team_id(self)).order_by("skill_name")- return Response(SignalScoutConfigSerializer(configs, many=True).data)+ team_id = _canonical_team_id(self)+ configs = list(SignalScoutConfig.objects.unscoped().filter(team_id=team_id).order_by("skill_name"))+ descriptions = _skill_descriptions_for(team_id, [c.skill_name for c in configs])+ serializer = SignalScoutConfigSerializer(configs, many=True, context={"skill_descriptions": descriptions})+ return Response(serializer.data)@extend_schema(request=SignalScoutConfigSerializer,@@ -617,8 +637,9 @@ class SignalScoutConfigViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):operation_id="signals_scout_config_update",)def partial_update(self, request: Request, *args, **kwargs) -> Response:+ team_id = _canonical_team_id(self)config_id = _parse_run_id_or_404(kwargs)- config = SignalScoutConfig.objects.unscoped().filter(team_id=_canonical_team_id(self), id=config_id).first()+ config = SignalScoutConfig.objects.unscoped().filter(team_id=team_id, id=config_id).first()if config is None:raise exceptions.NotFound()serializer = SignalScoutConfigSerializer(config, data=request.data, partial=True)@@ -628,4 +649,5 @@ class SignalScoutConfigViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):if not config.enabled and serializer.validated_data.get("enabled"):save_kwargs["enabled_by"] = request.userinstance = serializer.save(**save_kwargs)- return Response(SignalScoutConfigSerializer(instance).data)+ descriptions = _skill_descriptions_for(team_id, [instance.skill_name])+ return Response(SignalScoutConfigSerializer(instance, context={"skill_descriptions": descriptions}).data)diff --git a/products/signals/backend/test/test_scout_harness_api.py b/products/signals/backend/test/test_scout_harness_api.pyindex 340d319477ed..8b3531598209 100644--- a/products/signals/backend/test/test_scout_harness_api.py+++ b/products/signals/backend/test/test_scout_harness_api.py@@ -15,6 +15,7 @@ from posthog.temporal.oauth import (create_oauth_access_token_for_user,)+from products.ai_observability.backend.models.skills import LLMSkillfrom products.signals.backend.models import (SignalProjectProfile,SignalScoutConfig,@@ -587,6 +588,59 @@ class TestScoutHarnessConfigAPI(APIBaseTest):assert body[0]["emit"] is Trueassert body[0]["run_interval_minutes"] == 60+ @parameterized.expand(+ [+ ("skill_present", "Watches error tracking for new and spiking issues."),+ ("skill_absent", None),+ ]+ )+ def test_list_surfaces_skill_description(self, _name: str, skill_description: str | None) -> None:+ SignalScoutConfig.objects.create(team=self.team, skill_name="signals-scout-errors")+ if skill_description is not None:+ LLMSkill.objects.create(+ team=self.team, name="signals-scout-errors", description=skill_description, body="..."+ )++ response = self.client.get(self._list_url())++ assert response.status_code == status.HTTP_200_OK+ # Absent skill (or no description) falls back to "".+ assert response.json()[0]["description"] == (skill_description or "")++ def test_list_description_ignores_non_latest_and_other_team_skills(self) -> None:+ SignalScoutConfig.objects.create(team=self.team, skill_name="signals-scout-errors")+ LLMSkill.objects.create(+ team=self.team,+ name="signals-scout-errors",+ description="stale",+ body="...",+ version=1,+ is_latest=False,+ )+ LLMSkill.objects.create(+ team=self.team,+ name="signals-scout-errors",+ description="current",+ body="...",+ version=2,+ is_latest=True,+ )+ other_team = Team.objects.create(organization=self.organization, name="other")+ LLMSkill.objects.create(team=other_team, name="signals-scout-errors", description="other team", body="...")++ response = self.client.get(self._list_url())++ assert response.json()[0]["description"] == "current"++ def test_partial_update_surfaces_skill_description(self) -> None:+ config = SignalScoutConfig.objects.create(team=self.team, skill_name="signals-scout-foo", enabled=False)+ LLMSkill.objects.create(team=self.team, name="signals-scout-foo", description="Foo scout.", body="...")++ response = self.client.patch(self._detail_url(str(config.id)), data={"enabled": True}, format="json")++ assert response.status_code == status.HTTP_200_OK+ assert response.json()["description"] == "Foo scout."+def test_partial_update_changes_schedule_emit_and_records_enabled_by(self) -> None:config = SignalScoutConfig.objects.create(team=self.team, skill_name="signals-scout-foo", enabled=False)diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.tsindex 2b9a7d6c72db..4bc6cbc480a5 100644--- a/products/signals/frontend/generated/api.schemas.ts+++ b/products/signals/frontend/generated/api.schemas.ts@@ -151,6 +151,8 @@ export interface SignalScoutConfigApi {readonly id: string/** The `signals-scout-*` skill this config controls. Set at creation, not editable. */readonly skill_name: string+ /** Human-readable summary of what this scout investigates, sourced from the scout skill's `description` metadata. Use it for a quick steer on the scout's focus without loading the full skill body. Empty if the skill is not currently present on the team or carries no description. */+ readonly description: string/** Whether this scout runs on its schedule. Disabled scouts are skipped by the coordinator. */enabled?: boolean/** Whether the scout writes findings to the inbox. False = dry-run: it runs and logs but emits nothing. */@@ -179,6 +181,8 @@ export interface PatchedSignalScoutConfigApi {readonly id?: string/** The `signals-scout-*` skill this config controls. Set at creation, not editable. */readonly skill_name?: string+ /** Human-readable summary of what this scout investigates, sourced from the scout skill's `description` metadata. Use it for a quick steer on the scout's focus without loading the full skill body. Empty if the skill is not currently present on the team or carries no description. */+ readonly description?: string/** Whether this scout runs on its schedule. Disabled scouts are skipped by the coordinator. */enabled?: boolean/** Whether the scout writes findings to the inbox. False = dry-run: it runs and logs but emits nothing. */diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex e64d7b15c06f..d73ebfd1a1f9 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -33007,6 +33007,8 @@ export namespace Schemas {readonly id?: string;/** The `signals-scout-*` skill this config controls. Set at creation, not editable. */readonly skill_name?: string;+ /** Human-readable summary of what this scout investigates, sourced from the scout skill's `description` metadata. Use it for a quick steer on the scout's focus without loading the full skill body. Empty if the skill is not currently present on the team or carries no description. */+ readonly description?: string;/** Whether this scout runs on its schedule. Disabled scouts are skipped by the coordinator. */enabled?: boolean;/** Whether the scout writes findings to the inbox. False = dry-run: it runs and logs but emits nothing. */@@ -39591,6 +39593,8 @@ export namespace Schemas {readonly id: string;/** The `signals-scout-*` skill this config controls. Set at creation, not editable. */readonly skill_name: string;+ /** Human-readable summary of what this scout investigates, sourced from the scout skill's `description` metadata. Use it for a quick steer on the scout's focus without loading the full skill body. Empty if the skill is not currently present on the team or carries no description. */+ readonly description: string;/** Whether this scout runs on its schedule. Disabled scouts are skipped by the coordinator. */enabled?: boolean;/** Whether the scout writes findings to the inbox. False = dry-run: it runs and logs but emits nothing. */