: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
UPSERT_DASHBOARD_TOOL_PROMPT = """
Use this tool to create or update a dashboard with provided insights.
# How to use this tool
## Create vs update
Proactively use search and list_data tools to check if the dashboard already exists.
The user might provide you the dashboard–read its data and understand the structure of the dashboard.
You should ask for clarification if the request is ambiguous whether you need to create a new dashboard or update an existing one.
## Insights selection
Proactively use list_data and search tools to find existing insights.
If there are matching insights, read their insight schemas to understand whether they match the user's intent and have data.
Next, read the data schema and data warehouse schema and create new insights or SQL queries.
## Use dashboard templates as reference
PostHog ships vetted dashboard templates for common topics (product analytics, retention, revenue, etc.).
When they're available to you, browse the templates for one close to the user's topic and look at the insights it pairs together — they're a good signal of what a strong dashboard on that topic looks like.
Treat templates as examples, not instructions: take inspiration from the insights and their groupings, but tailor every insight to the user's own events, properties, and intent rather than copying a template verbatim.
## Finalize
Call this tool when you have enough information to create or update the dashboard.
# Choose the dashboard action from the requested state change
Use `add_insights` when the user wants to keep the current dashboard and include new insights. This includes requests to add, include, expand, or put a metric on a dashboard. Send only the new insight IDs. This action never removes existing insight tiles.
Use `duplicate` when the user wants a copy of an existing dashboard, for example the same dashboard for another customer, subscription, or date range. It keeps the dashboard variables, filters, tiles, layouts, and the chart settings of each insight (number formatting, prefixes, and suffixes). Do not rebuild the insights with SQL for a copy. Use `variable_values` to change only the variable values that differ, keyed by the variable code name. Never hardcode a value in SQL when the source dashboard has a variable for it.
Use `update` only when the user defines the complete intended set of dashboard insights, asks to remove or replace insights, or asks to change dashboard metadata.
# Understanding full dashboard update with insight_ids
When `insight_ids` is provided, it replaces all dashboard insights with the provided insights.
Use insight_ids to replace or remove insights.
By default, keep existing insight tile layouts unchanged (`layout_mode="preserve_existing"`).
Use `layout_mode="reflow_all"` whenever the user explicitly asks to change placement/order, including phrases like:
- reorder/rearrange/reflow the dashboard
- move an insight before/after another insight
- insert an insight between two insights
- place an insight first/last/at the top
Keep `layout_mode="preserve_existing"` for plain add/remove/replace requests where layout should stay unchanged.
When using `layout_mode="reflow_all"`, tile coordinates are recomputed in the order of `insight_ids`.
Example: Dashboard has [A, B, C] (in layout order). Use `insight_ids=[A, C]` (same insight IDs, omitting B).
Result: A and C keep their existing tile layouts, B's tile is soft-deleted, and no new tiles are created.
# When to use this tool
- The user asks to create, copy, or update a dashboard.
- The user asks for multiple metrics or dimensions, so it might be better to visualize them in a dashboard.
- The user wants to modify insights on an existing dashboard (add, remove, or replace).
<example>
User: create a dashboard for file activity metrics
Assistant: I'll create a new dashboard for file activity metrics.
<reasoning>The user clearly wants to create a new dashboard.</reasoning>
</example>
<example>
User: I want a dashboard of how my business is doing
Assistant: I'll search for existing dashboards. I found a relevant dashboard. Do you want me to summarize it or update it?
User: I want you to add MRR to that dashboard.
<reasoning>The user wants to retain the current dashboard and add MRR. Use add_insights with the new MRR insight ID.</reasoning>
</example>
<example>
User: get my financial metrics together
Assistant: I'll search for existing dashboards. I didn't find any relevant dashboards. Let me search for related insights. I found some insights, but I should list the existing insights to make sure I haven't missed due to different naming. Perfect! I found more relevant insights.
<reasoning>The assistant has to list the existing insights to make sure it hasn't missed any relevant insights due to specifics of the search tool using full-text search.</reasoning>
</example>
# When NOT to use this tool
- The user wants to save a single insight.
# Guidelines
- Use a minimal set of insights to reflect the changes the user requested.
- When updating dashboard or insight names or descriptions, use the original insight names or descriptions as a reference.
""".strip()
UPSERT_DASHBOARD_CONTEXT_PROMPT_TEMPLATE = """
The user is currently viewing a dashboard. Here is the dashboard's current definition:
```json
{current_dashboard}
```
""".strip()
CREATE_NO_INSIGHTS_PROMPT = """
Cannot create dashboard: no valid insights found. Please provide valid insight IDs.
""".strip()
DASHBOARD_NOT_FOUND_PROMPT = """
Dashboard with ID {dashboard_id} not found.
""".strip()
NO_PERMISSION_PROMPT = """
You do not have permission to edit this dashboard.
""".strip()
UPDATE_NO_CHANGES_PROMPT = """
Cannot update dashboard: no valid insights found and no metadata changes provided.
""".strip()
MISSING_INSIGHTS_NOTE_PROMPT = """
Note: The following insight IDs could not be added (not found or not saved): {missing_ids}
""".strip()
PERMISSION_REQUEST_PROMPT = """
## Updating dashboard: {{{dashboard_name}}}
{{#new_dashboard_name}}
**Rename to:** {{{new_dashboard_name}}}
{{/new_dashboard_name}}
{{#new_dashboard_description}}
**New description:** {{{new_dashboard_description}}}
{{/new_dashboard_description}}
{{#deleted_insights}}
## Removing {{{deleted_count}}}
{{{deleted_insights}}}
{{/deleted_insights}}
{{#new_insights}}
## Adding {{{added_count}}}
{{{new_insights}}}
{{/new_insights}}
""".strip()
MISSING_INSIGHT_IDS_PROMPT = """
Some insights were not found in the conversation artifacts: {{{missing_ids}}}. You should check if the provided insight_ids are correct.
""".strip()
UNKNOWN_VARIABLES_PROMPT = """
These variables do not exist in this project: {{{unknown_variables}}}. Use the code names of existing variables: {{{available_variables}}}.
""".strip()