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.

fix(signals): tell scouts the project timezone for SQL bounds (#115600)

Alessandro Pogliaghic0fa08062ad6
diff --git a/products/signals/backend/scout_harness/prompt.py b/products/signals/backend/scout_harness/prompt.py
index 0653423f746e..b8c4d79f7b7b 100644
--- a/products/signals/backend/scout_harness/prompt.py
+++ b/products/signals/backend/scout_harness/prompt.py
@@ -1327,6 +1327,7 @@ def build_run_prompt(
run_id: str,
team_id: int,
started_at: datetime,
+ project_timezone: str = "UTC",
github_read_access: bool = False,
structured_output_schema: dict | None = None,
write_scopes: Sequence[str] | None = None,
@@ -1477,6 +1478,7 @@ def build_run_prompt(
run_identity = f"""# Your run identity
- **team_id**: `{team_id}`, implicit on every MCP call.
+- **project_timezone**: `{project_timezone}`. HogQL resolves `now()` and bare datetime literals in this timezone, not UTC, so write every timestamp bound as `toDateTime('YYYY-MM-DD HH:MM:SS', 'UTC')` and confirm the bounds cover the intended UTC window before you treat an empty result as a quiet one.
- **skill_name**: `{skill.name}`, your steering layer.
- **skill_version**: `{skill.version}`, the version it is pinned to, written as a bare number and never `v`-prefixed. `skill_name` and `skill_version` are the two arguments the `skill-get` call in *First: read your skill* takes.{authors_line}
- **run_id**: `{run_id}`, passed to every `scout-*` tool that takes it, including `{emit_tool}`{check_tools_suffix}.
diff --git a/products/signals/backend/scout_harness/runner.py b/products/signals/backend/scout_harness/runner.py
index 5cca5870265c..df6c00ce91e0 100644
--- a/products/signals/backend/scout_harness/runner.py
+++ b/products/signals/backend/scout_harness/runner.py
@@ -996,6 +996,7 @@ async def _spawn_and_run(
run_id=str(run_id),
team_id=team.id,
started_at=started_at,
+ project_timezone=team.timezone,
github_read_access=github_guidance,
project_has_governed_metrics=project_has_governed_metrics,
# Names the external MCP servers the sandbox will mount, so *How to call tools* can carve
diff --git a/products/signals/backend/test/test_scout_harness.py b/products/signals/backend/test/test_scout_harness.py
index 92ac8038d3e8..f97389ec9b24 100644
--- a/products/signals/backend/test/test_scout_harness.py
+++ b/products/signals/backend/test/test_scout_harness.py
@@ -1007,7 +1007,10 @@ class TestPromptBuilder(BaseTest):
run_id="00000000-0000-0000-0000-000000000abc",
team_id=self.team.id,
started_at=started_at,
+ project_timezone="America/Vancouver",
)
+ assert "- **project_timezone**: `America/Vancouver`" in prompt
+ assert "toDateTime('YYYY-MM-DD HH:MM:SS', 'UTC')" in prompt
# Identity carries the skill name + version so bootstrap can reference it. The version
# renders as the bare number `skill-get` takes, since the endpoint validates it as an
# integer and the bootstrap points here rather than interpolating the value itself.