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(desktop): tell no-repo tasks to search business knowledge first (#101624)

Alex V723d7ee5efd1
diff --git a/products/desktop/packages/agent/src/server/agent-server.test.ts b/products/desktop/packages/agent/src/server/agent-server.test.ts
index 9bbb38eb9b2d..9aa4cd7d0001 100644
--- a/products/desktop/packages/agent/src/server/agent-server.test.ts
+++ b/products/desktop/packages/agent/src/server/agent-server.test.ts
@@ -6808,6 +6808,8 @@ describe("AgentServer HTTP Mode", () => {
"Generated-By: PostHog Desktop",
"Task-Id: test-task-id",
"canonical `posthog:exec` tool",
+ "`posthog:business-knowledge-documents-search`",
+ "whatever else the question is about",
"`posthog:read-data-schema`",
"`posthog:metric-list`",
"`posthog:metric-describe`",
@@ -6836,6 +6838,8 @@ describe("AgentServer HTTP Mode", () => {
"You may make local edits in a repository cloned with `clone_repo`",
"Do NOT create branches, commits, push changes, or open pull requests in this run",
"canonical `posthog:exec` tool",
+ "`posthog:business-knowledge-documents-search`",
+ "whatever else the question is about",
"`posthog:metric-list`",
"`posthog:metric-describe`",
"`posthog:data-catalog-metric-run`",
diff --git a/products/desktop/packages/agent/src/server/agent-server.ts b/products/desktop/packages/agent/src/server/agent-server.ts
index 0ada3d2bbbe2..2d30942361c3 100644
--- a/products/desktop/packages/agent/src/server/agent-server.ts
+++ b/products/desktop/packages/agent/src/server/agent-server.ts
@@ -4846,6 +4846,8 @@ ${prMentionSafetyInstruction.trimStart()}
You are a helpful assistant with access to PostHog via MCP tools. You can help with both code tasks and data/analytics questions.
+For a question about company-specific terms, internal policies, or team knowledge, search the project knowledge base before you answer, whatever else the question is about: call \`posthog:exec\` and run its inner \`posthog:business-knowledge-documents-search\` tool. These documents are not in the public docs or the context wiki, so check the knowledge base before you tell the user that you cannot find the answer. If that tool is not available in this project, move on instead of retrying it.
+
When the user asks about analytics, data, metrics, events, funnels, dashboards, feature flags, experiments, or anything PostHog-related:
- Use the canonical \`posthog:exec\` tool to query data, search insights, and provide real answers
- A count, sum, or amount of X per day/hour/week/month/year, a rate or percentage of X, an average or percentile of X, a cost per X, a conversion between two events, or a derived form of one of those is a governed metric question — whatever X is (sessions, 404s, feedback submissions, scout runs, tool calls, revenue). For those, inspect the complete governed catalog with \`posthog:metric-list\` first, inspect a candidate with \`posthog:metric-describe\`, then run an approved match with \`posthog:data-catalog-metric-run\`. Do this before \`posthog:read-data-schema\`, a typed domain tool, or a raw query