AI: defer WordPress.com plan capability checks to plan.features.active#3331
AI: defer WordPress.com plan capability checks to plan.features.active#3331lezama wants to merge 3 commits into
Conversation
11d52a1 to
c800e59
Compare
c800e59 to
c5ac208
Compare
Why do we need to add this to the "local system prompt"? |
I'd love to avoid this kind of specifics in the system prompt. if we can do without this kind of things it's better as otherwise we'll have to do it for all core features. |
…-out Address review feedback on the WP.com plan capabilities block: - Local Studio sites have no plan concept, so the WPCOM_PLAN_CAPABILITIES block is irrelevant noise there; render it only in the remote prompt. - Remove the custom-post-type-specific paragraph. The general rule (defer to plan.features.active) is enough; per-feature carve-outs would have to be repeated for every other core feature and invite the same drift the rest of this change is trying to prevent. - Update tests: assert the plan guidance appears only in remote mode, and keep the regression guard against the deleted tier table for both modes.
c5ac208 to
8144a4c
Compare
|
Both fair, addressed in 8144a4c:
|
…ypass
Previous commit on this branch let `plan.features.active` survive
stripOversizedFields, which meant every `GET /` tool response (the agent
is required to call this first) carried an extra payload alongside the
actual site fields — and risked re-introducing the 60K bloat the strip
exists to prevent.
Switch to a one-shot prefetch:
- `getWpComSitePlanFeatures(token, siteId)` calls `/sites/{id}?fields=plan`
once and returns the active feature slugs. Errors are swallowed — a
broken feature lookup shouldn't block the agent.
- `runCommand` populates `ui.activeSite.planFeaturesActive` on the first
remote turn. The cache rides the `SiteInfo` so subsequent turns reuse
it without another roundtrip.
- The system prompt's remote intro now lists the active features inline
(or falls back to "ask the user" when the prefetch returned nothing),
and both the workflow step and `WPCOM_PLAN_CAPABILITIES` block point
the agent at the prefetched list rather than telling it to call `GET /`
to consult features.
- Revert `wpcom-tools.ts` to drop `plan.features` entirely from tool
output, restoring the original bloat-prevention behaviour.
Tests cover both the prefetched and unprefetched render paths.
|
Follow-up: per-request strip-bypass replaced with a one-shot prefetch in f470276. The previous "preserve New shape:
Tradeoffs: one extra request at agent start; list goes stale if the user upgrades mid-session (rare — they can re-pick the site to refresh). Net: tool output stays minimal and the agent never has to make a tool call to reason about features. |
Related
A user on the Premium plan asked Studio Code (in remote-session mode) whether they needed to upgrade to push a plugin that registers a custom post type. The agent replied that "custom post types like the zine CPT also require Business", conflating CPTs (a core WordPress feature) with the custom-plugin-upload capability and confidently restating WP.com plan-tier rules from training data.
A first attempt at this PR replaced the prompt's tier description with a more detailed tier table — but Tess pointed out that table was also wrong (Personal and Premium do support plugin install, the top tier is "Commerce" not "eCommerce", etc.). Plan tiers and feature gating change frequently enough that any hardcoded summary in the prompt is going to drift. So this PR pivots: instead of putting any prescriptive tier copy in the prompt, point the agent at
plan.features.active(the per-site authoritative feature list the WP.com/sites/{id}endpoint already returns).Proposed Changes
WPCOM_PLAN_CAPABILITIESblock to both the local and remote system prompts. It explicitly tells the agent not to assert what specific tier names support, and instructs it to consultplan.features.active(or ask the user) instead.IMPORTANT: Before doing ANY work…and## Workflowinstructions in the remote prompt so they no longer mandateplan.product_slug-based feature gating;plan.is_freeis the only fixed plan-level rule (the free-plan refusal), everything else defers toplan.features.active.REMOTE_DESIGN_GUIDELINESto just the action rules and the free-plan refusal — the inaccurate(Personal, Premium, Business, eCommerce) — progressively more controlline is removed.apps/cli/ai/wpcom-tools.tsstripOversizedFields: it was strippingplan.featuresentirely (because the old prompt hardcoded tier behaviour), which would silently makeplan.features.activeunreachable for the agent. Nowfeatures.activeis preserved (small array of slugs) and only the bulkyfeatures.availableand other sub-fields are dropped.apps/cli/ai/tests/system-prompt.test.tscovering both prompt modes, asserting the newplan.features.activeinstruction is present, the CPT-not-plan-gated clause is present, and the previously-deleted(Personal, Premium, Business, …)tier table cannot be reintroduced silently.What this leaves for follow-up
Tess and
@alexapeduzziplan to do a wholesale review of how the agent talks about WP.com plans. This PR intentionally scopes itself to removing wrong content and pointing at the right data source; it doesn't introduce any new prescriptive copy about specific plans. Any richer guidance (a curatedplan.features.activeslug glossary, dynamically-fetched plan info, etc.) is a follow-up.Testing Instructions
npm test -- apps/cli/ai/tests/system-prompt.test.ts— 6 assertions, all green.npm test -- apps/cli/ai/tests/— full AI test suite (112 tests) passes.npm run typecheck --workspace apps/cli— passes.studio ai, ask"I'm on the Premium plan on WordPress.com — can I use a custom post type?". The agent should redirect toplan.features.active/ the install-plugins capability question, not assert that any particular tier is required.Pre-merge Checklist