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): scope and project scout-harness introspection reads (#62706)

posthog[bot]902ae4afad3b
diff --git a/products/signals/backend/scout_harness/serializers.py b/products/signals/backend/scout_harness/serializers.py
index f4a6154e2f40..84e369defed2 100644
--- a/products/signals/backend/scout_harness/serializers.py
+++ b/products/signals/backend/scout_harness/serializers.py
@@ -60,6 +60,23 @@ class SignalScoutRunSummarySerializer(serializers.Serializer):
"runs that errored before close-out. The dedupe key for non-emitting runs."
),
)
+ error = serializers.CharField(
+ allow_null=True,
+ required=False,
+ help_text=(
+ "Full `error_message` from the linked TaskRun, surfaced only for failed/cancelled runs "
+ "(null otherwise, including on success). Use `failure_reason` for a concise scan-friendly summary."
+ ),
+ )
+ failure_reason = serializers.CharField(
+ allow_null=True,
+ required=False,
+ help_text=(
+ "Concise derived reason the run didn't complete cleanly — the first line of `error` "
+ "(bounded), or a status-derived fallback. Null unless the run terminated failed/cancelled. "
+ "Read this to see at a glance *why* a run emitted nothing without pulling full stack traces."
+ ),
+ )
emitted_count = serializers.IntegerField(
help_text=(
"Number of findings this run actually emitted to the inbox. 0 for runs that "
@@ -162,6 +179,19 @@ class SearchRecentRunsQuerySerializer(serializers.Serializer):
"(`emitted_count > 0`); `false` returns only runs that emitted nothing. Omit for both."
),
)
+ skill_name = serializers.CharField(
+ required=False,
+ help_text=(
+ "Exact-match filter on the scout skill (e.g. `signals-scout-errors`). Narrows the run "
+ "dump to a single scout — the primary scoping path when a specialist dedupes against "
+ "its own past runs. Omit to span every scout on the team."
+ ),
+ )
+ skill_version = serializers.IntegerField(
+ required=False,
+ min_value=1,
+ help_text="Exact-match filter on the skill version. Pair with `skill_name` to pin one version; omit for all.",
+ )
limit = serializers.IntegerField(
required=False,
min_value=1,
@@ -177,7 +207,13 @@ class ScratchpadEntrySerializer(serializers.Serializer):
"""`SignalScratchpad` projection used by `search-memory` and `remember`."""
key = serializers.CharField(help_text="Agent-chosen semantic key, unique per team.")
- content = serializers.CharField(help_text="Prose content for prompt injection.")
+ content = serializers.CharField(
+ allow_blank=True,
+ help_text=(
+ "Prose content for prompt injection. Blank when the search projected it out "
+ "(`keys_only=true`); truncated to a preview when `content_max_chars` was set."
+ ),
+ )
created_at = serializers.CharField(allow_null=True, help_text="ISO-8601 creation timestamp.")
updated_at = serializers.CharField(allow_null=True, help_text="ISO-8601 last-write timestamp.")
created_by_run_id = serializers.CharField(
@@ -194,6 +230,22 @@ class SearchMemoryQuerySerializer(serializers.Serializer):
allow_blank=True,
help_text="ILIKE substring match against `content`. Omit to return the most recent entries.",
)
+ keys_only = serializers.BooleanField(
+ required=False,
+ help_text=(
+ "When true, blank each entry's `content` and return only keys + metadata. Use to scan "
+ "which memories exist without pulling their (potentially large) bodies, then re-query "
+ "the ones worth a full read. Takes precedence over `content_max_chars`."
+ ),
+ )
+ content_max_chars = serializers.IntegerField(
+ required=False,
+ min_value=0,
+ help_text=(
+ "Truncate each entry's `content` to the first N characters (a preview). Omit for the "
+ "full body. Ignored when `keys_only=true`."
+ ),
+ )
limit = serializers.IntegerField(
required=False,
min_value=1,
diff --git a/products/signals/backend/scout_harness/tools/runs.py b/products/signals/backend/scout_harness/tools/runs.py
index 2dbf5bb11835..d448fe3fb44d 100644
--- a/products/signals/backend/scout_harness/tools/runs.py
+++ b/products/signals/backend/scout_harness/tools/runs.py
@@ -21,11 +21,16 @@ from datetime import datetime
from typing import Any
from products.signals.backend.models import SignalScoutRun
+from products.tasks.backend.models import TaskRun
# Defensive caps so a runaway agent loop can't pull thousands of rows in one call.
DEFAULT_RUN_SEARCH_LIMIT = 20
MAX_RUN_SEARCH_LIMIT = 100
+# `failure_reason` is the concise, list-safe derived signal; `error` carries the full
+# `TaskRun.error_message`. Bound the derived reason so it stays cheap to scan in bulk.
+MAX_FAILURE_REASON_LENGTH = 500
+
@dataclass(frozen=True)
class RunSummary:
@@ -43,6 +48,10 @@ class RunSummary:
task_id: str | None = None
task_run_id: str | None = None
task_url: str | None = None
+ # `error` is the full `TaskRun.error_message`; `failure_reason` is the concise derived
+ # one-liner. Both are surfaced only for failed/cancelled runs — null otherwise (incl. success).
+ error: str | None = None
+ failure_reason: str | None = None
def as_dict(self) -> dict[str, Any]:
return asdict(self)
@@ -69,6 +78,10 @@ class RunDetail:
task_id: str | None = None
task_run_id: str | None = None
task_url: str | None = None
+ # `error` is the full `TaskRun.error_message`; `failure_reason` is the concise derived
+ # one-liner. Both are surfaced only for failed/cancelled runs — null otherwise (incl. success).
+ error: str | None = None
+ failure_reason: str | None = None
def as_dict(self) -> dict[str, Any]:
return asdict(self)
@@ -81,6 +94,8 @@ def search_recent_runs(
date_to: datetime | None = None,
text: str | None = None,
emitted: bool | None = None,
+ skill_name: str | None = None,
+ skill_version: int | None = None,
limit: int = DEFAULT_RUN_SEARCH_LIMIT,
) -> list[RunSummary]:
"""Return the most recent runs for a team, newest first.
@@ -93,7 +108,10 @@ def search_recent_runs(
`summary` — the primary dedupe path for runs that didn't emit findings.
`emitted` filters on emit outcome: `True` keeps only runs that emitted at least
one finding (`emitted_count > 0`), `False` keeps only runs that emitted nothing;
- omit it for both. Results are capped at `MAX_RUN_SEARCH_LIMIT`.
+ omit it for both. `skill_name` is an exact-match filter that narrows the dump to
+ a single scout — the primary scoping path for a specialist deduping against its
+ own past work; pair it with `skill_version` to pin a specific version. Results
+ are capped at `MAX_RUN_SEARCH_LIMIT`.
"""
clamped_limit = _clamp_limit(limit)
qs = SignalScoutRun.objects.filter(team_id=team_id).select_related("task_run").order_by("-created_at")
@@ -105,6 +123,10 @@ def search_recent_runs(
qs = qs.filter(summary__icontains=text)
if emitted is not None:
qs = qs.filter(emitted_count__gt=0) if emitted else qs.filter(emitted_count=0)
+ if skill_name:
+ qs = qs.filter(skill_name=skill_name)
+ if skill_version is not None:
+ qs = qs.filter(skill_version=skill_version)
qs = qs[:clamped_limit]
return [_to_summary(row, team_id=team_id) for row in qs]
@@ -125,6 +147,7 @@ def _to_summary(row: SignalScoutRun, *, team_id: int) -> RunSummary:
task_run = row.task_run
task_id = str(task_run.task_id) if task_run is not None else None
task_run_id = str(task_run.id) if task_run is not None else None
+ error, failure_reason = _derive_failure(task_run)
return RunSummary(
run_id=str(row.id),
skill_name=row.skill_name,
@@ -138,6 +161,8 @@ def _to_summary(row: SignalScoutRun, *, team_id: int) -> RunSummary:
task_id=task_id,
task_run_id=task_run_id,
task_url=_build_task_url(team_id=team_id, task_id=task_id, task_run_id=task_run_id),
+ error=error,
+ failure_reason=failure_reason,
)
@@ -146,6 +171,27 @@ def _to_detail(row: SignalScoutRun, *, team_id: int) -> RunDetail:
return RunDetail(**asdict(summary))
+def _derive_failure(task_run: TaskRun | None) -> tuple[str | None, str | None]:
+ """Return `(error, failure_reason)` for a run — both None unless it failed/cancelled.
+
+ Gating both on terminal-failure status keeps a non-null `error` a genuine failure signal:
+ a stray `error_message` left on a run that reached COMPLETED is not surfaced, so the
+ "both null on success" contract holds. `error` is the full `TaskRun.error_message`;
+ `failure_reason` is the concise list-safe derived one-liner — the first line of the message
+ bounded to `MAX_FAILURE_REASON_LENGTH`, or a status-derived fallback when none was recorded.
+ `failure_reason` is what a bulk run scan reads to see *why* a run emitted nothing without
+ pulling every stack trace.
+ """
+ if task_run is None or task_run.status not in (TaskRun.Status.FAILED, TaskRun.Status.CANCELLED):
+ return None, None
+ error = task_run.error_message or None
+ message = (task_run.error_message or "").strip()
+ if message:
+ return error, message.splitlines()[0][:MAX_FAILURE_REASON_LENGTH]
+ fallback = "cancelled" if task_run.status == TaskRun.Status.CANCELLED else "failed (no error message recorded)"
+ return error, fallback
+
+
def _build_task_url(*, team_id: int, task_id: str | None, task_run_id: str | None) -> str | None:
"""Build the relative Tasks UI deep-link, or None if the linkage isn't captured.
diff --git a/products/signals/backend/scout_harness/tools/scratchpad.py b/products/signals/backend/scout_harness/tools/scratchpad.py
index c20223f91a8d..6ef44b0a755e 100644
--- a/products/signals/backend/scout_harness/tools/scratchpad.py
+++ b/products/signals/backend/scout_harness/tools/scratchpad.py
@@ -52,11 +52,22 @@ def search_scratchpad(
team_id: int,
text: str | None = None,
limit: int = DEFAULT_SCRATCHPAD_SEARCH_LIMIT,
+ keys_only: bool = False,
+ content_max_chars: int | None = None,
) -> list[ScratchpadEntry]:
"""Return memories the agent should consider when planning a run.
`text` matches ILIKE against `content` and `key`. The previous `tags` filter
+ GIN index were dropped in PR 2 review.
+
+ Result-scoping projections keep an orientation/dedupe scan from pulling every
+ entry's full body — `content` is an unbounded TextField, so a wide scan can
+ return up to `MAX_SCRATCHPAD_CONTENT_LENGTH × limit` characters of prose the
+ caller doesn't need yet:
+ - `keys_only=True` blanks `content` entirely — return just keys + metadata to
+ pick the entries worth a full read, then re-query the chosen ones.
+ - `content_max_chars=N` truncates each `content` to the first `N` characters
+ (a preview). Ignored when `keys_only=True`, which already drops the body.
"""
clamped_limit = _clamp_search_limit(limit)
qs = SignalScratchpad.objects.filter(team_id=team_id)
@@ -65,7 +76,7 @@ def search_scratchpad(
qs = qs.filter(Q(content__icontains=text) | Q(key__icontains=text))
qs = qs.order_by("-updated_at", "-id")[:clamped_limit]
- return [_to_entry(row) for row in qs]
+ return [_to_entry(row, keys_only=keys_only, content_max_chars=content_max_chars) for row in qs]
def remember(
@@ -140,14 +151,26 @@ def _clamp_search_limit(limit: int) -> int:
return limit
-def _to_entry(row: SignalScratchpad) -> ScratchpadEntry:
+def _to_entry(
+ row: SignalScratchpad, *, keys_only: bool = False, content_max_chars: int | None = None
+) -> ScratchpadEntry:
# Django's FK descriptor exposes both `created_by_run` (object) and `created_by_run_id`
# (the raw FK column). `getattr` keeps Pyright happy without a join.
run_pk = getattr(row, "created_by_run_id", None)
return ScratchpadEntry(
key=row.key,
- content=row.content,
+ content=_project_content(row.content, keys_only=keys_only, content_max_chars=content_max_chars),
created_at=row.created_at.isoformat() if row.created_at else None,
updated_at=row.updated_at.isoformat() if row.updated_at else None,
created_by_run_id=str(run_pk) if run_pk else None,
)
+
+
+def _project_content(content: str, *, keys_only: bool, content_max_chars: int | None) -> str:
+ """Apply the search projection to a row's `content`: blank it for `keys_only`,
+ or truncate to a preview for `content_max_chars`. A negative max clamps to 0."""
+ if keys_only:
+ return ""
+ if content_max_chars is None:
+ return content
+ return content[: max(content_max_chars, 0)]
diff --git a/products/signals/backend/scout_harness/views.py b/products/signals/backend/scout_harness/views.py
index 8b39a4ba4b50..1fa64b882bca 100644
--- a/products/signals/backend/scout_harness/views.py
+++ b/products/signals/backend/scout_harness/views.py
@@ -21,7 +21,8 @@ from __future__ import annotations
import uuid
-from drf_spectacular.utils import OpenApiResponse, extend_schema
+from drf_spectacular.types import OpenApiTypes
+from drf_spectacular.utils import OpenApiParameter, OpenApiResponse, extend_schema
from rest_framework import exceptions, status, viewsets
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated
@@ -72,6 +73,16 @@ from products.signals.backend.scout_harness.tools.scratchpad import (
# retry-heavy run rather than leaving the payload unbounded.
MAX_EMISSIONS_PER_RUN = 1000
+# `SignalScoutRunViewSet.lookup_field` is `run_id`, but the model's PK field is `id`, so
+# drf-spectacular can't derive the path-param type from the model and warns (fatal under
+# `--fail-on-warn`). Declare the param explicitly on every detail action instead.
+_RUN_ID_PATH_PARAMETER = OpenApiParameter(
+ name="run_id",
+ type=OpenApiTypes.UUID,
+ location=OpenApiParameter.PATH,
+ description="UUID of the `SignalScoutRun` bridge row.",
+)
+
def _caller_carries_scout_internal_scope(request: Request) -> bool:
"""True only when the request authenticates with the sandbox-internal scout scope.
@@ -99,14 +110,16 @@ def _caller_carries_scout_internal_scope(request: Request) -> bool:
def _parse_run_id_or_404(kwargs: dict) -> uuid.UUID:
- """Parse the `id` URL kwarg as a UUID; raise 404 on missing or malformed.
-
- DRF routes any string the default `lookup_value_regex` accepts (anything
- except `/` and `.`) into the action, so the action is responsible for
- rejecting non-UUID inputs cleanly rather than letting them surface as
- 500s from `UUIDField.to_python()` on the underlying ORM query.
+ """Parse the run-id URL kwarg as a UUID; raise 404 on missing or malformed.
+
+ Accepts either `run_id` (the canonical name across the scout surface, set via
+ `SignalScoutRunViewSet.lookup_field`) or `id` (the legacy/config-viewset name) so
+ the same helper backs both. DRF routes any string the default `lookup_value_regex`
+ accepts (anything except `/` and `.`) into the action, so the action is responsible
+ for rejecting non-UUID inputs cleanly rather than letting them surface as 500s from
+ `UUIDField.to_python()` on the underlying ORM query.
"""
- raw = kwargs.get("id")
+ raw = kwargs.get("run_id") or kwargs.get("id")
if raw is None:
raise exceptions.NotFound()
try:
@@ -142,12 +155,13 @@ class SignalScoutRunViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
# in this viewset filter by `team_id` explicitly via the harness helpers, so leaving
# this unscoped is safe. Same shape `customer_analytics.AccountViewSet` uses.
queryset = SignalScoutRun.objects.unscoped()
- # Lookup is the run's UUID PK; DRF parses with the default `pk` URL kwarg.
- # No `lookup_value_regex` — use DRF's default and let the view actions parse
- # the raw segment with `uuid.UUID()` (via `_parse_run_id_or_404`) so malformed
- # IDs return a clean 404 rather than hitting `.filter(id=…)` with a non-UUID
- # and blowing up on Django's UUIDField conversion.
- lookup_field = "id"
+ # Lookup is the run's UUID PK, surfaced as `run_id` to match how the rest of the scout
+ # surface (serializers, scratchpad lineage, emission `source_id`) names it — the legacy
+ # `id` path param read inconsistently against `run_id` everywhere else. `_parse_run_id_or_404`
+ # still accepts both. No `lookup_value_regex` — use DRF's default and let the view actions
+ # parse the raw segment with `uuid.UUID()` so malformed IDs return a clean 404 rather than
+ # hitting `.filter(id=…)` with a non-UUID and blowing up on Django's UUIDField conversion.
+ lookup_field = "run_id"
# `list` returns a raw newest-first array (capped at limit=100 by the query serializer),
# not a paginated wrapper. Generated TS clients infer pagination from the global default
# otherwise, and the runtime shape diverges from the OpenAPI schema. Per-action overrides
@@ -169,6 +183,7 @@ class SignalScoutRunViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
"matches on `summary`. `date_from` / `date_to` are a half-open window on `created_at` "
"(`>= date_from`, `< date_to`); pass `date_to` on subsequent calls to walk past the "
"100-row cap. Pass `emitted=true` to see only runs that surfaced at least one finding. "
+ "Pass `skill_name` (optionally with `skill_version`) to scope to a single scout. "
"Results capped at 100."
),
)
@@ -178,6 +193,8 @@ class SignalScoutRunViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
date_to = validated.get("date_to")
text = validated.get("text") or None
emitted = validated.get("emitted")
+ skill_name = validated.get("skill_name") or None
+ skill_version = validated.get("skill_version")
limit = validated.get("limit") or 20
rows = search_recent_runs(
team_id=_canonical_team_id(self),
@@ -185,11 +202,14 @@ class SignalScoutRunViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
date_to=date_to,
text=text,
emitted=emitted,
+ skill_name=skill_name,
+ skill_version=skill_version,
limit=limit,
)
return Response(SignalScoutRunSummarySerializer([row.as_dict() for row in rows], many=True).data)
@extend_schema(
+ parameters=[_RUN_ID_PATH_PARAMETER],
responses={
200: OpenApiResponse(response=SignalScoutRunDetailSerializer, description="Full run detail."),
404: OpenApiResponse(description="Run not found or not visible to this project."),
@@ -208,6 +228,7 @@ class SignalScoutRunViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
return Response(SignalScoutRunDetailSerializer(detail.as_dict()).data)
@extend_schema(
+ parameters=[_RUN_ID_PATH_PARAMETER],
responses={
200: OpenApiResponse(
response=SignalScoutEmissionSerializer(many=True),
@@ -249,6 +270,7 @@ class SignalScoutRunViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
@validated_request(
request_serializer=EmitFindingRequestSerializer,
+ parameters=[_RUN_ID_PATH_PARAMETER],
responses={
200: OpenApiResponse(
response=EmitFindingResponseSerializer, description="Finding emitted, or skipped by a preflight gate."
@@ -374,14 +396,27 @@ class SignalScratchpadViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):
),
},
summary="Search the scout scratchpad",
- description=("Return `SignalScratchpad` entries for this project. ILIKE matches on `content` and `key`."),
+ description=(
+ "Return `SignalScratchpad` entries for this project. ILIKE matches on `content` and `key`. "
+ "Pass `keys_only=true` to scan keys without pulling entry bodies, or `content_max_chars` to "
+ "cap each `content` to a preview — both keep a wide orientation scan from returning every "
+ "entry's full prose."
+ ),
operation_id="signals_scout_scratchpad_search",
)
def list(self, request: Request, *args, **kwargs) -> Response:
validated = getattr(request, "validated_query_data", {}) or {}
text = validated.get("text") or None
+ keys_only = bool(validated.get("keys_only", False))
+ content_max_chars = validated.get("content_max_chars")
limit = validated.get("limit") or 20
- rows = search_scratchpad(team_id=_canonical_team_id(self), text=text, limit=limit)
+ rows = search_scratchpad(
+ team_id=_canonical_team_id(self),
+ text=text,
+ limit=limit,
+ keys_only=keys_only,
+ content_max_chars=content_max_chars,
+ )
return Response(ScratchpadEntrySerializer([row.as_dict() for row in rows], many=True).data)
@validated_request(
diff --git a/products/signals/backend/test/test_scout_harness_api.py b/products/signals/backend/test/test_scout_harness_api.py
index 4592e522f584..340d319477ed 100644
--- a/products/signals/backend/test/test_scout_harness_api.py
+++ b/products/signals/backend/test/test_scout_harness_api.py
@@ -143,6 +143,23 @@ class TestScoutHarnessRunsAPI(APIBaseTest):
expected = emitting if emitted_param == "true" else quiet
assert ids == [str(expected.id)]
+ def test_list_skill_name_filter_scopes_to_one_scout(self) -> None:
+ errors = _make_run(self.team, skill_name="signals-scout-errors")
+ _make_run(self.team, skill_name="signals-scout-llm")
+ response = self.client.get(f"{self._list_url()}?skill_name=signals-scout-errors")
+ assert response.status_code == status.HTTP_200_OK
+ ids = [row["run_id"] for row in response.json()]
+ assert ids == [str(errors.id)]
+
+ def test_list_surfaces_error_and_failure_reason_for_failed_run(self) -> None:
+ run = _make_run(self.team, task_run_status=TaskRun.Status.FAILED)
+ TaskRun.objects.filter(id=run.task_run_id).update(error_message="boom: sandbox died\nstack line 2")
+ response = self.client.get(self._list_url())
+ assert response.status_code == status.HTTP_200_OK
+ row = response.json()[0]
+ assert row["error"] == "boom: sandbox died\nstack line 2"
+ assert row["failure_reason"] == "boom: sandbox died"
+
def test_retrieve_returns_bridge_projection(self) -> None:
run = _make_run(self.team, summary="looked at /checkout, nothing actionable")
response = self.client.get(self._detail_url(str(run.id)))
@@ -362,6 +379,20 @@ class TestScoutHarnessScratchpadAPI(APIBaseTest):
keys = [row["key"] for row in response.json()]
assert keys == ["match"]
+ def test_search_keys_only_blanks_content(self) -> None:
+ SignalScratchpad.objects.create(team=self.team, key="k1", content="a long body")
+ response = self.client.get(f"{self._list_url()}?keys_only=true")
+ assert response.status_code == status.HTTP_200_OK
+ row = response.json()[0]
+ assert row["key"] == "k1"
+ assert row["content"] == ""
+
+ def test_search_content_max_chars_truncates_preview(self) -> None:
+ SignalScratchpad.objects.create(team=self.team, key="k1", content="abcdefghij")
+ response = self.client.get(f"{self._list_url()}?content_max_chars=4")
+ assert response.status_code == status.HTTP_200_OK
+ assert response.json()[0]["content"] == "abcd"
+
def test_search_does_not_leak_other_teams_memory(self) -> None:
other = Team.objects.create(organization=self.organization, name="Other")
SignalScratchpad.objects.create(team=other, key="theirs", content="leaked?")
diff --git a/products/signals/backend/test/test_scout_harness_tools.py b/products/signals/backend/test/test_scout_harness_tools.py
index 053d934c81cc..bb75739d1a32 100644
--- a/products/signals/backend/test/test_scout_harness_tools.py
+++ b/products/signals/backend/test/test_scout_harness_tools.py
@@ -36,7 +36,7 @@ from products.signals.backend.scout_harness.tools.emit import (
_validate_inputs,
emit_finding_sync,
)
-from products.signals.backend.scout_harness.tools.runs import MAX_RUN_SEARCH_LIMIT
+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 (
MAX_SCRATCHPAD_CONTENT_LENGTH,
MAX_SCRATCHPAD_SEARCH_LIMIT,
@@ -200,6 +200,73 @@ class TestSearchRecentRuns(BaseTest):
assert len(hits) == 2
+ def test_skill_name_filter_scopes_to_one_scout(self) -> None:
+ errors = _create_run(self.team, skill_name="signals-scout-errors")
+ _create_run(self.team, skill_name="signals-scout-llm")
+
+ hits = search_recent_runs(team_id=self.team.id, skill_name="signals-scout-errors")
+
+ assert [h.run_id for h in hits] == [str(errors.id)]
+
+ def test_skill_version_filter_pins_one_version(self) -> None:
+ v1 = _create_run(self.team, skill_name="signals-scout-errors", skill_version=1)
+ _create_run(self.team, skill_name="signals-scout-errors", skill_version=2)
+
+ hits = search_recent_runs(team_id=self.team.id, skill_name="signals-scout-errors", skill_version=1)
+
+ assert [h.run_id for h in hits] == [str(v1.id)]
+
+ def test_failure_reason_and_error_surface_for_failed_run(self) -> None:
+ run = _create_run(self.team, task_run_status=TaskRun.Status.FAILED)
+ TaskRun.objects.filter(id=run.task_run_id).update(error_message="boom: sandbox died\nstack line 2")
+
+ hit = search_recent_runs(team_id=self.team.id, limit=1)[0]
+
+ assert hit.error == "boom: sandbox died\nstack line 2"
+ # Derived reason is the bounded first line only.
+ assert hit.failure_reason == "boom: sandbox died"
+ detail = get_run(team_id=self.team.id, run_id=str(run.id))
+ assert detail is not None
+ assert detail.failure_reason == "boom: sandbox died"
+
+ def test_failure_reason_falls_back_when_no_error_message(self) -> None:
+ run = _create_run(self.team, task_run_status=TaskRun.Status.CANCELLED)
+
+ hit = search_recent_runs(team_id=self.team.id, limit=1)[0]
+
+ assert hit.error is None
+ assert hit.failure_reason == "cancelled"
+ assert hit.run_id == str(run.id)
+
+ def test_no_failure_reason_for_completed_run(self) -> None:
+ _create_run(self.team, task_run_status=TaskRun.Status.COMPLETED)
+
+ hit = search_recent_runs(team_id=self.team.id, limit=1)[0]
+
+ assert hit.error is None
+ assert hit.failure_reason is None
+
+ def test_completed_run_with_error_message_does_not_surface_error(self) -> None:
+ # A stray error_message on a run that still reached COMPLETED must not surface as a
+ # failure signal — `error` and `failure_reason` are gated on terminal-failure status.
+ run = _create_run(self.team, task_run_status=TaskRun.Status.COMPLETED)
+ TaskRun.objects.filter(id=run.task_run_id).update(error_message="transient warning, recovered")
+
+ hit = search_recent_runs(team_id=self.team.id, limit=1)[0]
+
+ assert hit.error is None
+ assert hit.failure_reason is None
+
+ def test_failure_reason_truncated_to_max_length(self) -> None:
+ run = _create_run(self.team, task_run_status=TaskRun.Status.FAILED)
+ long_message = "x" * (MAX_FAILURE_REASON_LENGTH + 50)
+ TaskRun.objects.filter(id=run.task_run_id).update(error_message=long_message)
+
+ hit = search_recent_runs(team_id=self.team.id, limit=1)[0]
+
+ assert hit.error == long_message # full message preserved
+ assert len(hit.failure_reason or "") == MAX_FAILURE_REASON_LENGTH # derived reason bounded
+
class TestGetRun(BaseTest):
def test_returns_full_run_payload(self) -> None:
@@ -338,6 +405,35 @@ class TestSearchScratchpad(BaseTest):
assert len(results) == MAX_SCRATCHPAD_SEARCH_LIMIT
+ def test_keys_only_blanks_content_but_keeps_keys(self) -> None:
+ remember(team_id=self.team.id, key="k1", content="a long body the caller doesn't need yet")
+
+ results = search_scratchpad(team_id=self.team.id, keys_only=True)
+
+ assert [e.key for e in results] == ["k1"]
+ assert results[0].content == ""
+
+ def test_content_max_chars_truncates_to_preview(self) -> None:
+ remember(team_id=self.team.id, key="k1", content="abcdefghij")
+
+ results = search_scratchpad(team_id=self.team.id, content_max_chars=4)
+
+ assert results[0].content == "abcd"
+
+ def test_keys_only_takes_precedence_over_content_max_chars(self) -> None:
+ remember(team_id=self.team.id, key="k1", content="abcdefghij")
+
+ results = search_scratchpad(team_id=self.team.id, keys_only=True, content_max_chars=4)
+
+ assert results[0].content == ""
+
+ def test_content_returned_in_full_by_default(self) -> None:
+ remember(team_id=self.team.id, key="k1", content="abcdefghij")
+
+ results = search_scratchpad(team_id=self.team.id)
+
+ assert results[0].content == "abcdefghij"
+
# --- emit adapter tests ---
diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.ts
index f580cce5b183..2b9a7d6c72db 100644
--- a/products/signals/frontend/generated/api.schemas.ts
+++ b/products/signals/frontend/generated/api.schemas.ts
@@ -784,6 +784,16 @@ export interface SignalScoutRunSummaryApi {
task_url?: string | null
/** One-paragraph close-out the scout wrote at end-of-run. Empty string for runs that errored before close-out. The dedupe key for non-emitting runs. */
summary: string
+ /**
+ * Full `error_message` from the linked TaskRun, surfaced only for failed/cancelled runs (null otherwise, including on success). Use `failure_reason` for a concise scan-friendly summary.
+ * @nullable
+ */
+ error?: string | null
+ /**
+ * Concise derived reason the run didn't complete cleanly — the first line of `error` (bounded), or a status-derived fallback. Null unless the run terminated failed/cancelled. Read this to see at a glance *why* a run emitted nothing without pulling full stack traces.
+ * @nullable
+ */
+ failure_reason?: string | null
/** Number of findings this run actually emitted to the inbox. 0 for runs that investigated but surfaced nothing, or ran dry-run / before AI approval. `> 0` means the run produced at least one `Signal`. */
emitted_count: number
/** The `finding_id`s behind `emitted_count`, in emit order. Each maps to a `Signal` with `source_id = run:<run_id>:finding:<finding_id>`. Empty for non-emitting runs. */
@@ -828,6 +838,16 @@ export interface SignalScoutRunDetailApi {
task_url?: string | null
/** One-paragraph close-out the scout wrote at end-of-run. Empty string for runs that errored before close-out. The dedupe key for non-emitting runs. */
summary: string
+ /**
+ * Full `error_message` from the linked TaskRun, surfaced only for failed/cancelled runs (null otherwise, including on success). Use `failure_reason` for a concise scan-friendly summary.
+ * @nullable
+ */
+ error?: string | null
+ /**
+ * Concise derived reason the run didn't complete cleanly — the first line of `error` (bounded), or a status-derived fallback. Null unless the run terminated failed/cancelled. Read this to see at a glance *why* a run emitted nothing without pulling full stack traces.
+ * @nullable
+ */
+ failure_reason?: string | null
/** Number of findings this run actually emitted to the inbox. 0 for runs that investigated but surfaced nothing, or ran dry-run / before AI approval. `> 0` means the run produced at least one `Signal`. */
emitted_count: number
/** The `finding_id`s behind `emitted_count`, in emit order. Each maps to a `Signal` with `source_id = run:<run_id>:finding:<finding_id>`. Empty for non-emitting runs. */
@@ -981,7 +1001,7 @@ export interface EmitFindingResponseApi {
export interface ScratchpadEntryApi {
/** Agent-chosen semantic key, unique per team. */
key: string
- /** Prose content for prompt injection. */
+ /** Prose content for prompt injection. Blank when the search projected it out (`keys_only=true`); truncated to a preview when `content_max_chars` was set. */
content: string
/**
* ISO-8601 creation timestamp.
@@ -1237,6 +1257,16 @@ export type SignalsScoutRunsListParams = {
* @maximum 100
*/
limit?: number
+ /**
+ * Exact-match filter on the scout skill (e.g. `signals-scout-errors`). Narrows the run dump to a single scout — the primary scoping path when a specialist dedupes against its own past runs. Omit to span every scout on the team.
+ * @minLength 1
+ */
+ skill_name?: string
+ /**
+ * Exact-match filter on the skill version. Pair with `skill_name` to pin one version; omit for all.
+ * @minimum 1
+ */
+ skill_version?: number
/**
* Case-insensitive substring match on the scout's end-of-run `summary`. Omit to skip the filter.
* @minLength 1
@@ -1245,6 +1275,15 @@ export type SignalsScoutRunsListParams = {
}
export type SignalsScoutScratchpadSearchParams = {
+ /**
+ * Truncate each entry's `content` to the first N characters (a preview). Omit for the full body. Ignored when `keys_only=true`.
+ * @minimum 0
+ */
+ content_max_chars?: number
+ /**
+ * When true, blank each entry's `content` and return only keys + metadata. Use to scan which memories exist without pulling their (potentially large) bodies, then re-query the ones worth a full read. Takes precedence over `content_max_chars`.
+ */
+ keys_only?: boolean
/**
* Max rows to return (default 20, hard cap 100).
* @minimum 1
diff --git a/products/signals/frontend/generated/api.ts b/products/signals/frontend/generated/api.ts
index 163c1417c0c9..fef7318b18f4 100644
--- a/products/signals/frontend/generated/api.ts
+++ b/products/signals/frontend/generated/api.ts
@@ -291,7 +291,7 @@ export const getSignalsScoutRunsListUrl = (projectId: string, params?: SignalsSc
}
/**
- * Return the most recent `SignalScoutRun` summaries for this project, newest first. Used by the headless scout to dedupe against work other runs already covered. ILIKE matches on `summary`. `date_from` / `date_to` are a half-open window on `created_at` (`>= date_from`, `< date_to`); pass `date_to` on subsequent calls to walk past the 100-row cap. Pass `emitted=true` to see only runs that surfaced at least one finding. Results capped at 100.
+ * Return the most recent `SignalScoutRun` summaries for this project, newest first. Used by the headless scout to dedupe against work other runs already covered. ILIKE matches on `summary`. `date_from` / `date_to` are a half-open window on `created_at` (`>= date_from`, `< date_to`); pass `date_to` on subsequent calls to walk past the 100-row cap. Pass `emitted=true` to see only runs that surfaced at least one finding. Pass `skill_name` (optionally with `skill_version`) to scope to a single scout. Results capped at 100.
* @summary Search recent agent runs
*/
export const signalsScoutRunsList = async (
@@ -305,8 +305,8 @@ export const signalsScoutRunsList = async (
})
}
-export const getSignalsScoutRunsRetrieveUrl = (projectId: string, id: string) => {
- return `/api/projects/${projectId}/signals/scout/runs/${id}/`
+export const getSignalsScoutRunsRetrieveUrl = (projectId: string, runId: string) => {
+ return `/api/projects/${projectId}/signals/scout/runs/${runId}/`
}
/**
@@ -315,17 +315,17 @@ export const getSignalsScoutRunsRetrieveUrl = (projectId: string, id: string) =>
*/
export const signalsScoutRunsRetrieve = async (
projectId: string,
- id: string,
+ runId: string,
options?: RequestInit
): Promise<SignalScoutRunDetailApi> => {
- return apiMutator<SignalScoutRunDetailApi>(getSignalsScoutRunsRetrieveUrl(projectId, id), {
+ return apiMutator<SignalScoutRunDetailApi>(getSignalsScoutRunsRetrieveUrl(projectId, runId), {
...options,
method: 'GET',
})
}
-export const getSignalsScoutRunsEmissionsUrl = (projectId: string, id: string) => {
- return `/api/projects/${projectId}/signals/scout/runs/${id}/emissions/`
+export const getSignalsScoutRunsEmissionsUrl = (projectId: string, runId: string) => {
+ return `/api/projects/${projectId}/signals/scout/runs/${runId}/emissions/`
}
/**
@@ -334,17 +334,17 @@ export const getSignalsScoutRunsEmissionsUrl = (projectId: string, id: string) =
*/
export const signalsScoutRunsEmissions = async (
projectId: string,
- id: string,
+ runId: string,
options?: RequestInit
): Promise<SignalScoutEmissionApi[]> => {
- return apiMutator<SignalScoutEmissionApi[]>(getSignalsScoutRunsEmissionsUrl(projectId, id), {
+ return apiMutator<SignalScoutEmissionApi[]>(getSignalsScoutRunsEmissionsUrl(projectId, runId), {
...options,
method: 'GET',
})
}
-export const getSignalsScoutEmitSignalUrl = (projectId: string, id: string) => {
- return `/api/projects/${projectId}/signals/scout/runs/${id}/emit-signal/`
+export const getSignalsScoutEmitSignalUrl = (projectId: string, runId: string) => {
+ return `/api/projects/${projectId}/signals/scout/runs/${runId}/emit-signal/`
}
/**
@@ -353,11 +353,11 @@ export const getSignalsScoutEmitSignalUrl = (projectId: string, id: string) => {
*/
export const signalsScoutEmitSignal = async (
projectId: string,
- id: string,
+ runId: string,
emitFindingRequestApi: EmitFindingRequestApi,
options?: RequestInit
): Promise<EmitFindingResponseApi> => {
- return apiMutator<EmitFindingResponseApi>(getSignalsScoutEmitSignalUrl(projectId, id), {
+ return apiMutator<EmitFindingResponseApi>(getSignalsScoutEmitSignalUrl(projectId, runId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
@@ -382,7 +382,7 @@ export const getSignalsScoutScratchpadSearchUrl = (projectId: string, params?: S
}
/**
- * Return `SignalScratchpad` entries for this project. ILIKE matches on `content` and `key`.
+ * Return `SignalScratchpad` entries for this project. ILIKE matches on `content` and `key`. Pass `keys_only=true` to scan keys without pulling entry bodies, or `content_max_chars` to cap each `content` to a preview — both keep a wide orientation scan from returning every entry's full prose.
* @summary Search the scout scratchpad
*/
export const signalsScoutScratchpadSearch = async (
diff --git a/products/signals/mcp/tools.yaml b/products/signals/mcp/tools.yaml
index 3459e9bd5f3f..2a1d33c7df88 100644
--- a/products/signals/mcp/tools.yaml
+++ b/products/signals/mcp/tools.yaml
@@ -274,11 +274,14 @@ tools:
description: >
Return the most recent `SignalScoutRun` summaries for this project, newest first. Used by the headless scout
to dedupe against work other runs already covered. Each row carries `emitted_count` (how many findings the
- run surfaced to the inbox) and `emitted_finding_ids`. Pass `emitted=true` to return only runs that emitted
- at least one finding (or `emitted=false` for runs that surfaced nothing). Pass `text` for a case-insensitive
- substring match on the run's `summary` (the primary dedupe key for runs that didn't emit findings). Pass
- `date_from` / `date_to` (ISO-8601, inclusive lower / exclusive upper bound on `created_at`) to scope to a
- window. Results capped at 100.
+ run surfaced to the inbox), `emitted_finding_ids`, and — for runs that didn't complete cleanly — `error`
+ (full TaskRun error) plus `failure_reason` (a concise derived one-liner). Pass `skill_name` (optionally with
+ `skill_version`) to scope the dump to a single scout instead of every scout on the team — the primary
+ scoping path when a specialist dedupes against its own past runs. Pass `emitted=true` to return only runs
+ that emitted at least one finding (or `emitted=false` for runs that surfaced nothing). Pass `text` for a
+ case-insensitive substring match on the run's `summary` (the primary dedupe key for runs that didn't emit
+ findings). Pass `date_from` / `date_to` (ISO-8601, inclusive lower / exclusive upper bound on `created_at`)
+ to scope to a window. Results capped at 100.
signals-scout-runs-retrieve:
operation: signals_scout_runs_retrieve
enabled: true
@@ -290,10 +293,11 @@ tools:
idempotent: true
title: Get a scout run by ID
description: >
- Return the full `SignalScoutRun` row, including the agent's end-of-run `summary`, `emitted_count`, and
- `emitted_finding_ids`. Status, timestamps, and error flow from the linked `tasks.TaskRun`; emitted findings
- live as `Signal` rows queryable by `source_id = run:<run_id>:finding:<finding_id>` (one per id in
- `emitted_finding_ids`). Strictly team-scoped — a UUID belonging to another team returns 404.
+ Return the full `SignalScoutRun` row for the given `run_id`, including the agent's end-of-run `summary`,
+ `emitted_count`, and `emitted_finding_ids`. Status, timestamps, `error` (full TaskRun error message), and
+ the derived `failure_reason` flow from the linked `tasks.TaskRun`; emitted findings live as `Signal` rows
+ queryable by `source_id = run:<run_id>:finding:<finding_id>` (one per id in `emitted_finding_ids`). Strictly
+ team-scoped — a UUID belonging to another team returns 404.
signals-scout-scratchpad-forget:
operation: signals_scout_scratchpad_forget
enabled: true
@@ -332,7 +336,9 @@ tools:
title: Search the scout scratchpad
description: >
Return `SignalScratchpad` entries for this project, newest first. Pass `text` for a case-insensitive
- substring match on the entry's `content` and `key`. Results capped at 100.
+ substring match on the entry's `content` and `key`. Pass `keys_only=true` to scan which memories exist
+ without pulling their (potentially large) bodies, or `content_max_chars` to cap each `content` to a preview
+ — both keep a wide orientation/dedupe scan from returning every entry's full prose. Results capped at 100.
users-signal-autonomy-create:
operation: users_signal_autonomy_create
enabled: false
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index d121699b964e..2b1f69ad6182 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -5132,7 +5132,7 @@
}
},
"signals-scout-runs-list": {
- "description": "Return the most recent `SignalScoutRun` summaries for this project, newest first. Used by the headless scout to dedupe against work other runs already covered. Each row carries `emitted_count` (how many findings the run surfaced to the inbox) and `emitted_finding_ids`. Pass `emitted=true` to return only runs that emitted at least one finding (or `emitted=false` for runs that surfaced nothing). Pass `text` for a case-insensitive substring match on the run's `summary` (the primary dedupe key for runs that didn't emit findings). Pass `date_from` / `date_to` (ISO-8601, inclusive lower / exclusive upper bound on `created_at`) to scope to a window. Results capped at 100.",
+ "description": "Return the most recent `SignalScoutRun` summaries for this project, newest first. Used by the headless scout to dedupe against work other runs already covered. Each row carries `emitted_count` (how many findings the run surfaced to the inbox), `emitted_finding_ids`, and — for runs that didn't complete cleanly — `error` (full TaskRun error) plus `failure_reason` (a concise derived one-liner). Pass `skill_name` (optionally with `skill_version`) to scope the dump to a single scout instead of every scout on the team — the primary scoping path when a specialist dedupes against its own past runs. Pass `emitted=true` to return only runs that emitted at least one finding (or `emitted=false` for runs that surfaced nothing). Pass `text` for a case-insensitive substring match on the run's `summary` (the primary dedupe key for runs that didn't emit findings). Pass `date_from` / `date_to` (ISO-8601, inclusive lower / exclusive upper bound on `created_at`) to scope to a window. Results capped at 100.",
"category": "Signals",
"feature": "signals",
"summary": "List recent scout runs",
@@ -5146,7 +5146,7 @@
}
},
"signals-scout-runs-retrieve": {
- "description": "Return the full `SignalScoutRun` row, including the agent's end-of-run `summary`, `emitted_count`, and `emitted_finding_ids`. Status, timestamps, and error flow from the linked `tasks.TaskRun`; emitted findings live as `Signal` rows queryable by `source_id = run:<run_id>:finding:<finding_id>` (one per id in `emitted_finding_ids`). Strictly team-scoped — a UUID belonging to another team returns 404.",
+ "description": "Return the full `SignalScoutRun` row for the given `run_id`, including the agent's end-of-run `summary`, `emitted_count`, and `emitted_finding_ids`. Status, timestamps, `error` (full TaskRun error message), and the derived `failure_reason` flow from the linked `tasks.TaskRun`; emitted findings live as `Signal` rows queryable by `source_id = run:<run_id>:finding:<finding_id>` (one per id in `emitted_finding_ids`). Strictly team-scoped — a UUID belonging to another team returns 404.",
"category": "Signals",
"feature": "signals",
"summary": "Get a scout run by ID",
@@ -5188,7 +5188,7 @@
}
},
"signals-scout-scratchpad-search": {
- "description": "Return `SignalScratchpad` entries for this project, newest first. Pass `text` for a case-insensitive substring match on the entry's `content` and `key`. Results capped at 100.",
+ "description": "Return `SignalScratchpad` entries for this project, newest first. Pass `text` for a case-insensitive substring match on the entry's `content` and `key`. Pass `keys_only=true` to scan which memories exist without pulling their (potentially large) bodies, or `content_max_chars` to cap each `content` to a preview — both keep a wide orientation/dedupe scan from returning every entry's full prose. Results capped at 100.",
"category": "Signals",
"feature": "signals",
"summary": "Search the scout scratchpad",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 9cb12ed85e3f..1e62b7fce3dd 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -5473,7 +5473,7 @@
}
},
"signals-scout-runs-list": {
- "description": "Return the most recent `SignalScoutRun` summaries for this project, newest first. Used by the headless scout to dedupe against work other runs already covered. Each row carries `emitted_count` (how many findings the run surfaced to the inbox) and `emitted_finding_ids`. Pass `emitted=true` to return only runs that emitted at least one finding (or `emitted=false` for runs that surfaced nothing). Pass `text` for a case-insensitive substring match on the run's `summary` (the primary dedupe key for runs that didn't emit findings). Pass `date_from` / `date_to` (ISO-8601, inclusive lower / exclusive upper bound on `created_at`) to scope to a window. Results capped at 100.",
+ "description": "Return the most recent `SignalScoutRun` summaries for this project, newest first. Used by the headless scout to dedupe against work other runs already covered. Each row carries `emitted_count` (how many findings the run surfaced to the inbox), `emitted_finding_ids`, and — for runs that didn't complete cleanly — `error` (full TaskRun error) plus `failure_reason` (a concise derived one-liner). Pass `skill_name` (optionally with `skill_version`) to scope the dump to a single scout instead of every scout on the team — the primary scoping path when a specialist dedupes against its own past runs. Pass `emitted=true` to return only runs that emitted at least one finding (or `emitted=false` for runs that surfaced nothing). Pass `text` for a case-insensitive substring match on the run's `summary` (the primary dedupe key for runs that didn't emit findings). Pass `date_from` / `date_to` (ISO-8601, inclusive lower / exclusive upper bound on `created_at`) to scope to a window. Results capped at 100.",
"category": "Signals",
"feature": "signals",
"summary": "List recent scout runs",
@@ -5487,7 +5487,7 @@
}
},
"signals-scout-runs-retrieve": {
- "description": "Return the full `SignalScoutRun` row, including the agent's end-of-run `summary`, `emitted_count`, and `emitted_finding_ids`. Status, timestamps, and error flow from the linked `tasks.TaskRun`; emitted findings live as `Signal` rows queryable by `source_id = run:<run_id>:finding:<finding_id>` (one per id in `emitted_finding_ids`). Strictly team-scoped — a UUID belonging to another team returns 404.",
+ "description": "Return the full `SignalScoutRun` row for the given `run_id`, including the agent's end-of-run `summary`, `emitted_count`, and `emitted_finding_ids`. Status, timestamps, `error` (full TaskRun error message), and the derived `failure_reason` flow from the linked `tasks.TaskRun`; emitted findings live as `Signal` rows queryable by `source_id = run:<run_id>:finding:<finding_id>` (one per id in `emitted_finding_ids`). Strictly team-scoped — a UUID belonging to another team returns 404.",
"category": "Signals",
"feature": "signals",
"summary": "Get a scout run by ID",
@@ -5529,7 +5529,7 @@
}
},
"signals-scout-scratchpad-search": {
- "description": "Return `SignalScratchpad` entries for this project, newest first. Pass `text` for a case-insensitive substring match on the entry's `content` and `key`. Results capped at 100.",
+ "description": "Return `SignalScratchpad` entries for this project, newest first. Pass `text` for a case-insensitive substring match on the entry's `content` and `key`. Pass `keys_only=true` to scan which memories exist without pulling their (potentially large) bodies, or `content_max_chars` to cap each `content` to a preview — both keep a wide orientation/dedupe scan from returning every entry's full prose. Results capped at 100.",
"category": "Signals",
"feature": "signals",
"summary": "Search the scout scratchpad",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 9767d916fa58..866a4ca9e79b 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -39143,7 +39143,7 @@ export namespace Schemas {
export interface ScratchpadEntry {
/** Agent-chosen semantic key, unique per team. */
key: string;
- /** Prose content for prompt injection. */
+ /** Prose content for prompt injection. Blank when the search projected it out (`keys_only=true`); truncated to a preview when `content_max_chars` was set. */
content: string;
/**
* ISO-8601 creation timestamp.
@@ -39625,6 +39625,16 @@ export namespace Schemas {
task_url?: string | null;
/** One-paragraph close-out the scout wrote at end-of-run. Empty string for runs that errored before close-out. The dedupe key for non-emitting runs. */
summary: string;
+ /**
+ * Full `error_message` from the linked TaskRun, surfaced only for failed/cancelled runs (null otherwise, including on success). Use `failure_reason` for a concise scan-friendly summary.
+ * @nullable
+ */
+ error?: string | null;
+ /**
+ * Concise derived reason the run didn't complete cleanly — the first line of `error` (bounded), or a status-derived fallback. Null unless the run terminated failed/cancelled. Read this to see at a glance *why* a run emitted nothing without pulling full stack traces.
+ * @nullable
+ */
+ failure_reason?: string | null;
/** Number of findings this run actually emitted to the inbox. 0 for runs that investigated but surfaced nothing, or ran dry-run / before AI approval. `> 0` means the run produced at least one `Signal`. */
emitted_count: number;
/** The `finding_id`s behind `emitted_count`, in emit order. Each maps to a `Signal` with `source_id = run:<run_id>:finding:<finding_id>`. Empty for non-emitting runs. */
@@ -39669,6 +39679,16 @@ export namespace Schemas {
task_url?: string | null;
/** One-paragraph close-out the scout wrote at end-of-run. Empty string for runs that errored before close-out. The dedupe key for non-emitting runs. */
summary: string;
+ /**
+ * Full `error_message` from the linked TaskRun, surfaced only for failed/cancelled runs (null otherwise, including on success). Use `failure_reason` for a concise scan-friendly summary.
+ * @nullable
+ */
+ error?: string | null;
+ /**
+ * Concise derived reason the run didn't complete cleanly — the first line of `error` (bounded), or a status-derived fallback. Null unless the run terminated failed/cancelled. Read this to see at a glance *why* a run emitted nothing without pulling full stack traces.
+ * @nullable
+ */
+ failure_reason?: string | null;
/** Number of findings this run actually emitted to the inbox. 0 for runs that investigated but surfaced nothing, or ran dry-run / before AI approval. `> 0` means the run produced at least one `Signal`. */
emitted_count: number;
/** The `finding_id`s behind `emitted_count`, in emit order. Each maps to a `Signal` with `source_id = run:<run_id>:finding:<finding_id>`. Empty for non-emitting runs. */
@@ -52781,6 +52801,16 @@ export namespace Schemas {
* @maximum 100
*/
limit?: number;
+ /**
+ * Exact-match filter on the scout skill (e.g. `signals-scout-errors`). Narrows the run dump to a single scout — the primary scoping path when a specialist dedupes against its own past runs. Omit to span every scout on the team.
+ * @minLength 1
+ */
+ skill_name?: string;
+ /**
+ * Exact-match filter on the skill version. Pair with `skill_name` to pin one version; omit for all.
+ * @minimum 1
+ */
+ skill_version?: number;
/**
* Case-insensitive substring match on the scout's end-of-run `summary`. Omit to skip the filter.
* @minLength 1
@@ -52789,6 +52819,15 @@ export namespace Schemas {
};
export type SignalsScoutScratchpadSearchParams = {
+ /**
+ * Truncate each entry's `content` to the first N characters (a preview). Omit for the full body. Ignored when `keys_only=true`.
+ * @minimum 0
+ */
+ content_max_chars?: number;
+ /**
+ * When true, blank each entry's `content` and return only keys + metadata. Use to scan which memories exist without pulling their (potentially large) bodies, then re-query the ones worth a full read. Takes precedence over `content_max_chars`.
+ */
+ keys_only?: boolean;
/**
* Max rows to return (default 20, hard cap 100).
* @minimum 1
diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.ts
index 7a9ca1bafe7e..ed9cc3559d89 100644
--- a/services/mcp/src/generated/signals/api.ts
+++ b/services/mcp/src/generated/signals/api.ts
@@ -196,7 +196,7 @@ export const SignalsScoutProjectProfileGetQueryParams = /* @__PURE__ */ zod.obje
})
/**
- * Return the most recent `SignalScoutRun` summaries for this project, newest first. Used by the headless scout to dedupe against work other runs already covered. ILIKE matches on `summary`. `date_from` / `date_to` are a half-open window on `created_at` (`>= date_from`, `< date_to`); pass `date_to` on subsequent calls to walk past the 100-row cap. Pass `emitted=true` to see only runs that surfaced at least one finding. Results capped at 100.
+ * Return the most recent `SignalScoutRun` summaries for this project, newest first. Used by the headless scout to dedupe against work other runs already covered. ILIKE matches on `summary`. `date_from` / `date_to` are a half-open window on `created_at` (`>= date_from`, `< date_to`); pass `date_to` on subsequent calls to walk past the 100-row cap. Pass `emitted=true` to see only runs that surfaced at least one finding. Pass `skill_name` (optionally with `skill_version`) to scope to a single scout. Results capped at 100.
* @summary Search recent agent runs
*/
export const SignalsScoutRunsListParams = /* @__PURE__ */ zod.object({
@@ -232,6 +232,18 @@ export const SignalsScoutRunsListQueryParams = /* @__PURE__ */ zod.object({
.max(signalsScoutRunsListQueryLimitMax)
.optional()
.describe('Max rows to return (default 20, hard cap 100).'),
+ skill_name: zod
+ .string()
+ .min(1)
+ .optional()
+ .describe(
+ 'Exact-match filter on the scout skill (e.g. `signals-scout-errors`). Narrows the run dump to a single scout — the primary scoping path when a specialist dedupes against its own past runs. Omit to span every scout on the team.'
+ ),
+ skill_version: zod
+ .number()
+ .min(1)
+ .optional()
+ .describe('Exact-match filter on the skill version. Pair with `skill_name` to pin one version; omit for all.'),
text: zod
.string()
.min(1)
@@ -244,12 +256,12 @@ export const SignalsScoutRunsListQueryParams = /* @__PURE__ */ zod.object({
* @summary Get a run by ID
*/
export const SignalsScoutRunsRetrieveParams = /* @__PURE__ */ zod.object({
- id: zod.string().describe('A UUID string identifying this Signal scout run.'),
project_id: zod
.string()
.describe(
"Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/."
),
+ run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
})
/**
@@ -257,12 +269,12 @@ export const SignalsScoutRunsRetrieveParams = /* @__PURE__ */ zod.object({
* @summary List a run's emitted findings
*/
export const SignalsScoutRunsEmissionsParams = /* @__PURE__ */ zod.object({
- id: zod.string().describe('A UUID string identifying this Signal scout run.'),
project_id: zod
.string()
.describe(
"Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/."
),
+ run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
})
/**
@@ -270,12 +282,12 @@ export const SignalsScoutRunsEmissionsParams = /* @__PURE__ */ zod.object({
* @summary Emit a finding for a run
*/
export const SignalsScoutEmitSignalParams = /* @__PURE__ */ zod.object({
- id: zod.string().describe('A UUID string identifying this Signal scout run.'),
project_id: zod
.string()
.describe(
"Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/."
),
+ run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
})
export const signalsScoutEmitSignalBodyDescriptionMax = 50000
@@ -357,7 +369,7 @@ export const SignalsScoutEmitSignalBody = /* @__PURE__ */ zod
.describe('Request body for `emit-finding`. Run attribution is taken from the URL path.')
/**
- * Return `SignalScratchpad` entries for this project. ILIKE matches on `content` and `key`.
+ * Return `SignalScratchpad` entries for this project. ILIKE matches on `content` and `key`. Pass `keys_only=true` to scan keys without pulling entry bodies, or `content_max_chars` to cap each `content` to a preview — both keep a wide orientation scan from returning every entry's full prose.
* @summary Search the scout scratchpad
*/
export const SignalsScoutScratchpadSearchParams = /* @__PURE__ */ zod.object({
@@ -368,9 +380,24 @@ export const SignalsScoutScratchpadSearchParams = /* @__PURE__ */ zod.object({
),
})
+export const signalsScoutScratchpadSearchQueryContentMaxCharsMin = 0
+
export const signalsScoutScratchpadSearchQueryLimitMax = 100
export const SignalsScoutScratchpadSearchQueryParams = /* @__PURE__ */ zod.object({
+ content_max_chars: zod
+ .number()
+ .min(signalsScoutScratchpadSearchQueryContentMaxCharsMin)
+ .optional()
+ .describe(
+ "Truncate each entry's `content` to the first N characters (a preview). Omit for the full body. Ignored when `keys_only=true`."
+ ),
+ keys_only: zod
+ .boolean()
+ .optional()
+ .describe(
+ "When true, blank each entry's `content` and return only keys + metadata. Use to scan which memories exist without pulling their (potentially large) bodies, then re-query the ones worth a full read. Takes precedence over `content_max_chars`."
+ ),
limit: zod
.number()
.min(1)
diff --git a/services/mcp/src/tools/generated/signals.ts b/services/mcp/src/tools/generated/signals.ts
index 4aa35c4594f2..49df2e3054fd 100644
--- a/services/mcp/src/tools/generated/signals.ts
+++ b/services/mcp/src/tools/generated/signals.ts
@@ -370,7 +370,7 @@ const signalsScoutEmitSignal = (): ToolBase<typeof SignalsScoutEmitSignalSchema,
}
const result = await context.api.request<Schemas.EmitFindingResponse>({
method: 'POST',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/scout/runs/${encodeURIComponent(String(params.id))}/emit-signal/`,
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/scout/runs/${encodeURIComponent(String(params.run_id))}/emit-signal/`,
body,
})
return result
@@ -410,7 +410,7 @@ const signalsScoutRunsEmissionsList = (): ToolBase<
const projectId = await context.stateManager.getProjectId()
const result = await context.api.request<Schemas.SignalScoutEmission[]>({
method: 'GET',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/scout/runs/${encodeURIComponent(String(params.id))}/emissions/`,
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/scout/runs/${encodeURIComponent(String(params.run_id))}/emissions/`,
})
return await withPostHogUrl(context, result, '/inbox')
},
@@ -434,6 +434,8 @@ const signalsScoutRunsList = (): ToolBase<
date_to: params.date_to,
emitted: params.emitted,
limit: params.limit,
+ skill_name: params.skill_name,
+ skill_version: params.skill_version,
text: params.text,
},
})
@@ -450,7 +452,7 @@ const signalsScoutRunsRetrieve = (): ToolBase<typeof SignalsScoutRunsRetrieveSch
const projectId = await context.stateManager.getProjectId()
const result = await context.api.request<Schemas.SignalScoutRunDetail>({
method: 'GET',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/scout/runs/${encodeURIComponent(String(params.id))}/`,
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/scout/runs/${encodeURIComponent(String(params.run_id))}/`,
})
return result
},
@@ -522,6 +524,8 @@ const signalsScoutScratchpadSearch = (): ToolBase<
method: 'GET',
path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/scout/scratchpad/`,
query: {
+ content_max_chars: params.content_max_chars,
+ keys_only: params.keys_only,
limit: params.limit,
text: params.text,
},
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 175397fdd108..7e106ed80b53 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
@@ -73,10 +73,6 @@
],
"description": "Optional one-line hypothesis the finding tests."
},
- "id": {
- "description": "A UUID string identifying this Signal scout run.",
- "type": "string"
- },
"mcp_trace_id": {
"anyOf": [
{
@@ -88,6 +84,10 @@
],
"description": "Optional MCP trace id for cross-system debugging."
},
+ "run_id": {
+ "description": "UUID of the `SignalScoutRun` bridge row.",
+ "type": "string"
+ },
"severity": {
"anyOf": [
{
@@ -124,6 +124,6 @@
"description": "Optional time window the finding refers to."
}
},
- "required": ["id", "description", "confidence", "evidence"],
+ "required": ["run_id", "description", "confidence", "evidence"],
"type": "object"
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-runs-emissions-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-runs-emissions-list.json
index 6bf8266d32be..a03c9f830807 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-runs-emissions-list.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-runs-emissions-list.json
@@ -1,11 +1,11 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
- "id": {
- "description": "A UUID string identifying this Signal scout run.",
+ "run_id": {
+ "description": "UUID of the `SignalScoutRun` bridge row.",
"type": "string"
}
},
- "required": ["id"],
+ "required": ["run_id"],
"type": "object"
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-runs-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-runs-list.json
index 315a58ad431d..6a11adb904e9 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-runs-list.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-runs-list.json
@@ -30,6 +30,16 @@
"minimum": 1,
"type": "number"
},
+ "skill_name": {
+ "description": "Exact-match filter on the scout skill (e.g. `signals-scout-errors`). Narrows the run dump to a single scout — the primary scoping path when a specialist dedupes against its own past runs. Omit to span every scout on the team.",
+ "minLength": 1,
+ "type": "string"
+ },
+ "skill_version": {
+ "description": "Exact-match filter on the skill version. Pair with `skill_name` to pin one version; omit for all.",
+ "minimum": 1,
+ "type": "number"
+ },
"text": {
"description": "Case-insensitive substring match on the scout's end-of-run `summary`. Omit to skip the filter.",
"minLength": 1,
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-runs-retrieve.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-runs-retrieve.json
index 6bf8266d32be..a03c9f830807 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-runs-retrieve.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-runs-retrieve.json
@@ -1,11 +1,11 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
- "id": {
- "description": "A UUID string identifying this Signal scout run.",
+ "run_id": {
+ "description": "UUID of the `SignalScoutRun` bridge row.",
"type": "string"
}
},
- "required": ["id"],
+ "required": ["run_id"],
"type": "object"
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-scratchpad-search.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-scratchpad-search.json
index 7f558d76c7ed..9fbd73e912bb 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-scratchpad-search.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-scratchpad-search.json
@@ -1,6 +1,15 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
+ "content_max_chars": {
+ "description": "Truncate each entry's `content` to the first N characters (a preview). Omit for the full body. Ignored when `keys_only=true`.",
+ "minimum": 0,
+ "type": "number"
+ },
+ "keys_only": {
+ "description": "When true, blank each entry's `content` and return only keys + metadata. Use to scan which memories exist without pulling their (potentially large) bodies, then re-query the ones worth a full read. Takes precedence over `content_max_chars`.",
+ "type": "boolean"
+ },
"limit": {
"description": "Max rows to return (default 20, hard cap 100).",
"maximum": 100,