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(self-driving): Prompt agents to clone further repos (#69794)

Michael Matloka2f82514dfa86
diff --git a/products/signals/backend/custom_agent/base.py b/products/signals/backend/custom_agent/base.py
index a29dfb3e0ba3..64471f5cdba9 100644
--- a/products/signals/backend/custom_agent/base.py
+++ b/products/signals/backend/custom_agent/base.py
@@ -559,10 +559,15 @@ Rules:
def _initial_session_preamble(self) -> str:
if self.repository:
repository_context = (
- f"Selected subject repository: `{self.repository}`. Use it as the main codebase for investigation."
+ f"Selected subject repository: `{self.repository}`. Use it as the main codebase for investigation - "
+ "but it's a starting point, not a boundary. If the evidence points at code in a different repository, "
+ "clone it and keep going: `gh repo clone <org>/<repo>`. Cloning a further repo is cheap."
)
else:
- repository_context = "No subject repository for this run; do not assume any codebase context."
+ repository_context = (
+ "No subject repository was pre-selected for this run. But if the task does turn out to involve "
+ "a specific repository, clone it yourself (`gh repo clone <org>/<repo>`). Cloning a repo is cheap."
+ )
return f"""You are running as a custom PostHog Signals agent.
## Initial request
diff --git a/products/signals/backend/report_generation/research.py b/products/signals/backend/report_generation/research.py
index f57f7fe94bf6..d2766113fa83 100644
--- a/products/signals/backend/report_generation/research.py
+++ b/products/signals/backend/report_generation/research.py
@@ -338,6 +338,11 @@ You have two investigation tools:
1. **The codebase** — the full PostHog repository is available on disk. Use file search, grep, and code reading.
2. **PostHog MCP** — you can query PostHog analytics data via MCP tools like `execute-sql`, `query-run`, `read-data-schema`, `insights-get-all`, `experiment-get`, `list-errors`, `feature-flag-get-all`, etc.
+The cloned repository is your starting point, not a boundary. When the evidence points at code outside this repository, clone that repository and keep investigating there: `gh repo clone <org>/<repo>`.
+Cloning a further repo is cheap — do it the moment a different repo becomes relevant, rather than forcing a finding onto the repo you happen to be in.
+For safety, only clone legit, imperfectly defined by us as: either in the same org as the initial repo OR open-source with dozens+ stars & weeks+ old.
+If the true subject is a repo you genuinely cannot reach, say so in the finding instead of guessing.
+
The report's history lives in its artefacts (prior findings, judgments, notes, task runs). You can list them with the `inbox-report-artefacts-list` MCP tool when prior context would help. Do not create or modify artefacts yourself — at the end of the session you will be asked for your findings and assessments as structured responses, and the pipeline persists them. Where an existing artefact of a given type is still correct, you will be able to confirm it instead of producing a new one.
When a signal includes **Attached images**, the URLs are publicly reachable — fetch them directly to inspect screenshots, UI issues, or other visual evidence.