:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(signals): teach scouts to use stable scratchpad keys (#66252)
Andrew Maguire907cade49e9d
diff --git a/products/signals/backend/scout_harness/prompt.py b/products/signals/backend/scout_harness/prompt.pyindex 078bb32848e3..9ef744ee637e 100644--- a/products/signals/backend/scout_harness/prompt.py+++ b/products/signals/backend/scout_harness/prompt.py@@ -61,6 +61,28 @@ _BASE_PROMPT_TAIL = """# How a run worksfill space. The harness parses the JSON and writes `summary` to the run rowas searchable prose.+# Scratchpad keys++`remember` upserts on `key`: writing a key that already exists *overwrites it in+place*. A key is a stable identity, not a log entry — it must name the *thing*+you're tracking, never *when* you saw it. Embedding a date, timestamp, or run id+in a key mints a brand-new row every run, never reclaims the old one, and — for a+dedupe key — guarantees next run's key won't match the entity you already+surfaced, defeating the dedupe it was meant to do.++- **Run state / cursors** (a "last scan" marker, a rolling baseline, "where I got+ to") → one fixed key like `pattern:<domain>:cursor`, with the timestamp *in the+ content*. Overwrite it each run.+- **Dedupe / "already surfaced X"** → key off the stable identity of the thing —+ `dedupe:<domain>:<issue_id>`, `<account_external_id>`, `<file_path>` — with no+ date. Put the dates you saw it *in the content* ("surfaced 2026-05-01,+ re-confirmed 2026-06-09"); re-confirming updates the same row in place.+- **One row per real external item** (a specific Discord message id, a specific+ alert id) is fine — that's bounded by real events, not by time.++Good: `dedupe:error_tracking:019de34e`, `pattern:apm:cursor`.+Bad: `dedupe:error_tracking:019de34e-2026-06-09`, `pattern:apm:scan-2026-06-09-0400`.+# Recency lensDefault to recent windows (~last 72h) when querying — fresh evidence is usuallydiff --git a/products/signals/backend/scout_harness/serializers.py b/products/signals/backend/scout_harness/serializers.pyindex 4e3d19924615..3ef7ed18450e 100644--- a/products/signals/backend/scout_harness/serializers.py+++ b/products/signals/backend/scout_harness/serializers.py@@ -330,7 +330,12 @@ class RememberRequestSerializer(serializers.Serializer):key = serializers.CharField(max_length=300,- help_text="Agent-chosen semantic key. Re-using a key updates the existing entry in place.",+ help_text=(+ "Agent-chosen semantic key, unique per team; re-using a key overwrites the entry in place. "+ "Key off the *stable identity* of what you're tracking — never embed a date, timestamp, or run "+ "id (that mints a new row every run and breaks dedupe). For run state/cursors, use one fixed key "+ "and keep the timestamp in `content`."+ ),)content = serializers.CharField(max_length=MAX_SCRATCHPAD_CONTENT_LENGTH,diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.tsindex ae2a17392594..2fa41decfe4d 100644--- a/products/signals/frontend/generated/api.schemas.ts+++ b/products/signals/frontend/generated/api.schemas.ts@@ -1385,7 +1385,7 @@ export interface ScratchpadEntryApi {*/export interface RememberRequestApi {/**- * Agent-chosen semantic key. Re-using a key updates the existing entry in place.+ * Agent-chosen semantic key, unique per team; re-using a key overwrites the entry in place. Key off the *stable identity* of what you're tracking — never embed a date, timestamp, or run id (that mints a new row every run and breaks dedupe). For run state/cursors, use one fixed key and keep the timestamp in `content`.* @maxLength 300*/key: stringdiff --git a/products/signals/frontend/generated/api.zod.ts b/products/signals/frontend/generated/api.zod.tsindex 962deb096563..b75e2950a928 100644--- a/products/signals/frontend/generated/api.zod.ts+++ b/products/signals/frontend/generated/api.zod.ts@@ -345,7 +345,9 @@ export const SignalsScoutScratchpadRememberBody = /* @__PURE__ */ zodkey: zod.string().max(signalsScoutScratchpadRememberBodyKeyMax)- .describe('Agent-chosen semantic key. Re-using a key updates the existing entry in place.'),+ .describe(+ "Agent-chosen semantic key, unique per team; re-using a key overwrites the entry in place. Key off the \*stable identity\* of what you're tracking — never embed a date, timestamp, or run id (that mints a new row every run and breaks dedupe). For run state\/cursors, use one fixed key and keep the timestamp in `content`."+ ),content: zod.string().max(signalsScoutScratchpadRememberBodyContentMax)diff --git a/products/signals/mcp/tools.yaml b/products/signals/mcp/tools.yamlindex b6affa08ae40..b510a618574a 100644--- a/products/signals/mcp/tools.yaml+++ b/products/signals/mcp/tools.yaml@@ -526,7 +526,10 @@ tools:title: Remember a scratchpad entrydescription: >Upsert a scratchpad entry keyed on `(team, key)` — re-using a key updates the existing entry in place, so- this is an upsert rather than a strict create. Optionally pass `run_id` to record which run wrote it.+ this is an upsert rather than a strict create. Keys are stable identities: key off *what* you're tracking,+ not *when* you saw it — never embed dates, timestamps, or run ids (that mints a new row every run and+ defeats dedupe). For run state, use one fixed key and keep the timestamp in `content`. Optionally pass+ `run_id` to record which run wrote it.signals-scout-scratchpad-search:operation: signals_scout_scratchpad_searchenabled: truediff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 6b1026a43ca8..29c31fd6621a 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -6387,7 +6387,7 @@}},"signals-scout-scratchpad-remember": {- "description": "Upsert a scratchpad entry keyed on `(team, key)` — re-using a key updates the existing entry in place, so this is an upsert rather than a strict create. Optionally pass `run_id` to record which run wrote it.",+ "description": "Upsert a scratchpad entry keyed on `(team, key)` — re-using a key updates the existing entry in place, so this is an upsert rather than a strict create. Keys are stable identities: key off *what* you're tracking, not *when* you saw it — never embed dates, timestamps, or run ids (that mints a new row every run and defeats dedupe). For run state, use one fixed key and keep the timestamp in `content`. Optionally pass `run_id` to record which run wrote it.","category": "Signals","feature": "signals","summary": "Remember a scratchpad entry",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex ec4cf2806938..96af6b10767a 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -6896,7 +6896,7 @@}},"signals-scout-scratchpad-remember": {- "description": "Upsert a scratchpad entry keyed on `(team, key)` — re-using a key updates the existing entry in place, so this is an upsert rather than a strict create. Optionally pass `run_id` to record which run wrote it.",+ "description": "Upsert a scratchpad entry keyed on `(team, key)` — re-using a key updates the existing entry in place, so this is an upsert rather than a strict create. Keys are stable identities: key off *what* you're tracking, not *when* you saw it — never embed dates, timestamps, or run ids (that mints a new row every run and defeats dedupe). For run state, use one fixed key and keep the timestamp in `content`. Optionally pass `run_id` to record which run wrote it.","category": "Signals","feature": "signals","summary": "Remember a scratchpad entry",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 3a601922900c..23f3a4776919 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -46107,7 +46107,7 @@ export namespace Schemas {*/export interface RememberRequest {/**- * Agent-chosen semantic key. Re-using a key updates the existing entry in place.+ * Agent-chosen semantic key, unique per team; re-using a key overwrites the entry in place. Key off the *stable identity* of what you're tracking — never embed a date, timestamp, or run id (that mints a new row every run and breaks dedupe). For run state/cursors, use one fixed key and keep the timestamp in `content`.* @maxLength 300*/key: string;diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.tsindex 9905a2ad24f5..c6a08f65aa59 100644--- a/services/mcp/src/generated/signals/api.ts+++ b/services/mcp/src/generated/signals/api.ts@@ -717,7 +717,9 @@ export const SignalsScoutScratchpadRememberBody = /* @__PURE__ */ zodkey: zod.string().max(signalsScoutScratchpadRememberBodyKeyMax)- .describe('Agent-chosen semantic key. Re-using a key updates the existing entry in place.'),+ .describe(+ "Agent-chosen semantic key, unique per team; re-using a key overwrites the entry in place. Key off the *stable identity* of what you're tracking — never embed a date, timestamp, or run id (that mints a new row every run and breaks dedupe). For run state/cursors, use one fixed key and keep the timestamp in `content`."+ ),content: zod.string().max(signalsScoutScratchpadRememberBodyContentMax)diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-scratchpad-remember.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-scratchpad-remember.jsonindex 13b5087dbbb0..03ff75e32cb6 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-scratchpad-remember.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-scratchpad-remember.json@@ -8,7 +8,7 @@"type": "string"},"key": {- "description": "Agent-chosen semantic key. Re-using a key updates the existing entry in place.",+ "description": "Agent-chosen semantic key, unique per team; re-using a key overwrites the entry in place. Key off the *stable identity* of what you're tracking — never embed a date, timestamp, or run id (that mints a new row every run and breaks dedupe). For run state/cursors, use one fixed key and keep the timestamp in `content`.","maxLength": 300,"type": "string"},