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): ship a default pre-check for the surveys scout (#115058)

posthog[bot]ec8c2813c83e
diff --git a/products/replay_vision/frontend/generated/api.schemas.ts b/products/replay_vision/frontend/generated/api.schemas.ts
index 68362a05bd4a..3457005dcece 100644
--- a/products/replay_vision/frontend/generated/api.schemas.ts
+++ b/products/replay_vision/frontend/generated/api.schemas.ts
@@ -1930,7 +1930,7 @@ export interface SignalScoutConfigOptionsApi {
* * `support_notes` - Support notes */
tool_preset?: ToolPresetEnumApi
/**
- * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off.
+ * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`.
* @maxLength 10000
* @nullable
*/
@@ -2089,6 +2089,15 @@ export const SignalScoutConfigManagedByEnumApi = {
Background: 'background',
} as const
+export type ScoutPrecheckQuerySourceEnumApi =
+ (typeof ScoutPrecheckQuerySourceEnumApi)[keyof typeof ScoutPrecheckQuerySourceEnumApi]
+
+export const ScoutPrecheckQuerySourceEnumApi = {
+ Config: 'config',
+ SkillDefault: 'skill_default',
+ Off: 'off',
+} as const
+
/**
* Optional JSON Schema (draft 2020-12) describing ONE structured record this scout produces via `scout-record-output` — e.g. a per-report quality judgment (`{"type": "object", "properties": {"verdict": {"enum": ["good", "bad", "unsure"]}, "reason": {"type": "string"}}, "required": ["verdict", "reason"]}`). The root must be `"type": "object"`. Setting a schema turns the structured-output channel on: the run prompt renders the schema and every submitted record is validated against it and recorded in the project as a `$scout_structured_output` event, queryable like any event. The channel also requires emit — a dry-run scout has nowhere to record to. Cardinality is the scout's call (one record per run, one per judged entity, ...). Null = channel off. Setting a schema requires skill-authoring authorization (the `llm_skill:write` scope and skill editor access) since the scout reads it verbatim in its prompt; clearing it needs only the config write. Records validate against the schema in force when the run was dispatched.
* @nullable
@@ -2201,10 +2210,19 @@ export interface SignalScoutConfigApi {
*/
readonly tool_preset: string | null
/**
- * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off.
+ * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`.
* @nullable
*/
readonly precheck_query: string | null
+ /** True turns off the pre-check, both `precheck_query` and the default the skill ships, so every scheduled run starts. False (the default) uses `precheck_query`, or the skill default when that is null. */
+ readonly precheck_disabled: boolean
+ /**
+ * The pre-check query the next scheduled run uses: `precheck_query`, or the default the scout's skill ships. Null when no pre-check runs.
+ * @nullable
+ */
+ readonly effective_precheck_query: string | null
+ /** Where `effective_precheck_query` comes from: `config` (this scout's `precheck_query`), `skill_default` (the default its skill ships), or `off` (no pre-check runs). */
+ readonly precheck_query_source: ScoutPrecheckQuerySourceEnumApi
/**
* When the coordinator last dispatched this scout. Null if it has never run.
* @nullable
diff --git a/products/replay_vision/frontend/generated/api.zod.ts b/products/replay_vision/frontend/generated/api.zod.ts
index 02213e3db815..9380bc253a3b 100644
--- a/products/replay_vision/frontend/generated/api.zod.ts
+++ b/products/replay_vision/frontend/generated/api.zod.ts
@@ -1058,7 +1058,7 @@ export const VisionScannersScoutsCreateBody = /* @__PURE__ */ zod
.max(visionScannersScoutsCreateBodyConfigOnePrecheckQueryMax)
.nullish()
.describe(
- "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off."
+ "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 \* {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
),
enabled: zod
.boolean()
diff --git a/products/signals/backend/migrations/0172_signalscoutconfig_precheck_disabled.py b/products/signals/backend/migrations/0172_signalscoutconfig_precheck_disabled.py
new file mode 100644
index 000000000000..0df306e62607
--- /dev/null
+++ b/products/signals/backend/migrations/0172_signalscoutconfig_precheck_disabled.py
@@ -0,0 +1,15 @@
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("signals", "0171_drop_signalscoutemission_weight_confidence"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="signalscoutconfig",
+ name="precheck_disabled",
+ field=models.BooleanField(db_default=False, default=False),
+ ),
+ ]
diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txt
index a52388970b6c..39e0b450c984 100644
--- a/products/signals/backend/migrations/max_migration.txt
+++ b/products/signals/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0171_drop_signalscoutemission_weight_confidence
+0172_signalscoutconfig_precheck_disabled
diff --git a/products/signals/backend/models.py b/products/signals/backend/models.py
index 99c8627621f5..21a576d1bfbc 100644
--- a/products/signals/backend/models.py
+++ b/products/signals/backend/models.py
@@ -2754,8 +2754,11 @@ class SignalScoutConfig(ModelActivityMixin, TeamScopedRootMixin, UUIDModel):
# Optional HogQL query a scheduled run evaluates before it starts (`scout_harness/precheck.py`).
# No rows, or a single false value, skips the run, so a scout that watches something rare can
# run often and pay for a sandbox only when there is something new. `{since}` and `{now}` are
- # bound as HogQL placeholders. Null turns the pre-check off.
+ # bound as HogQL placeholders, and `{interval_minutes}` is the scout's schedule interval. Null
+ # falls back to the default its canonical skill ships, if any (`scout-precheck-query`).
precheck_query = models.TextField(null=True, blank=True)
+ # Turns off both `precheck_query` and the skill default, so every due tick runs the scout.
+ precheck_disabled = models.BooleanField(default=False, db_default=False)
# Stamped by the coordinator after each dispatch; drives the due-check. Written every
# run, so it is excluded from activity logging (see field_exclusions below).
last_run_at = models.DateTimeField(null=True, blank=True)
diff --git a/products/signals/backend/scout_harness/lazy_seed.py b/products/signals/backend/scout_harness/lazy_seed.py
index 7c23a4e31255..c282ec38c9ef 100644
--- a/products/signals/backend/scout_harness/lazy_seed.py
+++ b/products/signals/backend/scout_harness/lazy_seed.py
@@ -122,7 +122,9 @@ class CanonicalSkill:
ships the scout under. `deprecation` is the optional retirement marker from `scout-status` /
`scout-deprecation`, set only on a scout PostHog is retiring.
`structured_output_schema` is the record contract a measurement scout ships, read from the
- bundled file `scout-structured-output-schema` names.
+ bundled file `scout-structured-output-schema` names. `precheck_query` is the optional
+ `scout-precheck-query` frontmatter value, the pre-check a scheduled run uses when the team set
+ none of its own.
"""
name: str
@@ -136,6 +138,7 @@ class CanonicalSkill:
display_name: str = ""
deprecation: ScoutDeprecation | None = None
structured_output_schema: dict | None = None
+ precheck_query: str | None = None
@dataclass(frozen=True)
@@ -282,6 +285,46 @@ def _parse_display_name(frontmatter: dict, skill_file: Path, *, is_scout: bool)
return display_name
+def _parse_precheck_query(frontmatter: dict, skill_file: Path, *, is_scout: bool) -> str | None:
+ """Read the optional `scout-precheck-query` frontmatter value — the scout's default pre-check.
+
+ A scheduled run uses it when the team set no `precheck_query` of its own and did not turn the
+ pre-check off, and only for a team inside the skill's rollout (`precheck.resolve_effective_precheck`).
+ It is read from disk at evaluation time, not stamped on the config, so an edit reaches every
+ team on the next deploy. Validated here with the same parser the config API uses, so a broken
+ default fails the fleet sync once rather than erroring on every tick of every team.
+
+ Only scouts have a pre-check, so the key is rejected on a companion skill.
+ """
+ if "scout-precheck-query" not in frontmatter:
+ return None
+ if not is_scout:
+ raise CanonicalSkillParseError(f"Only a signals-scout-* skill may declare 'scout-precheck-query': {skill_file}")
+ raw = frontmatter["scout-precheck-query"]
+ if not isinstance(raw, str) or not (query := raw.strip()):
+ raise CanonicalSkillParseError(
+ f"SKILL.md frontmatter 'scout-precheck-query' must be a non-empty string: {skill_file}"
+ )
+ # Deferred: `precheck` reads the canonical default from this module.
+ from products.signals.backend.scout_harness.precheck import ( # noqa: PLC0415 — breaks a circular import
+ PRECHECK_MAX_QUERY_LENGTH,
+ parse_precheck_query,
+ )
+
+ if len(query) > PRECHECK_MAX_QUERY_LENGTH:
+ raise CanonicalSkillParseError(
+ f"SKILL.md frontmatter 'scout-precheck-query' exceeds the {PRECHECK_MAX_QUERY_LENGTH} "
+ f"character limit: {skill_file}"
+ )
+ try:
+ parse_precheck_query(query)
+ except Exception as error:
+ raise CanonicalSkillParseError(
+ f"SKILL.md frontmatter 'scout-precheck-query' is not a valid HogQL SELECT: {skill_file}: {error}"
+ ) from error
+ return query
+
+
def _parse_structured_output_schema(
frontmatter: dict, files: list[CanonicalSkillFile], skill_file: Path, *, is_scout: bool
) -> dict | None:
@@ -412,6 +455,7 @@ def _parse_canonical_skill(skill_dir: Path, *, is_scout: bool = True) -> Canonic
config_tags = _parse_config_tags(frontmatter, skill_file, is_scout=is_scout)
role = _parse_scout_role(frontmatter, skill_file, is_scout=is_scout)
display_name = _parse_display_name(frontmatter, skill_file, is_scout=is_scout)
+ precheck_query = _parse_precheck_query(frontmatter, skill_file, is_scout=is_scout)
# A malformed marker is raised as a parse error like every other frontmatter fault, so the
# callers that degrade to an empty fleet keep one failure mode rather than two.
try:
@@ -470,6 +514,7 @@ def _parse_canonical_skill(skill_dir: Path, *, is_scout: bool = True) -> Canonic
display_name=display_name,
deprecation=deprecation,
structured_output_schema=structured_output_schema,
+ precheck_query=precheck_query,
)
@@ -621,6 +666,31 @@ def canonical_structured_output_schema_for(skill_name: str) -> dict | None:
return _canonical_structured_output_schemas().get(skill_name)
+@lru_cache(maxsize=1)
+def _canonical_precheck_queries() -> dict[str, str]:
+ """The default pre-check per canonical scout name, for the scouts that ship one.
+
+ Cached for the process like `canonical_skill_names` — the shipped fleet only changes on
+ deploy — and degrades to empty on a malformed canonical, which leaves every scout running on
+ every due tick as before.
+ """
+ try:
+ return {skill.name: skill.precheck_query for skill in discover_canonical_skills() if skill.precheck_query}
+ except CanonicalSkillParseError:
+ logger.warning("canonical_precheck_queries: malformed canonical skill on disk; reading no pre-check defaults")
+ return {}
+
+
+def canonical_precheck_query_for(skill_name: str) -> str | None:
+ """The default pre-check the canonical scout of this name ships, if any.
+
+ None for a custom scout, and for a canonical scout with no default. Callers must confirm the
+ name is canonical first — a team's own `signals-scout-*` skill can share a canonical name, and
+ it inherits nothing from disk.
+ """
+ return _canonical_precheck_queries().get(skill_name)
+
+
@lru_cache(maxsize=1)
def _canonical_deprecations() -> dict[str, ScoutDeprecation]:
"""The retirement marker per canonical scout name, for the scouts PostHog is retiring.
@@ -691,6 +761,7 @@ def reset_canonical_caches() -> None:
_canonical_operational_scouts,
_canonical_deprecations,
_canonical_structured_output_schemas,
+ _canonical_precheck_queries,
):
cache.cache_clear()
diff --git a/products/signals/backend/scout_harness/precheck.py b/products/signals/backend/scout_harness/precheck.py
index f2cb672e446e..afeab4cbf302 100644
--- a/products/signals/backend/scout_harness/precheck.py
+++ b/products/signals/backend/scout_harness/precheck.py
@@ -14,19 +14,30 @@ The failure breaker and the inactivity sweep read run rows, so a quiet scout is
being quiet.
A query error never turns the scout off: the run continues as if there were no pre-check.
+
+The query comes from the first source that applies (`resolve_effective_precheck`):
+
+1. `precheck_disabled` on the config: no pre-check, the scout runs every due tick.
+2. The config's own `precheck_query`.
+3. The default the canonical skill ships (`scout-precheck-query` frontmatter), for a project
+ inside that skill's rollout (`precheck_default_rollout` in the `signals-scout` flag payload).
+ Projects outside the rollout run as if there were no default, and form the control group.
"""
from __future__ import annotations
import json
import time
+import dataclasses
from datetime import datetime
from typing import Any, Literal
+from zoneinfo import ZoneInfo
from django.utils import timezone
import structlog
import posthoganalytics
+from croniter import CroniterError, croniter
from posthog.hogql import ast
from posthog.hogql.constants import HogQLGlobalSettings
@@ -42,7 +53,13 @@ from posthog.event_usage import groups
from posthog.models import Team
from products.signals.backend.models import SignalScoutConfig, SignalScoutRun
+from products.signals.backend.scout_harness.lazy_seed import canonical_precheck_query_for, scout_skill_origin
from products.signals.backend.scout_harness.limits import MAX_PRECHECK_ROWS_BYTES, SCOUT_TRIAL_METADATA_KEY
+from products.signals.backend.scout_harness.team_limits import (
+ precheck_default_rollout_bucket,
+ precheck_default_rollout_percent,
+)
+from products.skills.backend.models.skills import LLMSkill
logger = structlog.get_logger(__name__)
@@ -54,6 +71,16 @@ PrecheckOutcome = Literal["run", "skip", "error"]
# `rows`: the query found rows. `no_rows`: it found none. `false_value`: it returned one false
# value. `query_error`: the query failed and the run continues.
PrecheckReason = Literal["rows", "no_rows", "false_value", "query_error"]
+# Where the query came from. `off` means no pre-check runs.
+PrecheckQuerySource = Literal["config", "skill_default", "off"]
+
+
+@frozen
+class EffectivePrecheck:
+ query: str | None
+ source: PrecheckQuerySource
+ # The project's 0-99 bucket for the skill default. None when the skill ships no default.
+ rollout_bucket: int | None = None
@frozen
@@ -63,6 +90,7 @@ class PrecheckResult:
row_count: int = 0
# The capped rows, one JSON object per line, for the run prompt.
rows_text: str | None = None
+ query_source: PrecheckQuerySource = "config"
@property
def should_run(self) -> bool:
@@ -85,6 +113,7 @@ class PrecheckDryRunResult:
reason: PrecheckReason
since: datetime
now: datetime
+ interval_minutes: int
row_count: int = 0
columns: tuple[str, ...] = ()
rows_text: str = ""
@@ -93,35 +122,107 @@ class PrecheckDryRunResult:
def parse_precheck_query(query: str) -> ast.SelectQuery | ast.SelectSetQuery:
- """Parse a pre-check query with its `{since}` and `{now}` placeholders bound. Raises on a bad query."""
- placeholder = ast.Constant(value=timezone.now())
- return parse_select(query, placeholders={"since": placeholder, "now": placeholder})
+ """Parse a pre-check query with its `{since}`, `{now}` and `{interval_minutes}` placeholders bound.
+
+ Raises on a bad query.
+ """
+ moment = timezone.now()
+ return parse_select(query, placeholders=_placeholders(since=moment, now=moment, interval_minutes=1))
+
+
+def _placeholders(*, since: datetime, now: datetime, interval_minutes: int) -> dict[str, ast.Expr]:
+ return {
+ "since": ast.Constant(value=since),
+ "now": ast.Constant(value=now),
+ "interval_minutes": ast.Constant(value=interval_minutes),
+ }
+
+
+def resolve_effective_precheck(config: SignalScoutConfig, *, is_canonical: bool) -> EffectivePrecheck:
+ """The pre-check query a scheduled run of this scout uses, and where it came from.
+
+ `is_canonical` says whether the project's skill row is the one the harness ships. A team's own
+ skill can share a canonical name, and it inherits no default from disk.
+ """
+ if config.precheck_disabled:
+ return EffectivePrecheck(query=None, source="off")
+ if config.precheck_query:
+ return EffectivePrecheck(query=config.precheck_query, source="config")
+ default = canonical_precheck_query_for(config.skill_name) if is_canonical else None
+ if not default:
+ return EffectivePrecheck(query=None, source="off")
+ bucket = precheck_default_rollout_bucket(config.team_id, config.skill_name)
+ if bucket >= precheck_default_rollout_percent(config.skill_name):
+ return EffectivePrecheck(query=None, source="off", rollout_bucket=bucket)
+ return EffectivePrecheck(query=default, source="skill_default", rollout_bucket=bucket)
+
+
+def scout_skill_is_canonical(team_id: int, skill_name: str) -> bool:
+ """Whether the project's latest skill row for this scout is the one the harness ships."""
+ metadata = (
+ LLMSkill.objects.filter(team_id=team_id, name=skill_name, is_latest=True, deleted=False)
+ .values_list("metadata", flat=True)
+ .first()
+ )
+ return metadata is not None and scout_skill_origin(skill_name, metadata) == "canonical"
+
+
+def precheck_interval_minutes(config: SignalScoutConfig, team: Team, now: datetime) -> int:
+ """The `{interval_minutes}` value: the gap between two scheduled runs of this scout.
+
+ For a cron schedule it is the gap between the fire time before `now` and the one after it,
+ read in the project's timezone like the coordinator reads it. Otherwise it is the rolling
+ `run_interval_minutes`.
+ """
+ if config.run_cron_schedule:
+ try:
+ local_now = now.astimezone(ZoneInfo(team.timezone)).replace(tzinfo=None)
+ following: datetime = croniter(config.run_cron_schedule, local_now).get_next(datetime)
+ previous: datetime = croniter(config.run_cron_schedule, following).get_prev(datetime)
+ return max(1, round((following - previous).total_seconds() / 60))
+ except (CroniterError, ValueError, KeyError):
+ pass
+ return config.run_interval_minutes
def evaluate_scout_precheck(team_id: int, skill_name: str, now: datetime | None = None) -> PrecheckResult | None:
- """Evaluate the pre-check of one scout. Return None when the scout has no pre-check.
+ """Evaluate the effective pre-check of one scout. Return None when the scout has no pre-check.
Never raises for a query problem: a failed query returns an `error` outcome that runs the scout.
"""
config = (
SignalScoutConfig.objects.for_team(team_id)
.filter(skill_name=skill_name)
- .only("id", "team_id", "skill_name", "created_at", "status", "precheck_query")
+ .only(
+ "id",
+ "team_id",
+ "skill_name",
+ "created_at",
+ "status",
+ "precheck_query",
+ "precheck_disabled",
+ "run_interval_minutes",
+ "run_cron_schedule",
+ )
.first()
)
# A paused lane only runs as a breaker probe, which exists to find out whether the lane can
# succeed. A skip would hold the lane paused for as long as it stays quiet.
- if config is None or not config.precheck_query or config.status not in SignalScoutConfig.RUNNABLE_STATUSES:
+ if config is None or config.status not in SignalScoutConfig.RUNNABLE_STATUSES:
+ return None
+ effective = resolve_effective_precheck(config, is_canonical=scout_skill_is_canonical(team_id, skill_name))
+ if effective.query is None:
return None
now = now or timezone.now()
since = precheck_since(config)
team = Team.objects.select_related("organization").get(pk=team_id)
+ interval_minutes = precheck_interval_minutes(config, team, now)
started = time.monotonic()
error_type: str | None = None
try:
- found = _run_query(team, config.precheck_query, since=since, now=now)
+ found = _run_query(team, effective.query, since=since, now=now, interval_minutes=interval_minutes)
except Exception as error:
error_type = type(error).__name__
logger.warning(
@@ -134,11 +235,13 @@ def evaluate_scout_precheck(team_id: int, skill_name: str, now: datetime | None
result = PrecheckResult(outcome="error", reason="query_error")
else:
result = _result_from_rows(found)
+ result = dataclasses.replace(result, query_source=effective.source)
_capture_precheck_evaluated(
team=team,
config=config,
result=result,
+ effective=effective,
duration_ms=round((time.monotonic() - started) * 1000),
error_type=error_type,
)
@@ -151,8 +254,9 @@ def dry_run_scout_precheck(
"""Run a pre-check query the way the next scheduled run would, and change nothing."""
now = now or timezone.now()
since = precheck_since(config)
+ interval_minutes = precheck_interval_minutes(config, team, now)
try:
- found = _run_query(team, query, since=since, now=now)
+ found = _run_query(team, query, since=since, now=now, interval_minutes=interval_minutes)
except Exception as error:
logger.info(
"signals_scout: pre-check dry run failed",
@@ -163,13 +267,21 @@ def dry_run_scout_precheck(
# Other errors can carry generated SQL, so only an exposed error reaches the caller as written.
exposed = isinstance(error, ExposedHogQLError | ExposedCHQueryError)
message = str(error) if exposed else "The query could not run."
- return PrecheckDryRunResult(would_run=True, reason="query_error", since=since, now=now, error=message)
+ return PrecheckDryRunResult(
+ would_run=True,
+ reason="query_error",
+ since=since,
+ now=now,
+ interval_minutes=interval_minutes,
+ error=message,
+ )
result = _result_from_rows(found)
return PrecheckDryRunResult(
would_run=result.should_run,
reason=result.reason,
since=since,
now=now,
+ interval_minutes=interval_minutes,
row_count=len(found.rows),
columns=tuple(str(column) for column in found.columns),
rows_text=_render_rows(found),
@@ -197,8 +309,8 @@ def _result_from_rows(found: _PrecheckRows) -> PrecheckResult:
return PrecheckResult(outcome="run", reason="rows", row_count=len(found.rows), rows_text=_render_rows(found))
-def _run_query(team: Team, query: str, *, since: datetime, now: datetime) -> _PrecheckRows:
- parsed = parse_select(query, placeholders={"since": ast.Constant(value=since), "now": ast.Constant(value=now)})
+def _run_query(team: Team, query: str, *, since: datetime, now: datetime, interval_minutes: int) -> _PrecheckRows:
+ parsed = parse_select(query, placeholders=_placeholders(since=since, now=now, interval_minutes=interval_minutes))
capped = _cap_rows(parsed)
with tags_context(product=Product.SIGNALS, feature=Feature.ENRICHMENT, team_id=team.pk):
response = execute_hogql_query(
@@ -247,6 +359,7 @@ def _capture_precheck_evaluated(
team: Team,
config: SignalScoutConfig,
result: PrecheckResult,
+ effective: EffectivePrecheck,
duration_ms: int,
error_type: str | None,
) -> None:
@@ -262,6 +375,8 @@ def _capture_precheck_evaluated(
"row_count": result.row_count,
"duration_ms": duration_ms,
"error_type": error_type,
+ "query_source": effective.source,
+ "rollout_bucket": effective.rollout_bucket,
},
groups=groups(team.organization, team),
)
diff --git a/products/signals/backend/scout_harness/runner.py b/products/signals/backend/scout_harness/runner.py
index b9412fe53138..953adb47c6e7 100644
--- a/products/signals/backend/scout_harness/runner.py
+++ b/products/signals/backend/scout_harness/runner.py
@@ -260,6 +260,7 @@ async def _arun_signals_scout(
trial_launch_id: str | None = None,
check_id: str | None = None,
precheck_rows: str | None = None,
+ precheck_query_source: str | None = None,
) -> RunResult:
"""Async core. Safe to call from inside a running event loop (Temporal activity).
@@ -274,7 +275,8 @@ async def _arun_signals_scout(
history; it is never carried into a later run.
`precheck_rows` are the rows the pre-check of a scheduled run found (`scout_harness/precheck.py`).
- They render in their own prompt section as untrusted data.
+ They render in their own prompt section as untrusted data. `precheck_query_source` says which
+ pre-check started the run, and is stamped on the run row.
"""
team = await database_sync_to_async(_get_team, thread_sensitive=False)(team_id)
trial = (
@@ -529,6 +531,7 @@ async def _arun_signals_scout(
trial=trial,
check_id=check_id,
precheck_rows=precheck_rows,
+ precheck_query_source=precheck_query_source,
)
trial_status = tasks_facade.TaskRunStatus.COMPLETED.value
runtime_s = time.monotonic() - started
@@ -729,6 +732,7 @@ async def arun_signals_scout(
trial_launch_id: str | None = None,
check_id: str | None = None,
precheck_rows: str | None = None,
+ precheck_query_source: str | None = None,
) -> RunResult:
with private_capture_context() if trial_launch_id is not None else nullcontext():
return await _arun_signals_scout(
@@ -743,6 +747,7 @@ async def arun_signals_scout(
trial_launch_id=trial_launch_id,
check_id=check_id,
precheck_rows=precheck_rows,
+ precheck_query_source=precheck_query_source,
)
@@ -903,6 +908,7 @@ async def _spawn_and_run(
trial: TrialLaunch | None = None,
check_id: str | None = None,
precheck_rows: str | None = None,
+ precheck_query_source: str | None = None,
) -> tuple[str, str]:
"""Spawn the sandbox, create the bridge row before the first turn, run the agent.
@@ -1051,6 +1057,7 @@ async def _spawn_and_run(
run_note=run_note,
trial=trial,
check_id=check_id,
+ precheck_query_source=precheck_query_source,
)
# Lifecycle start marker. The row + TaskRun now exist and the run has cleared the
# reap + single-flight guards, so this counts exactly the runs that actually start —
@@ -1324,6 +1331,7 @@ def _create_run_row(
run_note: str | None = None,
trial: TrialLaunch | None = None,
check_id: str | None = None,
+ precheck_query_source: str | None = None,
) -> SignalScoutRun:
# Stamp the routed model triple (and the OpenAI queue it asked for) onto the row's `metadata`
# so "which model ran this?" is a column read on the run API, not an analytics-event join. Keys
@@ -1415,6 +1423,10 @@ def _create_run_row(
# `scout-report-check-list` read it to tie the check to this run.
if check_id:
metadata["check_id"] = check_id
+ # Which pre-check started this run (`config` or `skill_default`), so run outcomes can be split
+ # by it. Absent when no pre-check ran.
+ if precheck_query_source:
+ metadata["precheck_query_source"] = precheck_query_source
return SignalScoutRun.objects.unscoped().create(
id=run_id,
task_run_id=task_run_id,
diff --git a/products/signals/backend/scout_harness/serializers.py b/products/signals/backend/scout_harness/serializers.py
index 67c44b8509ed..3f3b4e7ae5b5 100644
--- a/products/signals/backend/scout_harness/serializers.py
+++ b/products/signals/backend/scout_harness/serializers.py
@@ -60,7 +60,9 @@ from products.signals.backend.scout_harness.precheck import (
PRECHECK_MAX_QUERY_LENGTH,
PRECHECK_MAX_ROWS,
PRECHECK_TIMEOUT_S,
+ EffectivePrecheck,
parse_precheck_query,
+ resolve_effective_precheck,
)
from products.signals.backend.scout_harness.scout_costs import SCOUT_COST_WINDOW_DAYS
from products.signals.backend.scout_harness.skill_loader import reserved_scout_name_error
@@ -3139,9 +3141,18 @@ _PRECHECK_QUERY_HELP = (
"scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events "
"WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet "
"it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate "
- "it: a manual or workflow run always starts. "
+ "it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two "
+ "scheduled runs, so a backstop can follow the schedule: `{since} < {now} - "
+ "toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more "
+ "often than every two intervals. "
f"The query stops after {PRECHECK_TIMEOUT_S} seconds and reads at most {PRECHECK_MAX_ROWS} rows. "
- "Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off."
+ "Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default "
+ "pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
+)
+
+_PRECHECK_DISABLED_HELP = (
+ "True turns off the pre-check, both `precheck_query` and the default the skill ships, so every "
+ "scheduled run starts. False (the default) uses `precheck_query`, or the skill default when that is null."
)
@@ -3376,6 +3387,12 @@ class ScoutRole(models.TextChoices):
OPERATIONAL = "operational", "operational"
+class ScoutPrecheckQuerySource(models.TextChoices):
+ CONFIG = "config", "config"
+ SKILL_DEFAULT = "skill_default", "skill_default"
+ OFF = "off", "off"
+
+
class ScoutDeprecationPhase(models.TextChoices):
ANNOUNCED = "announced", "announced"
RETIRED = "retired", "retired"
@@ -3550,6 +3567,19 @@ class SignalScoutConfigSerializer(serializers.ModelSerializer):
help_text=_SCOUT_MODEL_HELP,
)
precheck_query = serializers.CharField(read_only=True, allow_null=True, help_text=_PRECHECK_QUERY_HELP)
+ precheck_disabled = serializers.BooleanField(read_only=True, help_text=_PRECHECK_DISABLED_HELP)
+ effective_precheck_query = serializers.SerializerMethodField(
+ help_text=(
+ "The pre-check query the next scheduled run uses: `precheck_query`, or the default the "
+ "scout's skill ships. Null when no pre-check runs."
+ ),
+ )
+ precheck_query_source = serializers.SerializerMethodField(
+ help_text=(
+ "Where `effective_precheck_query` comes from: `config` (this scout's `precheck_query`), "
+ "`skill_default` (the default its skill ships), or `off` (no pre-check runs)."
+ ),
+ )
last_run_at = serializers.DateTimeField(
read_only=True,
allow_null=True,
@@ -3646,6 +3676,23 @@ class SignalScoutConfigSerializer(serializers.ModelSerializer):
info = (self.context.get("skill_info") or {}).get(obj.skill_name)
return info.role if info else "specialist"
+ def _effective_precheck(self, obj: SignalScoutConfig) -> EffectivePrecheck:
+ # Two fields read it, and the skill default reads the flag payload, so resolve it once per row.
+ cache: dict[Any, EffectivePrecheck] = self.context.setdefault("_effective_precheck_by_config", {})
+ if obj.pk not in cache:
+ cache[obj.pk] = resolve_effective_precheck(
+ obj, is_canonical=self.get_scout_origin(obj) == ScoutOrigin.CANONICAL.value
+ )
+ return cache[obj.pk]
+
+ @extend_schema_field(serializers.CharField(allow_null=True))
+ def get_effective_precheck_query(self, obj: SignalScoutConfig) -> str | None:
+ return self._effective_precheck(obj).query
+
+ @extend_schema_field(serializers.ChoiceField(choices=ScoutPrecheckQuerySource.choices))
+ def get_precheck_query_source(self, obj: SignalScoutConfig) -> str:
+ return self._effective_precheck(obj).source
+
@extend_schema_field(ScoutDeprecationSerializer(allow_null=True))
def get_deprecation(self, obj: SignalScoutConfig) -> dict[str, Any] | None:
# Same single-query `skill_info` map as `get_description`. The marker is read off the
@@ -3701,6 +3748,9 @@ class SignalScoutConfigSerializer(serializers.ModelSerializer):
"allowed_mcp_tools",
"tool_preset",
"precheck_query",
+ "precheck_disabled",
+ "effective_precheck_query",
+ "precheck_query_source",
"last_run_at",
"consecutive_failure_count",
"status_changed_at",
@@ -3869,6 +3919,7 @@ class SignalScoutConfigUpdateSerializer(_ScoutConfigCapabilityFieldsMixin, seria
"""Editable display name, schedule, enablement, and emit posture for one scout config."""
display_name = _display_name_field()
+ precheck_disabled = serializers.BooleanField(required=False, help_text=_PRECHECK_DISABLED_HELP)
enabled = serializers.BooleanField(
required=False,
help_text=(
@@ -4038,6 +4089,7 @@ class SignalScoutConfigUpdateSerializer(_ScoutConfigCapabilityFieldsMixin, seria
"repositories",
"write_scopes",
"precheck_query",
+ "precheck_disabled",
"suggestion_id",
"lifecycle_locked",
"allowed_mcp_tools",
@@ -4151,8 +4203,9 @@ class SignalScoutPrecheckTestRequestSerializer(serializers.Serializer):
trim_whitespace=False,
max_length=PRECHECK_MAX_QUERY_LENGTH,
help_text=(
- "HogQL `SELECT` to try, with the same `{since}` and `{now}` placeholders a saved pre-check "
- "gets. Omit it, or pass null or blank, to try the query saved on the scout."
+ "HogQL `SELECT` to try, with the same `{since}`, `{now}` and `{interval_minutes}` placeholders "
+ "a saved pre-check gets. Omit it, or pass null or blank, to try the scout's effective query: "
+ "its own `precheck_query`, or the default its skill ships."
),
)
@@ -4176,6 +4229,12 @@ class SignalScoutPrecheckTestSerializer(serializers.Serializer):
help_text="The value bound to `{since}`: the start of the last run that ran, or when the scout was created."
)
now = serializers.DateTimeField(help_text="The value bound to `{now}`.")
+ interval_minutes = serializers.IntegerField(
+ help_text=(
+ "The value bound to `{interval_minutes}`: the scout's rolling interval, or for a cron "
+ "schedule the gap in minutes between the fire times around now."
+ ),
+ )
row_count = serializers.IntegerField(
help_text=f"How many rows the query returned, at most {PRECHECK_MAX_ROWS}.",
)
diff --git a/products/signals/backend/scout_harness/team_limits.py b/products/signals/backend/scout_harness/team_limits.py
index 703e76903413..e8f1ee9340f9 100644
--- a/products/signals/backend/scout_harness/team_limits.py
+++ b/products/signals/backend/scout_harness/team_limits.py
@@ -340,6 +340,39 @@ def background_sample_bucket(team_id: int) -> int:
return int.from_bytes(digest[:8], "big") % 100
+# Payload key: a `{skill_name: percent}` map. It sets the share of projects (0-100) whose scout uses
+# the default pre-check its canonical skill ships. A skill that is absent reads as 0, so a new
+# default stays off until the flag names it, and the rest of the projects form the control group.
+PRECHECK_DEFAULT_ROLLOUT_KEY = "precheck_default_rollout"
+
+
+def _parse_precheck_default_rollout(payload: dict | None) -> dict[str, int]:
+ raw = (payload or {}).get(PRECHECK_DEFAULT_ROLLOUT_KEY)
+ if not isinstance(raw, dict):
+ return {}
+ return {
+ name: max(0, min(100, percent))
+ for name, percent in raw.items()
+ if isinstance(name, str) and isinstance(percent, int) and not isinstance(percent, bool)
+ }
+
+
+def precheck_default_rollout_percent(skill_name: str) -> int:
+ """The share of projects (0-100) that use this skill's default pre-check. 0 when the payload is unreadable."""
+ return _parse_precheck_default_rollout(_read_flag_payload()).get(skill_name, 0)
+
+
+def precheck_default_rollout_bucket(team_id: int, skill_name: str) -> int:
+ """The stable 0-99 bucket of a project for one skill's default pre-check.
+
+ A project uses the default when its bucket is below the skill's rollout percent, so a wider
+ rollout keeps every project a narrower one included. The skill name is in the hash, so each
+ skill gets its own control group.
+ """
+ digest = hashlib.sha256(f"signals-scout-precheck-default:{skill_name}:{team_id}".encode()).digest()
+ return int.from_bytes(digest[:8], "big") % 100
+
+
def _parse_background(payload: dict | None) -> BackgroundEnrollment | None:
"""Parse the `background` block, or return `None` when the coordinator must not act on it.
diff --git a/products/signals/backend/scout_harness/views.py b/products/signals/backend/scout_harness/views.py
index 2c76c7d90da3..7ee46f81ae8a 100644
--- a/products/signals/backend/scout_harness/views.py
+++ b/products/signals/backend/scout_harness/views.py
@@ -99,7 +99,11 @@ from products.signals.backend.scout_harness.lifecycle_lock import (
resolve_auth_kind,
user_holds_scout_lifecycle_claim,
)
-from products.signals.backend.scout_harness.precheck import dry_run_scout_precheck
+from products.signals.backend.scout_harness.precheck import (
+ dry_run_scout_precheck,
+ resolve_effective_precheck,
+ scout_skill_is_canonical,
+)
from products.signals.backend.scout_harness.run_costs import scout_run_token_costs
from products.signals.backend.scout_harness.run_gates import (
ScoutRunRejection,
@@ -3786,7 +3790,8 @@ class SignalScoutConfigViewSet(ScoutTrialConfigMixin, TeamAndOrgViewSetMixin, vi
"Run a scout's pre-check query once and return its rows, without starting a run and without "
"saving anything. The query gets the same `{since}` and `{now}` values the next scheduled run "
"would get, so the result says whether that run would start or skip. Pass `precheck_query` to "
- "try a query before you save it, or omit it to try the saved one. A query error comes back in "
+ "try a query before you save it, or omit it to try the effective one: the saved query, or the "
+ "default the scout's skill ships. A query error comes back in "
"the `error` field with a 200, because a scheduled run treats it as a reason to run."
),
operation_id="signals_scout_config_precheck_test",
@@ -3805,7 +3810,13 @@ class SignalScoutConfigViewSet(ScoutTrialConfigMixin, TeamAndOrgViewSetMixin, vi
config = SignalScoutConfig.objects.for_team(team.id).filter(id=config_id).first()
if config is None or config.skill_name in withheld_skills_for_team(team.id):
raise exceptions.NotFound()
- query = request.validated_data.get("precheck_query") or config.precheck_query
+ query = request.validated_data.get("precheck_query")
+ if not query:
+ # Never saved. A scout with its pre-check turned off can still test the query it would use.
+ config.precheck_disabled = False
+ query = resolve_effective_precheck(
+ config, is_canonical=scout_skill_is_canonical(team.id, config.skill_name)
+ ).query
if not query:
raise exceptions.ValidationError({"precheck_query": "This scout has no pre-check query. Give one to test."})
result = dry_run_scout_precheck(team, config, query)
diff --git a/products/signals/backend/temporal/agentic/scout_scheduler.py b/products/signals/backend/temporal/agentic/scout_scheduler.py
index 334ca0eddbb9..74a37d6aa92e 100644
--- a/products/signals/backend/temporal/agentic/scout_scheduler.py
+++ b/products/signals/backend/temporal/agentic/scout_scheduler.py
@@ -72,6 +72,8 @@ class RunSignalsScoutInput:
check_id: str | None = None
# The rows the pre-check found, set by the workflow on a scheduled run the pre-check started.
precheck_rows: str | None = None
+ # Which pre-check started the run (`config` or `skill_default`), stamped on the run row.
+ precheck_query_source: str | None = None
@frozen
@@ -128,18 +130,22 @@ class EvaluateScoutPrecheckOutput:
should_run: bool
# The capped rows the run renders into its prompt. None when there are no rows to pass.
rows_text: str | None = None
+ # Where the query came from. None when the scout has no pre-check.
+ query_source: str | None = None
@temporalio.activity.defn
@close_db_connections
async def evaluate_signals_scout_precheck_activity(input: RunSignalsScoutInput) -> EvaluateScoutPrecheckOutput:
- """Evaluate the scout's pre-check query. A scout without one always runs."""
+ """Evaluate the scout's effective pre-check query. A scout without one always runs."""
result = await database_sync_to_async(evaluate_scout_precheck, thread_sensitive=False)(
input.team_id, input.skill_name
)
if result is None:
return EvaluateScoutPrecheckOutput(should_run=True)
- return EvaluateScoutPrecheckOutput(should_run=result.should_run, rows_text=result.rows_text)
+ return EvaluateScoutPrecheckOutput(
+ should_run=result.should_run, rows_text=result.rows_text, query_source=result.query_source
+ )
@temporalio.activity.defn
@@ -235,6 +241,7 @@ async def _run_signals_scout(input: RunSignalsScoutInput) -> RunSignalsScoutOutp
trial_launch_id=input.trial_launch_id,
check_id=input.check_id,
precheck_rows=input.precheck_rows,
+ precheck_query_source=input.precheck_query_source,
)
except (OperationalError, InterfaceError):
# Transient DB connection drop (pgbouncer pool recycle / failover / deploy). Stay
@@ -298,6 +305,8 @@ class RunSignalsScoutWorkflow:
)
if precheck.rows_text:
input = replace(input, precheck_rows=precheck.rows_text)
+ if precheck.query_source:
+ input = replace(input, precheck_query_source=precheck.query_source)
try:
output = await temporalio.workflow.execute_activity(
run_signals_scout_activity,
diff --git a/products/signals/backend/test/test_scout_harness_lazy_seed.py b/products/signals/backend/test/test_scout_harness_lazy_seed.py
index 71dcdeacd7a7..72732eb16596 100644
--- a/products/signals/backend/test/test_scout_harness_lazy_seed.py
+++ b/products/signals/backend/test/test_scout_harness_lazy_seed.py
@@ -387,6 +387,28 @@ class TestDiscoverCanonicalSkills:
with pytest.raises(CanonicalSkillParseError, match=expected_error):
discover_canonical_skills(tmp_path)
+ @pytest.mark.parametrize(
+ "dir_name,precheck_yaml,expected_error",
+ [
+ ("signals-scout-bar", "scout-precheck-query: ''", "must be a non-empty string"),
+ ("signals-scout-bar", "scout-precheck-query: 'SELEC 1'", "not a valid HogQL SELECT"),
+ ("signals-scout-bar", "scout-precheck-query: 'SELECT {unknown}'", "not a valid HogQL SELECT"),
+ ("authoring-scouts", "scout-precheck-query: 'SELECT 1'", "Only a signals-scout-\\* skill may declare"),
+ ],
+ )
+ def test_rejects_malformed_scout_precheck_query(
+ self, tmp_path: Path, dir_name: str, precheck_yaml: str, expected_error: str
+ ) -> None:
+ name = dir_name if dir_name == "authoring-scouts" else "signals-scout-bar"
+ _write_canonical_skill(
+ tmp_path,
+ dir_name=dir_name,
+ frontmatter=f"---\nname: {name}\ndescription: bar skill\n{precheck_yaml}\n---\n",
+ body="# Bar\n",
+ )
+ with pytest.raises(CanonicalSkillParseError, match=expected_error):
+ discover_canonical_skills(tmp_path)
+
def test_parses_scout_role(self, tmp_path: Path) -> None:
_write_canonical_skill(
tmp_path,
diff --git a/products/signals/backend/test/test_scout_precheck.py b/products/signals/backend/test/test_scout_precheck.py
index e3137764b650..4c024383bf32 100644
--- a/products/signals/backend/test/test_scout_precheck.py
+++ b/products/signals/backend/test/test_scout_precheck.py
@@ -5,16 +5,28 @@ from posthog.test.base import APIBaseTest, BaseTest, ClickhouseTestMixin, _creat
from unittest.mock import patch
from django.apps import apps
+from django.test import SimpleTestCase
from parameterized import parameterized
from rest_framework import status
+from posthog.models import Team
+
from products.signals.backend.models import SignalScoutConfig, SignalScoutRun
-from products.signals.backend.scout_harness.precheck import PRECHECK_MAX_ROWS, evaluate_scout_precheck
+from products.signals.backend.scout_harness.lazy_seed import HARNESS_SEEDED_BY
+from products.signals.backend.scout_harness.precheck import (
+ PRECHECK_MAX_ROWS,
+ evaluate_scout_precheck,
+ precheck_interval_minutes,
+ resolve_effective_precheck,
+)
+from products.skills.backend.models.skills import LLMSkill
NOW = datetime(2026, 10, 9, 12, 0, 0, tzinfo=UTC)
SKILL = "signals-scout-errors"
NEW_EVENTS_QUERY = "SELECT event FROM events WHERE event = 'boom' AND timestamp > {since} AND timestamp <= {now}"
+SURVEYS_SKILL = "signals-scout-surveys"
+ROLLOUT_PERCENT = "products.signals.backend.scout_harness.precheck.precheck_default_rollout_percent"
@time_machine.travel(NOW, tick=False)
@@ -136,6 +148,98 @@ class TestEvaluateScoutPrecheck(ClickhouseTestMixin, BaseTest):
capture.assert_not_called()
+@time_machine.travel(NOW, tick=False)
+class TestSkillDefaultPrecheck(ClickhouseTestMixin, BaseTest):
+ def setUp(self) -> None:
+ super().setUp()
+ LLMSkill.objects.create(
+ team=self.team, name=SURVEYS_SKILL, description="", body="", metadata={"seeded_by": HARNESS_SEEDED_BY}
+ )
+ config = SignalScoutConfig.all_teams.create(team=self.team, skill_name=SURVEYS_SKILL)
+ SignalScoutConfig.all_teams.filter(pk=config.pk).update(created_at=NOW - timedelta(hours=2))
+
+ def _evaluate(self, rollout_percent: int):
+ with (
+ patch(ROLLOUT_PERCENT, return_value=rollout_percent),
+ patch("products.signals.backend.scout_harness.precheck.posthoganalytics.capture") as capture,
+ ):
+ result = evaluate_scout_precheck(self.team.pk, SURVEYS_SKILL)
+ return result, capture
+
+ @parameterized.expand(
+ [
+ ("no_survey_events", [], 2, "skip", 0),
+ ("survey_shown_without_answers", ["survey shown"], 2, "run", 1),
+ # Quiet for longer than two daily intervals, so the backstop row starts the run.
+ ("backstop", [], 50, "run", 1),
+ ]
+ )
+ def test_surveys_default_gates_the_run(self, _name, events, quiet_hours, outcome, row_count) -> None:
+ SignalScoutConfig.all_teams.filter(team=self.team).update(created_at=NOW - timedelta(hours=quiet_hours))
+ for event in events:
+ _create_event(
+ team=self.team,
+ event=event,
+ distinct_id="d1",
+ timestamp=NOW - timedelta(hours=1),
+ properties={"$survey_id": "s1"},
+ )
+ flush_persons_and_events()
+
+ result, capture = self._evaluate(rollout_percent=100)
+
+ assert result is not None
+ assert (result.outcome, result.row_count, result.query_source) == (outcome, row_count, "skill_default")
+ properties = capture.call_args.kwargs["properties"]
+ assert properties["query_source"] == "skill_default"
+ assert properties["rollout_bucket"] is not None
+
+ def test_project_outside_the_rollout_runs_as_before(self) -> None:
+ result, capture = self._evaluate(rollout_percent=0)
+
+ assert result is None
+ capture.assert_not_called()
+
+
+class TestResolveEffectivePrecheck(SimpleTestCase):
+ @parameterized.expand(
+ [
+ ("disabled_wins_over_everything", True, "SELECT 1", True, 100, None, "off"),
+ ("own_query_wins_over_default", False, "SELECT 1", True, 100, "SELECT 1", "config"),
+ ("default_inside_rollout", False, None, True, 100, "default", "skill_default"),
+ ("default_outside_rollout", False, None, True, 0, None, "off"),
+ ("custom_skill_inherits_nothing", False, None, False, 100, None, "off"),
+ ]
+ )
+ def test_precedence(self, _name, disabled, own_query, is_canonical, percent, query, source) -> None:
+ config = SignalScoutConfig(
+ team_id=1, skill_name=SURVEYS_SKILL, precheck_query=own_query, precheck_disabled=disabled
+ )
+ with (
+ patch(ROLLOUT_PERCENT, return_value=percent),
+ patch(
+ "products.signals.backend.scout_harness.precheck.canonical_precheck_query_for",
+ return_value="default",
+ ),
+ ):
+ effective = resolve_effective_precheck(config, is_canonical=is_canonical)
+
+ assert (effective.query, effective.source) == (query, source)
+
+ @parameterized.expand(
+ [
+ ("rolling", None, 360, 360),
+ ("daily_cron", "0 9 * * *", 1440, 1440),
+ ("twice_daily_cron_between_slots", "0 9,17 * * *", 1440, 480),
+ ("invalid_cron_falls_back", "not a cron", 90, 90),
+ ]
+ )
+ def test_interval_minutes(self, _name, cron, interval, expected) -> None:
+ config = SignalScoutConfig(run_cron_schedule=cron, run_interval_minutes=interval)
+
+ assert precheck_interval_minutes(config, Team(timezone="UTC"), NOW) == expected
+
+
@time_machine.travel(NOW, tick=False)
class TestScoutPrecheckTestAPI(ClickhouseTestMixin, APIBaseTest):
def setUp(self) -> None:
diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.ts
index 977ddc1521d8..525ecd1064b9 100644
--- a/products/signals/frontend/generated/api.schemas.ts
+++ b/products/signals/frontend/generated/api.schemas.ts
@@ -3445,7 +3445,7 @@ export interface SignalScoutConfigOptionsApi {
* * `support_notes` - Support notes */
tool_preset?: ToolPresetEnumApi
/**
- * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off.
+ * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`.
* @maxLength 10000
* @nullable
*/
@@ -3671,6 +3671,15 @@ export const SignalScoutConfigManagedByEnumApi = {
Background: 'background',
} as const
+export type ScoutPrecheckQuerySourceEnumApi =
+ (typeof ScoutPrecheckQuerySourceEnumApi)[keyof typeof ScoutPrecheckQuerySourceEnumApi]
+
+export const ScoutPrecheckQuerySourceEnumApi = {
+ Config: 'config',
+ SkillDefault: 'skill_default',
+ Off: 'off',
+} as const
+
/**
* Optional JSON Schema (draft 2020-12) describing ONE structured record this scout produces via `scout-record-output` — e.g. a per-report quality judgment (`{"type": "object", "properties": {"verdict": {"enum": ["good", "bad", "unsure"]}, "reason": {"type": "string"}}, "required": ["verdict", "reason"]}`). The root must be `"type": "object"`. Setting a schema turns the structured-output channel on: the run prompt renders the schema and every submitted record is validated against it and recorded in the project as a `$scout_structured_output` event, queryable like any event. The channel also requires emit — a dry-run scout has nowhere to record to. Cardinality is the scout's call (one record per run, one per judged entity, ...). Null = channel off. Setting a schema requires skill-authoring authorization (the `llm_skill:write` scope and skill editor access) since the scout reads it verbatim in its prompt; clearing it needs only the config write. Records validate against the schema in force when the run was dispatched.
* @nullable
@@ -3783,10 +3792,19 @@ export interface SignalScoutConfigApi {
*/
readonly tool_preset: string | null
/**
- * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off.
+ * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`.
* @nullable
*/
readonly precheck_query: string | null
+ /** True turns off the pre-check, both `precheck_query` and the default the skill ships, so every scheduled run starts. False (the default) uses `precheck_query`, or the skill default when that is null. */
+ readonly precheck_disabled: boolean
+ /**
+ * The pre-check query the next scheduled run uses: `precheck_query`, or the default the scout's skill ships. Null when no pre-check runs.
+ * @nullable
+ */
+ readonly effective_precheck_query: string | null
+ /** Where `effective_precheck_query` comes from: `config` (this scout's `precheck_query`), `skill_default` (the default its skill ships), or `off` (no pre-check runs). */
+ readonly precheck_query_source: ScoutPrecheckQuerySourceEnumApi
/**
* When the coordinator last dispatched this scout. Null if it has never run.
* @nullable
@@ -3922,7 +3940,7 @@ export interface SignalScoutConfigCreateApi {
* * `support_notes` - Support notes */
tool_preset?: ToolPresetEnumApi
/**
- * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off.
+ * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`.
* @maxLength 10000
* @nullable
*/
@@ -4069,11 +4087,13 @@ export interface PatchedSignalScoutConfigUpdateApi {
*/
write_scopes?: string[]
/**
- * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off.
+ * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`.
* @maxLength 10000
* @nullable
*/
precheck_query?: string | null
+ /** True turns off the pre-check, both `precheck_query` and the default the skill ships, so every scheduled run starts. False (the default) uses `precheck_query`, or the skill default when that is null. */
+ precheck_disabled?: boolean
/**
* Optional id of the canonical scout suggestion this request turns on. It records that the scout came from that suggestion. An id this project's batch does not hold is ignored.
* @maxLength 64
@@ -4095,7 +4115,7 @@ export interface PatchedSignalScoutConfigUpdateApi {
export interface SignalScoutPrecheckTestRequestApi {
/**
- * HogQL `SELECT` to try, with the same `{since}` and `{now}` placeholders a saved pre-check gets. Omit it, or pass null or blank, to try the query saved on the scout.
+ * HogQL `SELECT` to try, with the same `{since}`, `{now}` and `{interval_minutes}` placeholders a saved pre-check gets. Omit it, or pass null or blank, to try the scout's effective query: its own `precheck_query`, or the default its skill ships.
* @maxLength 10000
* @nullable
*/
@@ -4131,6 +4151,8 @@ export interface SignalScoutPrecheckTestApi {
since: string
/** The value bound to `{now}`. */
now: string
+ /** The value bound to `{interval_minutes}`: the scout's rolling interval, or for a cron schedule the gap in minutes between the fire times around now. */
+ interval_minutes: number
/** How many rows the query returned, at most 50. */
row_count: number
/** The column names of the result, in order. */
diff --git a/products/signals/frontend/generated/api.ts b/products/signals/frontend/generated/api.ts
index b93b8d511275..f2bc8e25b1cb 100644
--- a/products/signals/frontend/generated/api.ts
+++ b/products/signals/frontend/generated/api.ts
@@ -1510,7 +1510,7 @@ export const getSignalsScoutConfigPrecheckTestUrl = (projectId: string, id: stri
}
/**
- * Run a scout's pre-check query once and return its rows, without starting a run and without saving anything. The query gets the same `{since}` and `{now}` values the next scheduled run would get, so the result says whether that run would start or skip. Pass `precheck_query` to try a query before you save it, or omit it to try the saved one. A query error comes back in the `error` field with a 200, because a scheduled run treats it as a reason to run.
+ * Run a scout's pre-check query once and return its rows, without starting a run and without saving anything. The query gets the same `{since}` and `{now}` values the next scheduled run would get, so the result says whether that run would start or skip. Pass `precheck_query` to try a query before you save it, or omit it to try the effective one: the saved query, or the default the scout's skill ships. A query error comes back in the `error` field with a 200, because a scheduled run treats it as a reason to run.
* @summary Test a scout pre-check
*/
export const signalsScoutConfigPrecheckTest = async (
diff --git a/products/signals/frontend/generated/api.zod.ts b/products/signals/frontend/generated/api.zod.ts
index 2d8fd8d45725..3405ca7eb473 100644
--- a/products/signals/frontend/generated/api.zod.ts
+++ b/products/signals/frontend/generated/api.zod.ts
@@ -856,7 +856,7 @@ export const SignalsScoutCreateBody = /* @__PURE__ */ zod
.max(signalsScoutCreateBodyConfigOnePrecheckQueryMax)
.nullish()
.describe(
- "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off."
+ "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 \* {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
),
enabled: zod
.boolean()
@@ -1115,7 +1115,7 @@ export const SignalsScoutConfigCreateBody = /* @__PURE__ */ zod
.max(signalsScoutConfigCreateBodyPrecheckQueryMax)
.nullish()
.describe(
- "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off."
+ "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 \* {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
),
enabled: zod.boolean().optional().describe('Whether this scout runs on its schedule. Defaults to true.'),
emit: zod
@@ -1423,7 +1423,13 @@ export const SignalsScoutConfigUpdateBody = /* @__PURE__ */ zod
.max(signalsScoutConfigUpdateBodyPrecheckQueryMax)
.nullish()
.describe(
- "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off."
+ "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 \* {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
+ ),
+ precheck_disabled: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'True turns off the pre-check, both `precheck_query` and the default the skill ships, so every scheduled run starts. False (the default) uses `precheck_query`, or the skill default when that is null.'
),
suggestion_id: zod
.string()
@@ -1455,7 +1461,7 @@ export const SignalsScoutConfigUpdateBody = /* @__PURE__ */ zod
.describe('Editable display name, schedule, enablement, and emit posture for one scout config.')
/**
- * Run a scout's pre-check query once and return its rows, without starting a run and without saving anything. The query gets the same `{since}` and `{now}` values the next scheduled run would get, so the result says whether that run would start or skip. Pass `precheck_query` to try a query before you save it, or omit it to try the saved one. A query error comes back in the `error` field with a 200, because a scheduled run treats it as a reason to run.
+ * Run a scout's pre-check query once and return its rows, without starting a run and without saving anything. The query gets the same `{since}` and `{now}` values the next scheduled run would get, so the result says whether that run would start or skip. Pass `precheck_query` to try a query before you save it, or omit it to try the effective one: the saved query, or the default the scout's skill ships. A query error comes back in the `error` field with a 200, because a scheduled run treats it as a reason to run.
* @summary Test a scout pre-check
*/
export const signalsScoutConfigPrecheckTestBodyPrecheckQueryMax = 10000
@@ -1466,7 +1472,7 @@ export const SignalsScoutConfigPrecheckTestBody = /* @__PURE__ */ zod.object({
.max(signalsScoutConfigPrecheckTestBodyPrecheckQueryMax)
.nullish()
.describe(
- 'HogQL `SELECT` to try, with the same `{since}` and `{now}` placeholders a saved pre-check gets. Omit it, or pass null or blank, to try the query saved on the scout.'
+ "HogQL `SELECT` to try, with the same `{since}`, `{now}` and `{interval_minutes}` placeholders a saved pre-check gets. Omit it, or pass null or blank, to try the scout's effective query: its own `precheck_query`, or the default its skill ships."
),
})
diff --git a/products/signals/frontend/inbox/__mocks__/scoutConfigs.ts b/products/signals/frontend/inbox/__mocks__/scoutConfigs.ts
index 51e95d834a13..5df251c6e5d4 100644
--- a/products/signals/frontend/inbox/__mocks__/scoutConfigs.ts
+++ b/products/signals/frontend/inbox/__mocks__/scoutConfigs.ts
@@ -48,6 +48,9 @@ function makeMockScout(overrides: MockScoutOverrides): SignalScoutConfigApi {
network_access: 'trusted',
model: null,
precheck_query: null,
+ precheck_disabled: false,
+ effective_precheck_query: null,
+ precheck_query_source: 'off',
last_run_at: null,
consecutive_failure_count: 0,
status_changed_at: null,
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutCadenceLabel.test.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutCadenceLabel.test.tsx
index 0bf010c6a560..6cb72af8938e 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutCadenceLabel.test.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutCadenceLabel.test.tsx
@@ -36,6 +36,9 @@ const config: SignalScoutConfigApi = {
network_access: 'trusted',
model: null,
precheck_query: null,
+ precheck_disabled: false,
+ effective_precheck_query: null,
+ precheck_query_source: 'off',
tags: [],
source_product: null,
source_id: null,
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.test.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.test.tsx
index 4e19b21542b3..d8de2e00a984 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.test.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutConfigControls.test.tsx
@@ -42,6 +42,9 @@ const config: SignalScoutConfigApi = {
network_access: 'trusted',
model: null,
precheck_query: null,
+ precheck_disabled: false,
+ effective_precheck_query: null,
+ precheck_query_source: 'off',
tags: [],
source_product: null,
source_id: null,
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutNextRunLabel.test.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutNextRunLabel.test.tsx
index 59a0e6a2b663..e5db30f758fc 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutNextRunLabel.test.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutNextRunLabel.test.tsx
@@ -38,6 +38,9 @@ const config: SignalScoutConfigApi = {
network_access: 'trusted',
model: null,
precheck_query: null,
+ precheck_disabled: false,
+ effective_precheck_query: null,
+ precheck_query_source: 'off',
tags: [],
source_product: null,
source_id: null,
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutPrecheckSection.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutPrecheckSection.tsx
index 29307cbb630c..ae05935e6593 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutPrecheckSection.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutPrecheckSection.tsx
@@ -57,6 +57,11 @@ export function ScoutPrecheckSection({
const { testRun, testRunLoading, testRunFailed } = useValues(logic)
const { testPrecheck } = useActions(logic)
const saved = config.precheck_query ?? null
+ // The default the scout's skill ships, when it applies to this project and no query of its own replaces it.
+ const inherited =
+ config.precheck_query_source === 'skill_default' ? (config.effective_precheck_query ?? null) : null
+ const turnedOff = config.precheck_disabled
+ const baseline = saved ?? inherited ?? ''
// Null until something is typed, so an untouched editor follows the saved query.
const [draft, setDraft] = useState<string | null>(null)
// The query the last save or turn-off sent, held until the request settles. The draft clears
@@ -71,9 +76,9 @@ export function ScoutPrecheckSection({
}
setSubmitted(null)
}, [updating, submitted, saved])
- const text = draft ?? saved ?? ''
+ const text = draft ?? baseline
const query = text.trim()
- const changed = query !== (saved ?? '')
+ const changed = query !== baseline
const unsaved = draft !== null && (changed || submitted !== null)
useEffect(() => {
onUnsavedChange?.(unsaved)
@@ -85,7 +90,11 @@ export function ScoutPrecheckSection({
const disabledReason = updating ? 'Saving scout settings' : undefined
const saveDisabledReason =
disabledReason ??
- (query && changed ? undefined : !query && saved ? 'To remove the query, use Turn off' : 'No changes to save')
+ (query && (changed || turnedOff)
+ ? undefined
+ : !query && baseline
+ ? 'To stop the pre-check, use Turn off'
+ : 'No changes to save')
return (
<div className="border-t border-primary pt-2">
@@ -99,10 +108,16 @@ export function ScoutPrecheckSection({
header: (
<div className="flex min-w-0 flex-1 items-center justify-between gap-2">
<span className="shrink-0 text-xs text-default">Run only when</span>
- {saved ? (
+ {turnedOff ? (
+ <span className="text-[11.5px] text-muted">Turned off</span>
+ ) : saved ? (
<LemonTag size="small" type="option">
Query set
</LemonTag>
+ ) : inherited ? (
+ <LemonTag size="small" type="option">
+ Default query
+ </LemonTag>
) : (
<span className="text-[11.5px] text-muted">Always run</span>
)}
@@ -114,10 +129,22 @@ export function ScoutPrecheckSection({
A HogQL query that each scheduled run checks first. When it returns no rows, or a
single false value such as a count of 0, the scout skips the run, so a quiet scout
costs nothing. Otherwise the run starts with the rows the query found. Use{' '}
- {'{since}'} for the start of the last run and {'{now}'} for the current time. To run
- at least once a week, add {'OR {since} < {now} - INTERVAL 7 DAY'}. A manual run
- always starts.
+ {'{since}'} for the start of the last run, {'{now}'} for the current time, and{' '}
+ {'{interval_minutes}'} for the minutes between scheduled runs. To run at least once
+ a week, add {'OR {since} < {now} - INTERVAL 7 DAY'}. A manual run always starts.
</span>
+ {inherited && !turnedOff ? (
+ <span className="text-[11.5px] text-muted">
+ This scout uses the default query its skill ships. Save a change to use your own
+ query instead.
+ </span>
+ ) : null}
+ {turnedOff ? (
+ <span className="text-[11.5px] text-muted">
+ The pre-check is off, so every scheduled run starts. Turn it on to use the query
+ below again.
+ </span>
+ ) : null}
<LemonTextArea
value={text}
placeholder={QUERY_PLACEHOLDER}
@@ -147,7 +174,8 @@ export function ScoutPrecheckSection({
<span className="text-[11.5px] text-danger">{result.error}</span>
) : null}
<span className="text-[11.5px] text-muted">
- {'{since}'} is {humanFriendlyDetailedTime(result.since)}.
+ {'{since}'} is {humanFriendlyDetailedTime(result.since)}.{' '}
+ {'{interval_minutes}'} is {result.interval_minutes}.
</span>
{result.rows_text ? (
<pre className="m-0 max-h-40 overflow-auto rounded border border-primary bg-surface-secondary p-2 font-mono text-[11px] whitespace-pre-wrap break-all">
@@ -157,7 +185,18 @@ export function ScoutPrecheckSection({
</div>
) : null}
<div className="flex flex-wrap items-center justify-end gap-2">
- {saved ? (
+ {turnedOff ? (
+ <LemonButton
+ size="small"
+ type="secondary"
+ className="mr-auto"
+ disabledReason={disabledReason}
+ onClick={() => onUpdate(config.id, { precheck_disabled: false })}
+ data-attr="scout-precheck-turn-on"
+ >
+ Turn on
+ </LemonButton>
+ ) : baseline ? (
<LemonButton
size="small"
type="secondary"
@@ -166,15 +205,15 @@ export function ScoutPrecheckSection({
disabledReason={disabledReason}
onClick={() =>
LemonDialog.open({
- title: 'Remove the pre-check?',
+ title: 'Turn off the pre-check?',
description:
- 'Every scheduled run starts again. You can add a query again later.',
+ 'Every scheduled run starts again. You can turn it on again later.',
primaryButton: {
children: 'Turn off',
status: 'danger',
onClick: () => {
- onUpdate(config.id, { precheck_query: null })
- setSubmitted({ query: null })
+ onUpdate(config.id, { precheck_disabled: true })
+ setDraft(null)
},
'data-attr': 'scout-precheck-clear',
},
@@ -218,7 +257,7 @@ export function ScoutPrecheckSection({
loading={updating}
disabledReason={saveDisabledReason}
onClick={() => {
- onUpdate(config.id, { precheck_query: query })
+ onUpdate(config.id, { precheck_query: query, precheck_disabled: false })
setSubmitted({ query })
}}
data-attr="scout-precheck-save"
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutTags.stories.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutTags.stories.tsx
index 184087679e49..ba4a847ea058 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutTags.stories.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutTags.stories.tsx
@@ -36,6 +36,9 @@ const config: SignalScoutConfigApi = {
network_access: 'trusted',
model: null,
precheck_query: null,
+ precheck_disabled: false,
+ effective_precheck_query: null,
+ precheck_query_source: 'off',
last_run_at: null,
consecutive_failure_count: 0,
status_changed_at: null,
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutWriteAccessSection.test.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutWriteAccessSection.test.tsx
index 0b35189a72b8..14295a31da6e 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutWriteAccessSection.test.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutWriteAccessSection.test.tsx
@@ -38,6 +38,9 @@ const CONFIG: SignalScoutConfigApi = {
network_access: 'trusted',
model: null,
precheck_query: null,
+ precheck_disabled: false,
+ effective_precheck_query: null,
+ precheck_query_source: 'off',
tags: [],
source_product: null,
source_id: null,
diff --git a/products/signals/frontend/inbox/components/config/scouts/trials/scoutTrialsFixtures.ts b/products/signals/frontend/inbox/components/config/scouts/trials/scoutTrialsFixtures.ts
index 097f9e8d4cea..0bd4fdce019c 100644
--- a/products/signals/frontend/inbox/components/config/scouts/trials/scoutTrialsFixtures.ts
+++ b/products/signals/frontend/inbox/components/config/scouts/trials/scoutTrialsFixtures.ts
@@ -31,6 +31,9 @@ export const trialFixtureConfig: SignalScoutConfigApi = {
network_access: 'trusted',
model: 'gpt-5.6-terra',
precheck_query: null,
+ precheck_disabled: false,
+ effective_precheck_query: null,
+ precheck_query_source: 'off',
last_run_at: null,
consecutive_failure_count: 0,
status_changed_at: null,
diff --git a/products/signals/frontend/inbox/logics/scoutCreateModalLogic.test.ts b/products/signals/frontend/inbox/logics/scoutCreateModalLogic.test.ts
index e8d0f0de5709..df6bb07c7183 100644
--- a/products/signals/frontend/inbox/logics/scoutCreateModalLogic.test.ts
+++ b/products/signals/frontend/inbox/logics/scoutCreateModalLogic.test.ts
@@ -65,6 +65,9 @@ const CREATED_SCOUT: SignalScoutCreateResponseApi = {
network_access: 'trusted',
model: null,
precheck_query: null,
+ precheck_disabled: false,
+ effective_precheck_query: null,
+ precheck_query_source: 'off',
source_product: null,
source_id: null,
created_at: '2026-07-24T00:00:00Z',
diff --git a/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts b/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts
index 02fd78c318df..6975928eedad 100644
--- a/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts
+++ b/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts
@@ -92,6 +92,9 @@ const BASE_CONFIG: SignalScoutConfigApi = {
network_access: 'trusted',
model: null,
precheck_query: null,
+ precheck_disabled: false,
+ effective_precheck_query: null,
+ precheck_query_source: 'off',
source_product: null,
source_id: null,
created_at: '2026-07-22T00:00:00Z',
diff --git a/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.ts b/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.ts
index 4a847b0f64c9..bb0966fcbe70 100644
--- a/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.ts
+++ b/products/signals/frontend/inbox/logics/scoutSuggestionsLogic.test.ts
@@ -119,6 +119,9 @@ const CONFIG: SignalScoutConfigApi = {
network_access: 'trusted',
model: null,
precheck_query: null,
+ precheck_disabled: false,
+ effective_precheck_query: null,
+ precheck_query_source: 'off',
source_product: null,
source_id: null,
created_at: '2026-07-22T00:00:00Z',
diff --git a/products/signals/skills/signals-scout-surveys/SKILL.md b/products/signals/skills/signals-scout-surveys/SKILL.md
index 2ddffeed5094..64bf2a19e5fe 100644
--- a/products/signals/skills/signals-scout-surveys/SKILL.md
+++ b/products/signals/skills/signals-scout-surveys/SKILL.md
@@ -17,6 +17,23 @@ allowed_tools:
metadata:
owner_team: signals
scope: surveys
+scout-precheck-query: |
+ SELECT * FROM (
+ SELECT JSONExtractString(properties, '$survey_id') AS survey_id,
+ countIf(event = 'survey shown') AS shown,
+ countIf(event = 'survey dismissed') AS dismissed,
+ countIf(event = 'survey sent') AS sent,
+ max(timestamp) AS last_seen
+ FROM events
+ WHERE event IN ('survey shown', 'survey dismissed', 'survey sent')
+ AND timestamp > {since}
+ GROUP BY survey_id
+ UNION ALL
+ SELECT 'backstop', 0, 0, 0, {now}
+ WHERE {since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))
+ )
+ ORDER BY sent DESC, shown DESC
+ LIMIT 20
---
# Signals scout: surveys
@@ -38,6 +55,10 @@ Activity history is optional. Use the reader guidance supplied by MCP only when
If a history reader is unavailable or access is denied, stop using that reader for the rest of this run. Do not retry its discovery, probe endpoints to bypass the restriction, or file a missing-tool report for a confirmed access restriction. Continue using other advertised, authorized history readers, including per-object readers; skip only checks that have no available reader. Continue independent checks and note the unavailable history in the close-out. Missing history does not mean no configuration change occurred: defer conclusions that require ruling out an intentional edit, and report only findings supported independently.
+## Pre-check rows
+
+A scheduled run can start with a `<precheck_result>` block. Each row gives one survey's `shown`, `dismissed`, and `sent` counts since the last run, and when it last saw an event. A row with `survey_id` `backstop` means no survey events arrived, and the run started only because the scout was quiet for too long. When the block is present, use it in place of the quick close-out and the volume ranking below. A block with only the `backstop` row is the same as zero survey events: check for a response-volume drop on the surveys you know, then refresh the `not-in-use:` entry if surveys are not active.
+
## Quick close-out: are surveys even active?
If `surveys-get-all` (with `archived: false`) returns an empty list **and** `surveys-global-stats` shows zero events in the last 30 days, surveys aren't active on this project. Write one scratchpad entry:
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 719e95d08b6e..e594c9bc0c5b 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -83774,11 +83774,13 @@ export namespace Schemas {
*/
write_scopes?: string[];
/**
- * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off.
+ * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`.
* @maxLength 10000
* @nullable
*/
precheck_query?: string | null;
+ /** True turns off the pre-check, both `precheck_query` and the default the skill ships, so every scheduled run starts. False (the default) uses `precheck_query`, or the skill default when that is null. */
+ precheck_disabled?: boolean;
/**
* Optional id of the canonical scout suggestion this request turns on. It records that the scout came from that suggestion. An id this project's batch does not hold is ignored.
* @maxLength 64
@@ -97221,7 +97223,7 @@ export namespace Schemas {
* * `support_notes` - Support notes */
tool_preset?: ToolPresetEnum;
/**
- * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off.
+ * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`.
* @maxLength 10000
* @nullable
*/
@@ -97382,6 +97384,15 @@ export namespace Schemas {
Background: 'background',
} as const;
+ export type ScoutPrecheckQuerySourceEnum = typeof ScoutPrecheckQuerySourceEnum[keyof typeof ScoutPrecheckQuerySourceEnum];
+
+
+ export const ScoutPrecheckQuerySourceEnum = {
+ Config: 'config',
+ SkillDefault: 'skill_default',
+ Off: 'off',
+ } as const;
+
/**
* Optional JSON Schema (draft 2020-12) describing ONE structured record this scout produces via `scout-record-output` — e.g. a per-report quality judgment (`{"type": "object", "properties": {"verdict": {"enum": ["good", "bad", "unsure"]}, "reason": {"type": "string"}}, "required": ["verdict", "reason"]}`). The root must be `"type": "object"`. Setting a schema turns the structured-output channel on: the run prompt renders the schema and every submitted record is validated against it and recorded in the project as a `$scout_structured_output` event, queryable like any event. The channel also requires emit — a dry-run scout has nowhere to record to. Cardinality is the scout's call (one record per run, one per judged entity, ...). Null = channel off. Setting a schema requires skill-authoring authorization (the `llm_skill:write` scope and skill editor access) since the scout reads it verbatim in its prompt; clearing it needs only the config write. Records validate against the schema in force when the run was dispatched.
* @nullable
@@ -97494,10 +97505,19 @@ export namespace Schemas {
*/
readonly tool_preset: string | null;
/**
- * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off.
+ * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`.
* @nullable
*/
readonly precheck_query: string | null;
+ /** True turns off the pre-check, both `precheck_query` and the default the skill ships, so every scheduled run starts. False (the default) uses `precheck_query`, or the skill default when that is null. */
+ readonly precheck_disabled: boolean;
+ /**
+ * The pre-check query the next scheduled run uses: `precheck_query`, or the default the scout's skill ships. Null when no pre-check runs.
+ * @nullable
+ */
+ readonly effective_precheck_query: string | null;
+ /** Where `effective_precheck_query` comes from: `config` (this scout's `precheck_query`), `skill_default` (the default its skill ships), or `off` (no pre-check runs). */
+ readonly precheck_query_source: ScoutPrecheckQuerySourceEnum;
/**
* When the coordinator last dispatched this scout. Null if it has never run.
* @nullable
@@ -100403,7 +100423,7 @@ export namespace Schemas {
* * `support_notes` - Support notes */
tool_preset?: ToolPresetEnum;
/**
- * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off.
+ * Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`.
* @maxLength 10000
* @nullable
*/
@@ -100566,6 +100586,8 @@ export namespace Schemas {
since: string;
/** The value bound to `{now}`. */
now: string;
+ /** The value bound to `{interval_minutes}`: the scout's rolling interval, or for a cron schedule the gap in minutes between the fire times around now. */
+ interval_minutes: number;
/** How many rows the query returned, at most 50. */
row_count: number;
/** The column names of the result, in order. */
@@ -100581,7 +100603,7 @@ export namespace Schemas {
export interface SignalScoutPrecheckTestRequest {
/**
- * HogQL `SELECT` to try, with the same `{since}` and `{now}` placeholders a saved pre-check gets. Omit it, or pass null or blank, to try the query saved on the scout.
+ * HogQL `SELECT` to try, with the same `{since}`, `{now}` and `{interval_minutes}` placeholders a saved pre-check gets. Omit it, or pass null or blank, to try the scout's effective query: its own `precheck_query`, or the default its skill ships.
* @maxLength 10000
* @nullable
*/
diff --git a/services/mcp/src/generated/replay_vision/api.ts b/services/mcp/src/generated/replay_vision/api.ts
index a4ca2e8d6195..957a383dac8b 100644
--- a/services/mcp/src/generated/replay_vision/api.ts
+++ b/services/mcp/src/generated/replay_vision/api.ts
@@ -1774,7 +1774,7 @@ export const VisionScannersScoutsCreateBody = () => zod
.max(visionScannersScoutsCreateBodyConfigOnePrecheckQueryMax)
.nullish()
.describe(
- "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off."
+ "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 \* {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
),
enabled: zod
.boolean()
diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.ts
index df4d7856d277..6d42a9454c20 100644
--- a/services/mcp/src/generated/signals/api.ts
+++ b/services/mcp/src/generated/signals/api.ts
@@ -904,7 +904,7 @@ export const SignalsScoutCreateBody = () => zod
.max(signalsScoutCreateBodyConfigOnePrecheckQueryMax)
.nullish()
.describe(
- "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off."
+ "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 \* {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
),
enabled: zod
.boolean()
@@ -1160,7 +1160,7 @@ export const SignalsScoutConfigCreateBody = () => zod
.max(signalsScoutConfigCreateBodyPrecheckQueryMax)
.nullish()
.describe(
- "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off."
+ "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 \* {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
),
enabled: zod.boolean().optional().describe('Whether this scout runs on its schedule. Defaults to true.'),
emit: zod
@@ -1477,7 +1477,13 @@ export const SignalsScoutConfigUpdateBody = () => zod
.max(signalsScoutConfigUpdateBodyPrecheckQueryMax)
.nullish()
.describe(
- "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off."
+ "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 \* {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
+ ),
+ precheck_disabled: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'True turns off the pre-check, both `precheck_query` and the default the skill ships, so every scheduled run starts. False (the default) uses `precheck_query`, or the skill default when that is null.'
),
suggestion_id: zod
.string()
@@ -1522,7 +1528,7 @@ export const SignalsScoutConfigDestroyParams = () => zod.object({
})
/**
- * Run a scout's pre-check query once and return its rows, without starting a run and without saving anything. The query gets the same `{since}` and `{now}` values the next scheduled run would get, so the result says whether that run would start or skip. Pass `precheck_query` to try a query before you save it, or omit it to try the saved one. A query error comes back in the `error` field with a 200, because a scheduled run treats it as a reason to run.
+ * Run a scout's pre-check query once and return its rows, without starting a run and without saving anything. The query gets the same `{since}` and `{now}` values the next scheduled run would get, so the result says whether that run would start or skip. Pass `precheck_query` to try a query before you save it, or omit it to try the effective one: the saved query, or the default the scout's skill ships. A query error comes back in the `error` field with a 200, because a scheduled run treats it as a reason to run.
* @summary Test a scout pre-check
*/
export const SignalsScoutConfigPrecheckTestParams = () => zod.object({
@@ -1542,7 +1548,7 @@ export const SignalsScoutConfigPrecheckTestBody = () => zod.object({
.max(signalsScoutConfigPrecheckTestBodyPrecheckQueryMax)
.nullish()
.describe(
- 'HogQL `SELECT` to try, with the same `{since}` and `{now}` placeholders a saved pre-check gets. Omit it, or pass null or blank, to try the query saved on the scout.'
+ "HogQL `SELECT` to try, with the same `{since}`, `{now}` and `{interval_minutes}` placeholders a saved pre-check gets. Omit it, or pass null or blank, to try the scout's effective query: its own `precheck_query`, or the default its skill ships."
),
})
diff --git a/services/mcp/src/tools/generated/signals.ts b/services/mcp/src/tools/generated/signals.ts
index ac5f9f97fc1b..142b009855d4 100644
--- a/services/mcp/src/tools/generated/signals.ts
+++ b/services/mcp/src/tools/generated/signals.ts
@@ -1056,6 +1056,9 @@ const scoutConfigUpdate = (): ToolBase<
if (params.precheck_query !== undefined) {
body['precheck_query'] = params.precheck_query
}
+ if (params.precheck_disabled !== undefined) {
+ body['precheck_disabled'] = params.precheck_disabled
+ }
if (params.suggestion_id !== undefined) {
body['suggestion_id'] = params.suggestion_id
}
@@ -2515,6 +2518,9 @@ const signalsScoutConfigUpdate = (): ToolBase<
if (params.precheck_query !== undefined) {
body['precheck_query'] = params.precheck_query
}
+ if (params.precheck_disabled !== undefined) {
+ body['precheck_disabled'] = params.precheck_disabled
+ }
if (params.suggestion_id !== undefined) {
body['suggestion_id'] = params.suggestion_id
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-create.json
index 9756deec16bb..0430681d280c 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-create.json
@@ -150,7 +150,7 @@
"type": "null"
}
],
- "description": "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off."
+ "description": "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
},
"repositories": {
"description": "GitHub repositories this scout clones into its sandbox, each in `organization/repo` format. Set them for a scout that reads code, so it can search the tree and run the project's own tests instead of reading files one API call at a time. Empty (the default) leaves the sandbox without a checkout. The scout's GitHub access stays read-only either way, so a repository listed here is never writable from a run. At most 10, each reachable through the project's GitHub connection. Applies from the scout's next run.",
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-precheck-test.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-precheck-test.json
index 3eb73aa09cc4..91704db2bb3a 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-precheck-test.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-precheck-test.json
@@ -15,7 +15,7 @@
"type": "null"
}
],
- "description": "HogQL `SELECT` to try, with the same `{since}` and `{now}` placeholders a saved pre-check gets. Omit it, or pass null or blank, to try the query saved on the scout."
+ "description": "HogQL `SELECT` to try, with the same `{since}`, `{now}` and `{interval_minutes}` placeholders a saved pre-check gets. Omit it, or pass null or blank, to try the scout's effective query: its own `precheck_query`, or the default its skill ships."
}
},
"required": ["id"],
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.json
index 084d1a28df04..686671ee5fe0 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-config-update.json
@@ -142,6 +142,10 @@
},
"type": "object"
},
+ "precheck_disabled": {
+ "description": "True turns off the pre-check, both `precheck_query` and the default the skill ships, so every scheduled run starts. False (the default) uses `precheck_query`, or the skill default when that is null.",
+ "type": "boolean"
+ },
"precheck_query": {
"anyOf": [
{
@@ -152,7 +156,7 @@
"type": "null"
}
],
- "description": "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off."
+ "description": "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
},
"repositories": {
"description": "GitHub repositories this scout clones into its sandbox, each in `organization/repo` format. Set them for a scout that reads code, so it can search the tree and run the project's own tests instead of reading files one API call at a time. Empty (the default) leaves the sandbox without a checkout. The scout's GitHub access stays read-only either way, so a repository listed here is never writable from a run. At most 10, each reachable through the project's GitHub connection. Applies from the scout's next run.",
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-create.json
index a49003579123..679d076ca74e 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/scout-create.json
@@ -152,7 +152,7 @@
"type": "null"
}
],
- "description": "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off."
+ "description": "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
},
"repositories": {
"description": "GitHub repositories this scout clones into its sandbox, each in `organization/repo` format. Set them for a scout that reads code, so it can search the tree and run the project's own tests instead of reading files one API call at a time. Empty (the default) leaves the sandbox without a checkout. The scout's GitHub access stays read-only either way, so a repository listed here is never writable from a run. At most 10, each reachable through the project's GitHub connection. Applies from the scout's next run.",
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-create.json
index 9756deec16bb..0430681d280c 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-create.json
@@ -150,7 +150,7 @@
"type": "null"
}
],
- "description": "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off."
+ "description": "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
},
"repositories": {
"description": "GitHub repositories this scout clones into its sandbox, each in `organization/repo` format. Set them for a scout that reads code, so it can search the tree and run the project's own tests instead of reading files one API call at a time. Empty (the default) leaves the sandbox without a checkout. The scout's GitHub access stays read-only either way, so a repository listed here is never writable from a run. At most 10, each reachable through the project's GitHub connection. Applies from the scout's next run.",
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.json
index 084d1a28df04..686671ee5fe0 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/signals-scout-config-update.json
@@ -142,6 +142,10 @@
},
"type": "object"
},
+ "precheck_disabled": {
+ "description": "True turns off the pre-check, both `precheck_query` and the default the skill ships, so every scheduled run starts. False (the default) uses `precheck_query`, or the skill default when that is null.",
+ "type": "boolean"
+ },
"precheck_query": {
"anyOf": [
{
@@ -152,7 +156,7 @@
"type": "null"
}
],
- "description": "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off."
+ "description": "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
},
"repositories": {
"description": "GitHub repositories this scout clones into its sandbox, each in `organization/repo` format. Set them for a scout that reads code, so it can search the tree and run the project's own tests instead of reading files one API call at a time. Empty (the default) leaves the sandbox without a checkout. The scout's GitHub access stays read-only either way, so a repository listed here is never writable from a run. At most 10, each reachable through the project's GitHub connection. Applies from the scout's next run.",
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-scouts-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-scouts-create.json
index 9595eaf909e2..147306b39fa0 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-scouts-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/vision-scanners-scouts-create.json
@@ -151,7 +151,7 @@
"type": "null"
}
],
- "description": "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank turns the pre-check off."
+ "description": "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 * {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
},
"repositories": {
"description": "GitHub repositories this scout clones into its sandbox, each in `organization/repo` format. Set them for a scout that reads code, so it can search the tree and run the project's own tests instead of reading files one API call at a time. Empty (the default) leaves the sandbox without a checkout. The scout's GitHub access stays read-only either way, so a repository listed here is never writable from a run. At most 10, each reachable through the project's GitHub connection. Applies from the scout's next run.",