Skip to content

fix(mcp-analytics): hand off cleanly when the SDK install is blocked#929

Draft
sarahxsanders wants to merge 8 commits into
posthog-code/abort-not-error-trackingfrom
posthog-code/mcp-analytics-install-handoff
Draft

fix(mcp-analytics): hand off cleanly when the SDK install is blocked#929
sarahxsanders wants to merge 8 commits into
posthog-code/abort-not-error-trackingfrom
posthog-code/mcp-analytics-install-handoff

Conversation

@sarahxsanders

@sarahxsanders sarahxsanders commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

What it changes

When the mcp-analytics skill (PostHog/context-mill#252) can't install the SDK inside the sandbox, the wizard no longer treats it as an error or an abort. It is a non-fatal handoff: the agent finishes all the code changes, the run succeeds, and the outro shows the install as the one step left for the user.

Under the hood this replaces the old [ABORT] manual install required path with a new, generic [MANUAL-STEP] signal. Any program can now emit [MANUAL-STEP] <text> to flag a remaining action; it is collected like [WIZARD-REMARK], never halts the run, and is rendered in the success outro's next-steps section. The wizard stays product-agnostic (it does not know what "install" is); the skill supplies the text.

Why it is a success, not an abort

[ABORT] is a hard halt: the moment the agent emits it, the run is killed. Agents usually install before they write code, so an abort on a blocked install fires before any instrumentation happens, and the handoff copy would claim the code changes were done when nothing had been. Asking the agent to instead defer the abort until after the code changes is exactly the "finish everything, then fail in a structured way" reasoning that weaker models don't do reliably.

A sandbox-blocked install is not a failure. In a monorepo the install has to write a hoisted node_modules above the project folder, outside the sandbox we deliberately keep installs inside for security, so it always belongs to the user. Modeling it as a non-fatal success with one step left removes the early bail entirely (a blocked install no longer halts anything) and drops the fragile reasoning. A completion guard still blocks a hollow success: a run that did no work, or left planned tasks open, is still an error, not a false "one step left."

This replaces the abort-based handoff after review feedback on the stack.

User experience

The user sees a normal green success, with the install as the remaining step:

Almost done. One step left.

One step left

  • Run yarn add @posthog/mcp posthog-node to install the PostHog MCP SDK, then restart your server.

The command adapts to the user's package manager, so npm, pnpm, and bun users see their own line. And because of #920, the two genuine dead ends (no MCP server, unsupported language) still stop as expected conditions that are not logged as errors.

Merge order

These three PRs are one fix in three parts. Merge in this order:

  1. wizard #920: base of the wizard stack, merge first.
  2. wizard #929: stacked on fix(wizard): stop reporting expected agent aborts as errors #920, merge after it.
  3. context-mill #252: release after fix(mcp-analytics): hand off cleanly when the SDK install is blocked #929, so the skill and the wizard light up together.

This PR is step 2. It is stacked on #920 and needs #252 to actually fire.

Nothing breaks if they land out of order. #929 and #252 are each harmless on their own; they just do nothing until both are live.

🤖 Generated with Claude Code

David's run reported "MCP analytics configured!" on a project that didn't
compile: the agent made the edits, but `yarn add` was blocked by a filesystem
sandbox limit (his package is a monorepo member, so the install had to write a
hoisted node_modules outside the agent's writable directory). The failure was
buried in the report file and the run still finished as a success.

Add a `manual install required` abort case so a blocked install surfaces a
clear handoff outro with the command to run, instead of a false success. Rides
on resolveAbortOutcome (#920): a matched abort renders the friendly outro and is
NOT reported to error tracking, since a blocked monorepo install is an expected
user condition, not a bug.

Requires the context-mill mcp-analytics skill to emit
`[ABORT] manual install required: <command>` when STEP 7 verify fails — that
change is a separate context-mill PR. Until it ships this case is inert.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

Solution A is handoff-only: we won't move package installs (and their
lifecycle scripts) outside the agent sandbox to close one monorepo case.
The skill, report, and edits are already left in place on the abort path
(the keep-skills prompt is success-only), so tell the user they can finish
either by running the install themselves or by pointing their own AI coding
tool at the still-installed .claude/skills/mcp-analytics.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
sarahxsanders and others added 2 commits July 20, 2026 10:11
Make it explicit why the wizard didn't install for the user: it runs in a
sandbox for security and won't write outside the project folder, so a
monorepo install (which writes a parent folder) is out of reach by design.
Note that their own AI tool is not sandboxed, so it can finish the step.
…mmand

Rework the "manual install required" handoff so it does not hardcode the
install command and leads with the skill:
- AbortCase.body may now be a function that receives the regex match, so a
  case can pull captured groups out of the abort reason. resolveAbortOutcome
  resolves it.
- The mcp-analytics regex captures the exact command the skill detected (it
  travels after the colon in "[ABORT] manual install required: <command>"),
  so the handoff shows the right one for the user's package manager. Command
  is optional, so an older skill emitting a bare reason still matches.
- Copy leads with the skill (the user's own unsandboxed AI tool can finish;
  the skill is saved at .claude/skills/mcp-analytics). Terminal fallback shows
  the detected command, or names the packages if none was sent. docsUrl
  renders the docs link.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sarahxsanders
sarahxsanders marked this pull request as ready for review July 20, 2026 15:13
@sarahxsanders
sarahxsanders requested a review from a team as a code owner July 20, 2026 15:13

@gewenyu99 gewenyu99 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy nit, but lgtm

Comment thread src/lib/programs/mcp-analytics/index.ts Outdated
Comment thread src/lib/programs/mcp-analytics/index.ts Outdated
sarahxsanders and others added 3 commits July 20, 2026 14:47
Co-authored-by: Vincent (Wen Yu) Ge <29069505+gewenyu99@users.noreply.github.com>
The web edit left tab-indented lines in the handoff body, which failed the
prettier check. Reformat to spaces and shorten the over-long comment.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Cut comments that restated the code (the body-type branch, several test-case
comments) and tightened the three that carry real intent down to the non-obvious
why. Also drops the em dashes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sarahxsanders
sarahxsanders marked this pull request as draft July 20, 2026 19:52
… left" success

A blocked SDK install was modeled as [ABORT], which hard-halts the run, so the
agent could bail before writing any code. Replace it with a generic, non-fatal
[MANUAL-STEP] signal: the agent finishes the code changes, the run succeeds, and
the outro shows the install as the one remaining step.

Adds the signal + collection, threads manualSteps through both harnesses, folds
it into the success outro, and removes the manual-install abort case (reverting
the now-unused function-body AbortCase).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants