Skip to content

What does the PostHog AI sandbox stream while it edits, and how do we run it locally? #301

Closed

Description

@Silthus

Map: Map: PostHog AI live-edits the open email in every Workflows email editor

Cast: GPT-6.1 Sol, /research

Question

What does the PostHog AI sandbox runtime give the frontend while the agent works, and how do we run a real agent turn against a local stack?

  • Does an MCP tool call's input stream to the frontend as updated phases on toolStreamEventsLogic before it completes? How granular is it, and is the inner tool name known early enough for partial input to be useful?
  • How do useMcpToolApplyBack and the bus behave when one turn targets several resources, for example two emails of one sequence (it fails closed on ambiguity)? Can a target change mid-turn?
  • Can the frontend answer a tool call, or only react to it? (Frontend-applied sandbox tools are ruled out, but the fact still shapes the tool contract.)
  • What does a turn need to run locally end to end (sandbox, model access, MCP server), so the map's proof bar (a recorded real run) is reachable? Write the exact steps.
  • How large can attached context get per message, and what does it cost to include the open email's design JSON with block ids?

Sources: products/posthog_ai/frontend/ (runStreamLogic, toolStreamEventsLogic, useMcpToolApplyBack), the sandbox agent runtime and MCP server code, and the existing apply-back callers (QueryWindow.tsx, DashboardHeader.tsx). Feeds the architecture prototype.

Activity

  1. self-assigned this
    on Oct 6, 2026
  2. Silthus commented on Oct 6, 2026

    @Silthus
    OwnerAuthor

    Note

    🤖 GPT-6.1 Sol responding on behalf of Michael

    Resolved from upstream/master at 5202af95fd153. Findings and exact local steps.

    • Claude streams growing outer MCP input snapshots as updated events. The inner tool name becomes available during generation, but the frontend's innerInput parser waits for complete embedded JSON.
    • Apply-back snapshots editor activations at send time. It rejects multiple targets matching the same tool, and switching emails cannot transfer the claim. Its default applies each completed tool call. turn_end keeps only the last completion, not one result per email.
    • The web app reacts to MCP results and answers permissions or questions. The generic desktop MCP relay can return tool results, but the current web apply-back hook cannot.
    • Local runs need Docker, Temporal, the model gateway and MCP. Select ai_features, tasks and mcp, run setup_background_agents, supply model access, enable phai-sandbox-mode, and use LOCAL_POSTHOG_CODE_MONOREPO_ROOT=./packages/agent to match the researched runtime source. Environment preparation and service resolution worked. No real turn was recorded.
    • The current inline context path has no dedicated attachment cap. Workflow state elides designs above 64,000 characters. The legacy bridge allows 32 items and 4,096 characters per value. A checked-in welcome-email design is 2,778 bytes with four IDs, about 750 tokens. The existing frontend contract tests passed, 20 across three suites.

    The recording remains for the implementation proof. The optional Go gateway repository was unavailable to this session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions