integrating-with-posthog-ai

Integrate PostHog product surfaces with the PostHog AI agent frontend.

713|118|Updated Aug 11, 2020
One-click install
npx skills add https://github.com/PostHog/posthog-foss --skill integrating-with-posthog-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: integrating-with-posthog-ai
Source: https://github.com/PostHog/posthog-foss/tree/main/.agents/skills/integrating-with-posthog-ai
Command: npx skills add https://github.com/PostHog/posthog-foss --skill integrating-with-posthog-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Wiring a PostHog product surface into the PostHog AI agent requires choosing the correct frontend seam, and mistakes like injecting user data into trusted context or sending full object shapes cause prompt-injection risks and per-turn token bloat.

Core Features & Use Cases

  • Context and instruction injection: Attach scene or entity context and trusted instructions so the agent knows what the user is viewing and how to behave on the page.
  • Tool-event reactions: Listen to the tool-stream bus or use apply-back hooks so open pages update when the agent calls MCP tools.
  • Tool card rendering: Register renderers so product tool calls display as rich cards with permission previews instead of generic fallbacks.
  • Use Case: A developer building the workflows scene uses useSceneAgentPanel to attach live editor state, injects the product's skill and MCP tool catalog as trusted instructions, and applies agent edits back into the open form.

Quick Start

Ask the agent to integrate your PostHog product scene with PostHog AI by attaching context, injecting instructions, and reacting to tool calls using the seams in this skill.

Frequently Asked Questions about integrating-with-posthog-ai

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I attach context to the PostHog AI agent from my scene?

Use the useAttachedContext hook from api/logics with items shaped as { type, key, label }, or useSceneAgentPanel for a whole scene. Send identifiers rather than serialized entities, since the context block rides on every message in the conversation.

How do I make my page update when the PostHog AI agent calls a tool?

Use useToolStreamListener for plain reactions like refetching, or useMcpToolApplyBack to apply agent edits into an open form. Match on the completed phase, filter by the target resource id, and rely on the default replay suppression.

What is the difference between trusted and untrusted context in PostHog AI?

Items with type 'instructions' land in trusted context that the agent follows as direction, while all other items land in untrusted context treated as data. Trusted items must contain only build-time strings, never user-entered or interpolated values, to prevent prompt injection.

Can I build a custom agent UI with the PostHog AI run primitives?

The run primitives like RunSurface and runStreamLogic are public but not recommended for product integrations. Building on them means owning stream binding, composer state, and permission routing; copy the signals inbox or TaskRunChat reference implementations if truly needed.

Why is my tool event handler firing again after a page reload?

Reload replays run history through the same code path, but replay events are suppressed by default. If your handler fires on reload, check that you did not set includeReplay: true, and confirm you are matching on the completed phase.