Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(signals): add slug tags to scout emit with self-evolving per-scout vocabulary (#62843)

Andrew Maguire27c18efe0af4
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 219fc9bcd3ca..09d2c2863372 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -39500,6 +39500,13 @@
"skill_version": {
"type": "number"
},
+ "tags": {
+ "description": "Lowercase kebab-case slug tags (e.g. `cost-spike`) categorizing the finding. Each scout maintains and evolves its own vocabulary over time; the harness normalizes and caps these at emit.",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
"task_run_id": {
"description": "The `tasks.TaskRun` id the scout span ran inside. Join key into the `signals_scouts_runs` LLM-analytics view, which is keyed on `task_run_id` (the `scout_run_id` bridge row is not).",
"type": "string"
diff --git a/frontend/src/queries/schema/schema-signals.ts b/frontend/src/queries/schema/schema-signals.ts
index f6db6aa6e309..d2607e357c94 100644
--- a/frontend/src/queries/schema/schema-signals.ts
+++ b/frontend/src/queries/schema/schema-signals.ts
@@ -324,6 +324,9 @@ export interface SignalsScoutSignalExtra extends SignalExtraBase {
evidence: SignalsScoutEvidenceEntry[]
/** Free-form short keys the harness can use for cross-run dedupe. */
dedupe_keys?: string[]
+ /** Lowercase kebab-case slug tags (e.g. `cost-spike`) categorizing the finding. Each scout
+ * maintains and evolves its own vocabulary over time; the harness normalizes and caps these at emit. */
+ tags?: string[]
/** Optional time window the finding refers to. */
time_range?: {
date_from: string
diff --git a/posthog/schema.py b/posthog/schema.py
index 3692e621d3cd..fdee04e97fc8 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -4799,6 +4799,14 @@ class SignalsScoutSignalExtra(BaseModel):
severity: Severity | None = None
skill_name: str
skill_version: float
+ tags: list[str] | None = Field(
+ default=None,
+ description=(
+ "Lowercase kebab-case slug tags (e.g. `cost-spike`) categorizing the"
+ " finding. Each scout maintains and evolves its own vocabulary over time;"
+ " the harness normalizes and caps these at emit."
+ ),
+ )
task_run_id: str = Field(
...,
description=(
diff --git a/products/signals/backend/migrations/0037_signalscoutemission_tags.py b/products/signals/backend/migrations/0037_signalscoutemission_tags.py
new file mode 100644
index 000000000000..0a87a3f2492b
--- /dev/null
+++ b/products/signals/backend/migrations/0037_signalscoutemission_tags.py
@@ -0,0 +1,17 @@
+# Generated by Django 5.2.14 on 2026-06-11 06:47
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("signals", "0036_signalteamconfig_backfill_default_autostart_p2"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="signalscoutemission",
+ name="tags",
+ field=models.JSONField(blank=True, default=list),
+ ),
+ ]
diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txt
index 6a3b3b921a6e..a547de6422ab 100644
--- a/products/signals/backend/migrations/max_migration.txt
+++ b/products/signals/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0036_signalteamconfig_backfill_default_autostart_p2
+0037_signalscoutemission_tags
diff --git a/products/signals/backend/models.py b/products/signals/backend/models.py
index 9e227f0f1f92..0377b8b6f0da 100644
--- a/products/signals/backend/models.py
+++ b/products/signals/backend/models.py
@@ -587,6 +587,10 @@ class SignalScoutEmission(TeamScopedRootMixin, UUIDModel):
weight = models.FloatField()
confidence = models.FloatField()
severity = models.CharField(max_length=20, null=True, blank=True)
+ # Slug tags the scout attached to the finding (normalized lowercase kebab-case, capped at
+ # emit). This row is what feeds the per-scout tag-vocabulary feedback loop in the run prompt
+ # (`recent_tag_usage`), so the vocabulary derives from emitted behavior, not a maintained list.
+ tags = models.JSONField(default=list, blank=True)
# Deterministic `run:<run_id>:finding:<finding_id>` — the join key back into the signal store
# for the full embedding/grouping view of this finding.
source_id = models.CharField(max_length=200)
diff --git a/products/signals/backend/scout_harness/AGENTS.md b/products/signals/backend/scout_harness/AGENTS.md
index 03d27ee0aa9f..e6781864c478 100644
--- a/products/signals/backend/scout_harness/AGENTS.md
+++ b/products/signals/backend/scout_harness/AGENTS.md
@@ -110,6 +110,14 @@ one sandbox session → zero or more emitted signals.
`weight` is the pipeline's promotion knob, not a scout judgment — promotion is
governed by the `confidence` emit-gate (≥ ~0.65), dedupe, and the safety filter.
The scout-facing schema and skills carry no `weight` field.
+- Findings can carry `tags` — lowercase kebab-case category slugs, normalized and
+ capped by `normalize_tags` in `tools/emit.py`. Tags persist in the signal's
+ `extra.tags` (queryable in the signal store) and on the `SignalScoutEmission` row.
+ The vocabulary lives in the scout loop, not the harness: the base prompt's
+ _Tagging your findings_ section instructs each scout to maintain a
+ `tags:<domain>:taxonomy` scratchpad entry (read first-move like any memory, evolved
+ as categories emerge), and the emission rows are the queryable ground truth a scout
+ can audit its taxonomy against. The harness only normalizes, caps, and persists.
- Scratchpad entries and run history are read at prompt assembly time. The agent can
also write scratchpad entries mid-run via `remember` / `forget` — that's how a
specialist with no anomalies to chase records "no LLM activity here, close out
diff --git a/products/signals/backend/scout_harness/prompt.py b/products/signals/backend/scout_harness/prompt.py
index bc21e8fc7098..0eca9bbc48f7 100644
--- a/products/signals/backend/scout_harness/prompt.py
+++ b/products/signals/backend/scout_harness/prompt.py
@@ -77,10 +77,31 @@ When you call `signals-scout-emit-signal`:
- `confidence` ∈ [0, 1] — your certainty the finding is real. This is the emit
gate: below ~0.65, prefer a scratchpad entry over emitting.
- `evidence` — list of citations, capped at 20 entries.
+- `tags` — optional category slugs for the finding; see *Tagging your findings*
+ below.
- `finding_id` — a stable id for this finding, echoed into the signal for
traceability. It does NOT dedupe: emitting the same id twice creates two
signals, so emit each finding exactly once and never retry an emit.
+# Tagging your findings
+
+Attach 1-5 `tags` to each emit — lowercase kebab-case slugs naming the
+*category* of the finding (`cost-spike`, `silent-failure`, `tracking-gap`),
+not the specific entity (that's what `dedupe_keys` and evidence ids are for).
+Tags are how structure emerges from everything the scout fleet emits, and the
+vocabulary is yours to own and evolve:
+
+- **Keep your taxonomy in the scratchpad.** Maintain a `tags:<domain>:taxonomy`
+ entry listing your tags and what each means — your step-1 scratchpad search
+ surfaces it. Update it when you coin, rename, or retire a tag.
+- **Reuse before coining.** If an existing tag fits, use it — consistency is
+ what makes tags queryable. Coin a new slug when a genuinely new category
+ emerges; don't force a finding into an ill-fitting tag.
+- Your emitted tags are recorded per finding (visible via
+ `signals-scout-runs-emissions-list`), so you can audit actual usage against
+ your taxonomy if they drift.
+- Near-miss formats are normalized to slugs at emit, but aim for clean slugs.
+
# Writing the description (how it renders in the inbox)
Your `description` is rendered as GitHub-flavored markdown in the inbox and
diff --git a/products/signals/backend/scout_harness/serializers.py b/products/signals/backend/scout_harness/serializers.py
index 7934ab265ede..5a53523d1713 100644
--- a/products/signals/backend/scout_harness/serializers.py
+++ b/products/signals/backend/scout_harness/serializers.py
@@ -15,7 +15,11 @@ from rest_framework import serializers
from posthog.schema import Severity
from products.signals.backend.models import SignalScoutConfig, SignalScoutEmission
-from products.signals.backend.scout_harness.tools.emit import MAX_FINDING_ID_LENGTH
+from products.signals.backend.scout_harness.tools.emit import (
+ MAX_FINDING_ID_LENGTH,
+ MAX_TAG_LENGTH,
+ MAX_TAGS_PER_FINDING,
+)
from products.signals.backend.scout_harness.tools.scratchpad import MAX_SCRATCHPAD_CONTENT_LENGTH
# --- Run history -----------------------------------------------------------
@@ -133,6 +137,10 @@ class SignalScoutEmissionSerializer(serializers.ModelSerializer):
allow_null=True,
help_text="Optional severity tag — one of P0, P1, P2, P3, P4 — or null if the run didn't set one.",
)
+ tags = serializers.ListField(
+ child=serializers.CharField(),
+ help_text="Slug tags the scout attached to this finding (lowercase kebab-case, e.g. `cost-spike`). Empty list when the run set none.",
+ )
source_id = serializers.CharField(
help_text="Deterministic `run:<run_id>:finding:<finding_id>` — the join key into the underlying signal store.",
)
@@ -148,6 +156,7 @@ class SignalScoutEmissionSerializer(serializers.ModelSerializer):
"weight",
"confidence",
"severity",
+ "tags",
"source_id",
"emitted_at",
]
@@ -346,6 +355,17 @@ class EmitFindingRequestSerializer(serializers.Serializer):
required=False,
help_text="Optional keys for downstream dedupe (e.g. `error_tracking_issue:<id>`).",
)
+ tags = serializers.ListField(
+ child=serializers.CharField(max_length=MAX_TAG_LENGTH),
+ required=False,
+ max_length=MAX_TAGS_PER_FINDING,
+ help_text=(
+ "Optional category tags as lowercase kebab-case slugs (e.g. `cost-spike`, `silent-failure`), "
+ f"max {MAX_TAGS_PER_FINDING}. Reuse the vocabulary in your `tags:<domain>:taxonomy` scratchpad entry "
+ "when a tag fits; coin a new slug when a genuinely new category emerges. Near-miss formats are "
+ "normalized to slugs; persisted in the signal's `extra.tags` and on the emission row."
+ ),
+ )
time_range = TimeRangeSerializer(
required=False,
allow_null=True,
diff --git a/products/signals/backend/scout_harness/tools/__init__.py b/products/signals/backend/scout_harness/tools/__init__.py
index 86bab9fa8d1b..84274aec452f 100644
--- a/products/signals/backend/scout_harness/tools/__init__.py
+++ b/products/signals/backend/scout_harness/tools/__init__.py
@@ -7,10 +7,13 @@ sandbox. Each tool is team-scoped and Postgres-backed.
from products.signals.backend.scout_harness.tools.emit import (
MAX_EVIDENCE_ENTRIES,
+ MAX_TAG_LENGTH,
+ MAX_TAGS_PER_FINDING,
EmitResult,
EvidenceEntry,
InvalidEmitError,
emit_finding,
+ normalize_tags,
)
from products.signals.backend.scout_harness.tools.profile import (
PROFILE_TTL,
@@ -42,6 +45,8 @@ __all__ = [
"InvalidScratchpadError",
"MAX_EVIDENCE_ENTRIES",
"MAX_RUN_SEARCH_LIMIT",
+ "MAX_TAG_LENGTH",
+ "MAX_TAGS_PER_FINDING",
"PROFILE_TTL",
"ProjectProfile",
"ScratchpadEntry",
@@ -52,6 +57,7 @@ __all__ = [
"forget",
"get_project_profile",
"get_run",
+ "normalize_tags",
"remember",
"search_scratchpad",
"search_recent_runs",
diff --git a/products/signals/backend/scout_harness/tools/emit.py b/products/signals/backend/scout_harness/tools/emit.py
index c3395a18e394..6b4ff048a645 100644
--- a/products/signals/backend/scout_harness/tools/emit.py
+++ b/products/signals/backend/scout_harness/tools/emit.py
@@ -25,6 +25,7 @@ in `products/signals/backend/api.py` validates against.
from __future__ import annotations
+import re
import uuid
import logging
from dataclasses import asdict, dataclass
@@ -53,6 +54,16 @@ MAX_EVIDENCE_ENTRIES = 20
# (default 1.0) immediately. See products/signals/backend/scout_harness/AGENTS.md.
SCOUT_SIGNAL_WEIGHT = 1.0
+# Tags are slugs: lowercase kebab-case so the per-scout vocabulary converges instead of
+# fragmenting on casing/punctuation (`cost_spike` vs `Cost Spike` vs `cost-spike`). The
+# harness normalizes rather than rejects near-misses — agents shouldn't burn a turn on a
+# formatting 400 — but an unsalvageable tag (empty after normalization, or overlong) is a
+# hard error so the vocabulary never accretes junk entries.
+MAX_TAGS_PER_FINDING = 10
+MAX_TAG_LENGTH = 50
+_TAG_INVALID_CHARS = re.compile(r"[^a-z0-9-]+")
+_TAG_HYPHEN_RUNS = re.compile(r"-{2,}")
+
# Cap on a caller-supplied `finding_id`. The deterministic `source_id` is
# `run:<uuid>:finding:<finding_id>` (~49 fixed chars), and both `finding_id` and `source_id`
# persist in 200-char columns — so an unbounded id would overflow them, fail the emission insert
@@ -110,6 +121,7 @@ async def emit_finding(
time_range: tuple[str, str] | None = None,
mcp_trace_id: str | None = None,
finding_id: str | None = None,
+ tags: list[str] | None = None,
) -> EmitResult:
"""Async entry: route DB calls through `database_sync_to_async` so async callers
(the harness runner inside Temporal) don't block the event loop.
@@ -119,6 +131,7 @@ async def emit_finding(
_assert_team_owns_run(team, run)
_validate_inputs(description, confidence, evidence, finding_id)
finding_id = finding_id or _new_finding_id()
+ tags = normalize_tags(tags)
extra = _build_extra(
run_id=str(run.id),
task_run_id=str(run.task_run_id),
@@ -132,6 +145,7 @@ async def emit_finding(
dedupe_keys=dedupe_keys,
time_range=time_range,
mcp_trace_id=mcp_trace_id,
+ tags=tags,
)
attempt_extra = _log_extra(
team_id=team.id,
@@ -175,6 +189,7 @@ async def emit_finding(
confidence=confidence,
severity=severity,
source_id=source_id,
+ tags=tags,
)
logger.info(
"signals_scout.emit: emitted",
@@ -196,6 +211,7 @@ def emit_finding_sync(
time_range: tuple[str, str] | None = None,
mcp_trace_id: str | None = None,
finding_id: str | None = None,
+ tags: list[str] | None = None,
) -> EmitResult:
"""Sync entry used by the DRF view path.
@@ -207,6 +223,7 @@ def emit_finding_sync(
_assert_team_owns_run(team, run)
_validate_inputs(description, confidence, evidence, finding_id)
finding_id = finding_id or _new_finding_id()
+ tags = normalize_tags(tags)
extra = _build_extra(
run_id=str(run.id),
task_run_id=str(run.task_run_id),
@@ -220,6 +237,7 @@ def emit_finding_sync(
dedupe_keys=dedupe_keys,
time_range=time_range,
mcp_trace_id=mcp_trace_id,
+ tags=tags,
)
attempt_extra = _log_extra(
team_id=team.id,
@@ -262,6 +280,7 @@ def emit_finding_sync(
confidence=confidence,
severity=severity,
source_id=source_id,
+ tags=tags,
)
logger.info(
"signals_scout.emit: emitted",
@@ -287,6 +306,34 @@ def _assert_team_owns_run(team: Team, run: SignalScoutRun) -> None:
raise RuntimeError(f"emit_finding: team {team.id} does not own run {run.id} (team {run.team_id})")
+def normalize_tags(tags: list[str] | None) -> list[str] | None:
+ """Normalize agent-supplied tags to deduped lowercase kebab-case slugs.
+
+ Whitespace/underscores become hyphens, anything outside `[a-z0-9-]` is stripped,
+ hyphen runs collapse, and duplicates (post-normalization) are dropped preserving
+ first-seen order. A tag that normalizes to nothing or exceeds `MAX_TAG_LENGTH`
+ raises `InvalidEmitError` — silently dropping it would make the agent believe a
+ tag stuck when it didn't. Returns None for None/empty input so `_build_extra`
+ omits the field entirely.
+ """
+ if not tags:
+ return None
+ if len(tags) > MAX_TAGS_PER_FINDING:
+ raise InvalidEmitError(f"tags has {len(tags)} entries, max is {MAX_TAGS_PER_FINDING}")
+ normalized: list[str] = []
+ for raw in tags:
+ slug = re.sub(r"[\s_]+", "-", raw.strip().lower())
+ slug = _TAG_INVALID_CHARS.sub("", slug)
+ slug = _TAG_HYPHEN_RUNS.sub("-", slug).strip("-")
+ if not slug:
+ raise InvalidEmitError(f"tag {raw!r} is empty after slug normalization")
+ if len(slug) > MAX_TAG_LENGTH:
+ raise InvalidEmitError(f"tag {raw!r} exceeds {MAX_TAG_LENGTH} chars after normalization ({len(slug)})")
+ if slug not in normalized:
+ normalized.append(slug)
+ return normalized
+
+
def _validate_inputs(
description: str,
confidence: float,
@@ -319,10 +366,11 @@ def _build_extra(
dedupe_keys: list[str] | None,
time_range: tuple[str, str] | None,
mcp_trace_id: str | None,
+ tags: list[str] | None,
) -> dict[str, Any]:
"""Shape the extra payload to match `SignalsScoutSignalExtra` (extra='forbid'),
omitting optional fields when not provided so pydantic doesn't see a `None` for
- fields that don't accept it."""
+ fields that don't accept it. `tags` must already be normalized via `normalize_tags`."""
extra: dict[str, Any] = {
"scout_run_id": run_id,
"task_run_id": task_run_id,
@@ -338,6 +386,8 @@ def _build_extra(
extra["severity"] = severity
if dedupe_keys is not None:
extra["dedupe_keys"] = list(dedupe_keys)
+ if tags is not None:
+ extra["tags"] = list(tags)
if time_range is not None:
extra["time_range"] = {"date_from": time_range[0], "date_to": time_range[1]}
if mcp_trace_id is not None:
@@ -358,6 +408,7 @@ def _record_emit(
confidence: float,
severity: str | None,
source_id: str,
+ tags: list[str] | None,
) -> None:
"""Persist the emit: bump the run's tally (`emitted_finding_ids` + `emitted_count`) and
write a `SignalScoutEmission` row carrying the finding's content, in one transaction.
@@ -391,6 +442,7 @@ def _record_emit(
confidence=confidence,
severity=severity,
source_id=source_id,
+ tags=tags or [],
)
except Exception:
# Tally and emission row are best-effort; the signal already emitted. Log and move on
diff --git a/products/signals/backend/scout_harness/views.py b/products/signals/backend/scout_harness/views.py
index 95bb9d6298df..ad49558c9269 100644
--- a/products/signals/backend/scout_harness/views.py
+++ b/products/signals/backend/scout_harness/views.py
@@ -340,6 +340,7 @@ class SignalScoutRunViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
time_range=time_range_tuple,
mcp_trace_id=data.get("mcp_trace_id") or None,
finding_id=data.get("finding_id") or None,
+ tags=data.get("tags") or None,
)
except InvalidEmitError as exc:
raise exceptions.ValidationError({"detail": str(exc)})
diff --git a/products/signals/backend/test/test_scout_harness.py b/products/signals/backend/test/test_scout_harness.py
index 16db56e46cb1..80b8f28727c0 100644
--- a/products/signals/backend/test/test_scout_harness.py
+++ b/products/signals/backend/test/test_scout_harness.py
@@ -167,6 +167,10 @@ class TestPromptBuilder(BaseTest):
# agent-feedback tool so the scout system improves over time.
assert "Report operational friction" in prompt
assert "agent-feedback" in prompt
+ # Tag guidance teaches the scratchpad-taxonomy convention — the scout owns and
+ # evolves its vocabulary in the scout loop; the harness only carries the nudge.
+ assert "Tagging your findings" in prompt
+ assert "tags:<domain>:taxonomy" in prompt
# The base prompt teaches scouts to format the description for the inbox
# surface (markdown, front-loaded into the ~300-char collapsed preview),
# while leaving a skill body free to impose its own structure.
diff --git a/products/signals/backend/test/test_scout_harness_api.py b/products/signals/backend/test/test_scout_harness_api.py
index 8b3531598209..bddcc3061f9b 100644
--- a/products/signals/backend/test/test_scout_harness_api.py
+++ b/products/signals/backend/test/test_scout_harness_api.py
@@ -215,7 +215,7 @@ class TestScoutHarnessRunEmissionsAPI(APIBaseTest):
def test_returns_emissions_for_run_newest_first(self) -> None:
run = _make_run(self.team, emitted_count=2, emitted_finding_ids=["f-a", "f-b"])
_make_emission(self.team, run, finding_id="f-a")
- newer = _make_emission(self.team, run, finding_id="f-b")
+ newer = _make_emission(self.team, run, finding_id="f-b", tags=["cost-spike"])
response = self.client.get(self._emissions_url(str(run.id)))
assert response.status_code == status.HTTP_200_OK
body = response.json()
@@ -226,7 +226,10 @@ class TestScoutHarnessRunEmissionsAPI(APIBaseTest):
assert first["weight"] == 0.7
assert first["confidence"] == 0.85
assert first["severity"] == "P1"
+ assert first["tags"] == ["cost-spike"]
assert first["source_id"] == f"run:{run.id}:finding:{newer.finding_id}"
+ # Untagged emissions surface an empty list, not null.
+ assert body[1]["tags"] == []
def test_emissions_scoped_to_the_requested_run(self) -> None:
run_a = _make_run(self.team)
@@ -308,6 +311,31 @@ class TestScoutHarnessEmitFindingAPI(APIBaseTest):
# Idempotency is via the deterministic `source_id` keyed on (run, finding).
assert mock_emit.await_args.kwargs["source_id"] == f"run:{run.id}:finding:f-1"
+ def test_emit_finding_normalizes_tags_into_extra(self) -> None:
+ run = _make_run(self.team)
+ with patch("products.signals.backend.facade.api.emit_signal", new_callable=AsyncMock) as mock_emit:
+ response = self.client.post(
+ self._emit_signal_url(str(run.id)),
+ data=self._payload(tags=["Cost Spike", "cost_spike", "silent-failure"]),
+ format="json",
+ )
+ assert response.status_code == status.HTTP_200_OK
+ assert mock_emit.await_args is not None
+ assert mock_emit.await_args.kwargs["extra"]["tags"] == ["cost-spike", "silent-failure"]
+ emission = SignalScoutEmission.objects.get(scout_run=run)
+ assert emission.tags == ["cost-spike", "silent-failure"]
+
+ def test_emit_finding_rejects_too_many_tags(self) -> None:
+ run = _make_run(self.team)
+ with patch("products.signals.backend.facade.api.emit_signal", new_callable=AsyncMock) as mock_emit:
+ response = self.client.post(
+ self._emit_signal_url(str(run.id)),
+ data=self._payload(tags=[f"tag-{i}" for i in range(11)]),
+ format="json",
+ )
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ mock_emit.assert_not_called()
+
def test_emit_finding_rejects_non_in_progress_run(self) -> None:
run = _make_run(self.team, task_run_status=TaskRun.Status.COMPLETED)
response = self.client.post(self._emit_signal_url(str(run.id)), data=self._payload(), format="json")
diff --git a/products/signals/backend/test/test_scout_harness_tools.py b/products/signals/backend/test/test_scout_harness_tools.py
index bb75739d1a32..c579cf9c1251 100644
--- a/products/signals/backend/test/test_scout_harness_tools.py
+++ b/products/signals/backend/test/test_scout_harness_tools.py
@@ -29,12 +29,15 @@ from products.signals.backend.scout_harness.tools import (
)
from products.signals.backend.scout_harness.tools.emit import (
MAX_FINDING_ID_LENGTH,
+ MAX_TAG_LENGTH,
+ MAX_TAGS_PER_FINDING,
SCOUT_SIGNAL_WEIGHT,
SOURCE_PRODUCT,
SOURCE_TYPE,
_build_extra,
_validate_inputs,
emit_finding_sync,
+ normalize_tags,
)
from products.signals.backend.scout_harness.tools.runs import MAX_FAILURE_REASON_LENGTH, MAX_RUN_SEARCH_LIMIT
from products.signals.backend.scout_harness.tools.scratchpad import (
@@ -473,6 +476,55 @@ class TestValidateEmitInputs:
_validate_inputs("ok", 0.5, [], "x" * MAX_FINDING_ID_LENGTH)
+class TestNormalizeTags:
+ """Pure normalization — no DB."""
+
+ @parameterized.expand(
+ [
+ ("already_clean", ["cost-spike"], ["cost-spike"]),
+ ("uppercase", ["Cost-Spike"], ["cost-spike"]),
+ ("spaces", ["cost spike"], ["cost-spike"]),
+ ("underscores", ["cost_spike"], ["cost-spike"]),
+ ("mixed_separators_and_case", [" Cost _ Spike "], ["cost-spike"]),
+ ("invalid_chars_stripped", ["cost!spike?"], ["costspike"]),
+ ("hyphen_runs_collapsed", ["cost--spike", "-edge-"], ["cost-spike", "edge"]),
+ (
+ "dedupes_post_normalization",
+ ["cost-spike", "Cost Spike", "silent-failure"],
+ ["cost-spike", "silent-failure"],
+ ),
+ ("preserves_first_seen_order", ["b-tag", "a-tag"], ["b-tag", "a-tag"]),
+ ]
+ )
+ def test_normalizes_to_slugs(self, _name: str, raw: list[str], expected: list[str]) -> None:
+ assert normalize_tags(raw) == expected
+
+ @parameterized.expand([("none", None), ("empty", [])])
+ def test_no_tags_returns_none(self, _name: str, raw: list[str] | None) -> None:
+ assert normalize_tags(raw) is None
+
+ @parameterized.expand([("only_punctuation", ["!!!"]), ("whitespace", [" "]), ("only_hyphens", ["---"])])
+ def test_unsalvageable_tag_raises(self, _name: str, raw: list[str]) -> None:
+ with pytest.raises(InvalidEmitError):
+ normalize_tags(raw)
+
+ def test_too_many_tags_raises(self) -> None:
+ with pytest.raises(InvalidEmitError):
+ normalize_tags([f"tag-{i}" for i in range(MAX_TAGS_PER_FINDING + 1)])
+
+ def test_at_capacity_passes(self) -> None:
+ tags = [f"tag-{i}" for i in range(MAX_TAGS_PER_FINDING)]
+ assert normalize_tags(tags) == tags
+
+ def test_overlong_tag_raises(self) -> None:
+ with pytest.raises(InvalidEmitError):
+ normalize_tags(["a" * (MAX_TAG_LENGTH + 1)])
+
+ def test_tag_at_max_length_passes(self) -> None:
+ tag = "a" * MAX_TAG_LENGTH
+ assert normalize_tags([tag]) == [tag]
+
+
class TestBuildEmitExtra:
"""Pure shaping — no DB. Asserts the dict matches what `SignalsScoutSignalExtra` expects."""
@@ -490,6 +542,7 @@ class TestBuildEmitExtra:
dedupe_keys=None,
time_range=None,
mcp_trace_id=None,
+ tags=None,
)
def test_minimal_extra_has_only_required_fields(self) -> None:
@@ -505,7 +558,7 @@ class TestBuildEmitExtra:
]
# Optional fields omitted, not None — pydantic with extra="forbid" tolerates absence
# but rejects unexpected keys, so omission is the right shape.
- for opt in ("hypothesis", "severity", "dedupe_keys", "time_range", "mcp_trace_id"):
+ for opt in ("hypothesis", "severity", "dedupe_keys", "time_range", "mcp_trace_id", "tags"):
assert opt not in extra
def test_skill_version_cast_to_float(self) -> None:
@@ -528,12 +581,14 @@ class TestBuildEmitExtra:
dedupe_keys=["checkout-500-spike"],
time_range=("2026-04-29T00:00:00Z", "2026-04-30T00:00:00Z"),
mcp_trace_id="trace-abc",
+ tags=["cost-spike", "post-deploy-regression"],
)
assert extra["hypothesis"] == "checkout post-deploy regression"
assert extra["severity"] == "P1"
assert extra["dedupe_keys"] == ["checkout-500-spike"]
assert extra["time_range"] == {"date_from": "2026-04-29T00:00:00Z", "date_to": "2026-04-30T00:00:00Z"}
assert extra["mcp_trace_id"] == "trace-abc"
+ assert extra["tags"] == ["cost-spike", "post-deploy-regression"]
def test_built_extra_validates_against_schema_variant(self) -> None:
"""Round-trip: the extra we build must pass `SignalsScoutSignalInput` validation
@@ -541,6 +596,7 @@ class TestBuildEmitExtra:
from posthog.schema import SignalsScoutSignalInput
extra = self._minimal()
+ extra["tags"] = ["cost-spike"]
SignalsScoutSignalInput.model_validate(
{
"source_product": SOURCE_PRODUCT,
@@ -827,6 +883,7 @@ async def test_emit_finding_persists_emission_rows(ateam_emit, arun_emit):
evidence=[EvidenceEntry(source_product="error_tracking", summary="500s on /checkout")],
severity="P1",
finding_id="f-emit",
+ tags=["post-deploy-regression"],
)
rows = await database_sync_to_async(lambda: list(SignalScoutEmission.all_teams.filter(scout_run=arun_emit)))()
@@ -838,9 +895,51 @@ async def test_emit_finding_persists_emission_rows(ateam_emit, arun_emit):
assert emission.weight == SCOUT_SIGNAL_WEIGHT
assert emission.confidence == 0.85
assert emission.severity == "P1"
+ assert emission.tags == ["post-deploy-regression"]
assert emission.source_id == f"run:{arun_emit.id}:finding:f-emit"
+async def test_emit_finding_normalizes_tags_into_extra_and_emission_row(ateam_emit, arun_emit):
+ # Messy agent-supplied tags reach both persistence surfaces (signal `extra` and the
+ # emission row) already normalized, so the vocabulary converges on slugs.
+ with patch("products.signals.backend.facade.api.emit_signal", new=AsyncMock()) as mock_emit:
+ await emit_finding(
+ team=ateam_emit,
+ run=arun_emit,
+ description="Checkout 500s post-deploy",
+ confidence=0.85,
+ evidence=[EvidenceEntry(source_product="error_tracking", summary="500s on /checkout")],
+ finding_id="f-tags",
+ tags=["Cost Spike", "cost_spike", "silent-failure"],
+ )
+
+ assert mock_emit.await_args is not None
+ assert mock_emit.await_args.kwargs["extra"]["tags"] == ["cost-spike", "silent-failure"]
+ emission = await database_sync_to_async(SignalScoutEmission.all_teams.get)(scout_run=arun_emit)
+ assert emission.tags == ["cost-spike", "silent-failure"]
+
+
+async def test_emit_finding_without_tags_omits_extra_field_and_defaults_row_empty(ateam_emit, arun_emit):
+ with patch("products.signals.backend.facade.api.emit_signal", new=AsyncMock()) as mock_emit:
+ await emit_finding(
+ team=ateam_emit,
+ run=arun_emit,
+ description="Checkout 500s post-deploy",
+ confidence=0.85,
+ evidence=[EvidenceEntry(source_product="error_tracking", summary="500s on /checkout")],
+ finding_id="f-no-tags",
+ )
+
+ assert mock_emit.await_args is not None
+ assert "tags" not in mock_emit.await_args.kwargs["extra"]
+ emission = await database_sync_to_async(SignalScoutEmission.all_teams.get)(scout_run=arun_emit)
+ assert emission.tags == []
+
+
@pytest.mark.asyncio
@pytest.mark.django_db
async def test_emit_finding_skip_does_not_record_tally(arun_emit, ateam_emit):
diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.ts
index 4bc6cbc480a5..2e5aa24bbb46 100644
--- a/products/signals/frontend/generated/api.schemas.ts
+++ b/products/signals/frontend/generated/api.schemas.ts
@@ -909,6 +909,8 @@ export interface SignalScoutEmissionApi {
* * `P3` - P3
* * `P4` - P4 */
severity: AutonomyPriorityEnumApi | null
+ /** Slug tags the scout attached to this finding (lowercase kebab-case, e.g. `cost-spike`). Empty list when the run set none. */
+ tags: string[]
/** Deterministic `run:<run_id>:finding:<finding_id>` — the join key into the underlying signal store. */
source_id: string
/** ISO-8601 timestamp the finding was emitted. */
@@ -972,6 +974,12 @@ export interface EmitFindingRequestApi {
severity?: AutonomyPriorityEnumApi | null
/** Optional keys for downstream dedupe (e.g. `error_tracking_issue:<id>`). */
dedupe_keys?: string[]
+ /**
+ * Optional category tags as lowercase kebab-case slugs (e.g. `cost-spike`, `silent-failure`), max 10. Reuse the vocabulary in your `tags:<domain>:taxonomy` scratchpad entry when a tag fits; coin a new slug when a genuinely new category emerges. Near-miss formats are normalized to slugs; persisted in the signal's `extra.tags` and on the emission row.
+ * @maxItems 10
+ * @items.maxLength 50
+ */
+ tags?: string[]
/** Optional time window the finding refers to. */
time_range?: TimeRangeApi | null
/**
diff --git a/products/signals/frontend/generated/api.zod.ts b/products/signals/frontend/generated/api.zod.ts
index 7830ef44e8cf..370ee9700403 100644
--- a/products/signals/frontend/generated/api.zod.ts
+++ b/products/signals/frontend/generated/api.zod.ts
@@ -110,6 +110,10 @@ export const signalsScoutEmitSignalBodyConfidenceMax = 1
export const signalsScoutEmitSignalBodyEvidenceMax = 20
+export const signalsScoutEmitSignalBodyTagsItemMax = 50
+
+export const signalsScoutEmitSignalBodyTagsMax = 10
+
export const signalsScoutEmitSignalBodyFindingIdMax = 100
export const SignalsScoutEmitSignalBody = /* @__PURE__ */ zod
@@ -160,6 +164,13 @@ export const SignalsScoutEmitSignalBody = /* @__PURE__ */ zod
.array(zod.string())
.optional()
.describe('Optional keys for downstream dedupe (e.g. `error_tracking_issue:<id>`).'),
+ tags: zod
+ .array(zod.string().max(signalsScoutEmitSignalBodyTagsItemMax))
+ .max(signalsScoutEmitSignalBodyTagsMax)
+ .optional()
+ .describe(
+ "Optional category tags as lowercase kebab-case slugs (e.g. `cost-spike`, `silent-failure`), max 10. Reuse the vocabulary in your `tags:<domain>:taxonomy` scratchpad entry when a tag fits; coin a new slug when a genuinely new category emerges. Near-miss formats are normalized to slugs; persisted in the signal's `extra.tags` and on the emission row."
+ ),
time_range: zod
.union([
zod.object({
diff --git a/products/signals/mcp/tools.yaml b/products/signals/mcp/tools.yaml
index 2a1d33c7df88..c80a1229347c 100644
--- a/products/signals/mcp/tools.yaml
+++ b/products/signals/mcp/tools.yaml
@@ -224,6 +224,7 @@ tools:
Fire `emit_signal` with `source_product = signals_scout`. The `finding_id` is baked into the deterministic
`Signal.source_id = run:<id>:finding:<id>` for traceability, but this is NOT idempotent — a second call with
the same `finding_id` emits a second signal, so emit each finding exactly once and never retry an emit.
+ Findings should carry `tags` — see the `tags` param for the slug and taxonomy convention.
signals-scout-project-profile-get:
operation: signals_scout_project_profile_get
enabled: true
@@ -256,10 +257,10 @@ tools:
title: List a scout run's emitted findings
description: >
Return the findings a `SignalScoutRun` emitted to the inbox, newest first — one row per emit with its
- `description` (the finding text as surfaced), `weight`, `confidence`, `severity`, and the deterministic
- `source_id` (`run:<run_id>:finding:<finding_id>`) that joins back to the underlying signal. Use this to see
- *what* a run actually surfaced, not just how many (`emitted_count`) or which ids (`emitted_finding_ids`).
- Strictly team-scoped — a run UUID belonging to another team returns 404.
+ `description` (the finding text as surfaced), `weight`, `confidence`, `severity`, `tags`, and the
+ deterministic `source_id` (`run:<run_id>:finding:<finding_id>`) that joins back to the underlying signal.
+ Use this to see *what* a run actually surfaced, not just how many (`emitted_count`) or which ids
+ (`emitted_finding_ids`). Strictly team-scoped — a run UUID belonging to another team returns 404.
signals-scout-runs-list:
operation: signals_scout_runs_list
enabled: true
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 2b1f69ad6182..22f1835d957d 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -5090,7 +5090,7 @@
}
},
"signals-scout-emit-signal": {
- "description": "Fire `emit_signal` with `source_product = signals_scout`. The `finding_id` is baked into the deterministic `Signal.source_id = run:<id>:finding:<id>` for traceability, but this is NOT idempotent — a second call with the same `finding_id` emits a second signal, so emit each finding exactly once and never retry an emit.",
+ "description": "Fire `emit_signal` with `source_product = signals_scout`. The `finding_id` is baked into the deterministic `Signal.source_id = run:<id>:finding:<id>` for traceability, but this is NOT idempotent — a second call with the same `finding_id` emits a second signal, so emit each finding exactly once and never retry an emit. Findings should carry `tags` — see the `tags` param for the slug and taxonomy convention.",
"category": "Signals",
"feature": "signals",
"summary": "Emit a finding for a run",
@@ -5118,7 +5118,7 @@
}
},
"signals-scout-runs-emissions-list": {
- "description": "Return the findings a `SignalScoutRun` emitted to the inbox, newest first — one row per emit with its `description` (the finding text as surfaced), `weight`, `confidence`, `severity`, and the deterministic `source_id` (`run:<run_id>:finding:<finding_id>`) that joins back to the underlying signal. Use this to see *what* a run actually surfaced, not just how many (`emitted_count`) or which ids (`emitted_finding_ids`). Strictly team-scoped — a run UUID belonging to another team returns 404.",
+ "description": "Return the findings a `SignalScoutRun` emitted to the inbox, newest first — one row per emit with its `description` (the finding text as surfaced), `weight`, `confidence`, `severity`, `tags`, and the deterministic `source_id` (`run:<run_id>:finding:<finding_id>`) that joins back to the underlying signal. Use this to see *what* a run actually surfaced, not just how many (`emitted_count`) or which ids (`emitted_finding_ids`). Strictly team-scoped — a run UUID belonging to another team returns 404.",
"category": "Signals",
"feature": "signals",
"summary": "List a scout run's emitted findings",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 1e62b7fce3dd..fe32963bb183 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -5431,7 +5431,7 @@
}
},
"signals-scout-emit-signal": {
- "description": "Fire `emit_signal` with `source_product = signals_scout`. The `finding_id` is baked into the deterministic `Signal.source_id = run:<id>:finding:<id>` for traceability, but this is NOT idempotent — a second call with the same `finding_id` emits a second signal, so emit each finding exactly once and never retry an emit.",
+ "description": "Fire `emit_signal` with `source_product = signals_scout`. The `finding_id` is baked into the deterministic `Signal.source_id = run:<id>:finding:<id>` for traceability, but this is NOT idempotent — a second call with the same `finding_id` emits a second signal, so emit each finding exactly once and never retry an emit. Findings should carry `tags` — see the `tags` param for the slug and taxonomy convention.",
"category": "Signals",
"feature": "signals",
"summary": "Emit a finding for a run",
@@ -5459,7 +5459,7 @@
}
},
"signals-scout-runs-emissions-list": {
- "description": "Return the findings a `SignalScoutRun` emitted to the inbox, newest first — one row per emit with its `description` (the finding text as surfaced), `weight`, `confidence`, `severity`, and the deterministic `source_id` (`run:<run_id>:finding:<finding_id>`) that joins back to the underlying signal. Use this to see *what* a run actually surfaced, not just how many (`emitted_count`) or which ids (`emitted_finding_ids`). Strictly team-scoped — a run UUID belonging to another team returns 404.",
+ "description": "Return the findings a `SignalScoutRun` emitted to the inbox, newest first — one row per emit with its `description` (the finding text as surfaced), `weight`, `confidence`, `severity`, `tags`, and the deterministic `source_id` (`run:<run_id>:finding:<finding_id>`) that joins back to the underlying signal. Use this to see *what* a run actually surfaced, not just how many (`emitted_count`) or which ids (`emitted_finding_ids`). Strictly team-scoped — a run UUID belonging to another team returns 404.",
"category": "Signals",
"feature": "signals",
"summary": "List a scout run's emitted findings",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index d73ebfd1a1f9..8c24eaa9fb7e 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -14723,6 +14723,12 @@ export namespace Schemas {
severity?: AutonomyPriorityEnum | null;
/** Optional keys for downstream dedupe (e.g. `error_tracking_issue:<id>`). */
dedupe_keys?: string[];
+ /**
+ * Optional category tags as lowercase kebab-case slugs (e.g. `cost-spike`, `silent-failure`), max 10. Reuse the vocabulary in your `tags:<domain>:taxonomy` scratchpad entry when a tag fits; coin a new slug when a genuinely new category emerges. Near-miss formats are normalized to slugs; persisted in the signal's `extra.tags` and on the emission row.
+ * @maxItems 10
+ * @items.maxLength 50
+ */
+ tags?: string[];
/** Optional time window the finding refers to. */
time_range?: TimeRange | null;
/**
@@ -39647,6 +39653,8 @@ export namespace Schemas {
* * `P3` - P3
* * `P4` - P4 */
severity: AutonomyPriorityEnum | null;
+ /** Slug tags the scout attached to this finding (lowercase kebab-case, e.g. `cost-spike`). Empty list when the run set none. */
+ tags: string[];
/** Deterministic `run:<run_id>:finding:<finding_id>` — the join key into the underlying signal store. */
source_id: string;
/** ISO-8601 timestamp the finding was emitted. */
diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.ts
index ed9cc3559d89..dea25c989e26 100644
--- a/services/mcp/src/generated/signals/api.ts
+++ b/services/mcp/src/generated/signals/api.ts
@@ -297,6 +297,10 @@ export const signalsScoutEmitSignalBodyConfidenceMax = 1
export const signalsScoutEmitSignalBodyEvidenceMax = 20
+export const signalsScoutEmitSignalBodyTagsItemMax = 50
+
+export const signalsScoutEmitSignalBodyTagsMax = 10
+
export const signalsScoutEmitSignalBodyFindingIdMax = 100
export const SignalsScoutEmitSignalBody = /* @__PURE__ */ zod
@@ -347,6 +351,13 @@ export const SignalsScoutEmitSignalBody = /* @__PURE__ */ zod
.array(zod.string())
.optional()
.describe('Optional keys for downstream dedupe (e.g. `error_tracking_issue:<id>`).'),
+ tags: zod
+ .array(zod.string().max(signalsScoutEmitSignalBodyTagsItemMax))
+ .max(signalsScoutEmitSignalBodyTagsMax)
+ .optional()
+ .describe(
+ "Optional category tags as lowercase kebab-case slugs (e.g. `cost-spike`, `silent-failure`), max 10. Reuse the vocabulary in your `tags:<domain>:taxonomy` scratchpad entry when a tag fits; coin a new slug when a genuinely new category emerges. Near-miss formats are normalized to slugs; persisted in the signal's `extra.tags` and on the emission row."
+ ),
time_range: zod
.union([
zod.object({
diff --git a/services/mcp/src/tools/generated/signals.ts b/services/mcp/src/tools/generated/signals.ts
index 49df2e3054fd..15ee6b366578 100644
--- a/services/mcp/src/tools/generated/signals.ts
+++ b/services/mcp/src/tools/generated/signals.ts
@@ -359,6 +359,9 @@ const signalsScoutEmitSignal = (): ToolBase<typeof SignalsScoutEmitSignalSchema,
if (params.dedupe_keys !== undefined) {
body['dedupe_keys'] = params.dedupe_keys
}
+ if (params.tags !== undefined) {
+ body['tags'] = params.tags
+ }
if (params.time_range !== undefined) {
body['time_range'] = params.time_range
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-emit-signal.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-emit-signal.json
index 7e106ed80b53..78d1aa618b59 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-emit-signal.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-emit-signal.json
@@ -101,6 +101,15 @@
],
"description": "Optional severity tag — one of P0, P1, P2, P3, P4. Informational only.\n\n* `P0` - P0\n* `P1` - P1\n* `P2` - P2\n* `P3` - P3\n* `P4` - P4"
},
+ "tags": {
+ "description": "Optional category tags as lowercase kebab-case slugs (e.g. `cost-spike`, `silent-failure`), max 10. Reuse the vocabulary in your `tags:<domain>:taxonomy` scratchpad entry when a tag fits; coin a new slug when a genuinely new category emerges. Near-miss formats are normalized to slugs; persisted in the signal's `extra.tags` and on the emission row.",
+ "items": {
+ "maxLength": 50,
+ "type": "string"
+ },
+ "maxItems": 10,
+ "type": "array"
+ },
"time_range": {
"anyOf": [
{