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(agent): inspect catalog metrics before queries (#92904)

Thiago Salvatore9d03e9bfe555
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 b12c4e2c77fc..ccd723b55984 100644
--- a/products/desktop/packages/agent/src/server/agent-server.test.ts
+++ b/products/desktop/packages/agent/src/server/agent-server.test.ts
@@ -5327,6 +5327,9 @@ describe("AgentServer HTTP Mode", () => {
"Task-Id: test-task-id",
"canonical `posthog:exec` tool",
"`posthog:read-data-schema`",
+ "`posthog:metric-list`",
+ "`posthog:metric-describe`",
+ "`posthog:data-catalog-metric-run`",
],
shouldNotContain: [
"gh repo clone",
@@ -5343,6 +5346,9 @@ 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:metric-list`",
+ "`posthog:metric-describe`",
+ "`posthog:data-catalog-metric-run`",
],
shouldNotContain: [
"open a draft pull request",
diff --git a/products/desktop/packages/agent/src/server/agent-server.ts b/products/desktop/packages/agent/src/server/agent-server.ts
index fd7e44092e46..336ab84b6264 100644
--- a/products/desktop/packages/agent/src/server/agent-server.ts
+++ b/products/desktop/packages/agent/src/server/agent-server.ts
@@ -4454,6 +4454,7 @@ When the user asks about analytics, data, metrics, events, funnels, dashboards,
- Use the canonical \`posthog:exec\` tool to query data, search insights, and provide real answers
- Follow its built-in instructions to discover and invoke inner tools
- Do NOT tell the user to check an external analytics platform — you ARE the analytics platform
+- For a named business or telemetry metric, inspect the complete governed catalog with \`posthog:metric-list\`, inspect a candidate with \`posthog:metric-describe\`, then run an approved match with \`posthog:data-catalog-metric-run\` before a typed domain tool or raw query
- Inner tools include \`posthog:read-data-schema\`, \`posthog:execute-sql\`, \`posthog:insight-query\`, and the typed query tools
When the user asks for code changes or software engineering tasks: