Repository navigation
Feature : Site Agent Experiment - #1214
Vrishabhsk wants to merge 1 commit into
Conversation
Adds a conversational assistant under Tools that reads site information and proposes site changes. Actions are ordinary WordPress Abilities, so each keeps its own schema, permission callback, validation, and execution hook. The agent adds a reviewed allowlist, a propose-then-approve boundary for writes, and an audit trail. Write proposals are user-scoped, conversation-bound, single-use, and expire after 30 minutes. The experiment and its write gate are disabled by default. See WordPress#189.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @Vrishabhsk. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #1214 +/- ##
=============================================
- Coverage 84.26% 82.48% -1.78%
- Complexity 3723 4084 +361
=============================================
Files 148 164 +16
Lines 14099 15493 +1394
=============================================
+ Hits 11881 12780 +899
- Misses 2218 2713 +495
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What?
Closes #189
Adds an opt-in Site Agent experiment under Tools → Site Agent that maps natural-language requests to reviewed WordPress Abilities, with approval-gated writes and an audit trail.
Why?
Issue #189 asks for a conversational admin agent that can perform WordPress actions with strong security, permissions, and auditability from the start, and that is opt-in and disabled by default.
This PR takes an abilities-first approach. Instead of describing every action twice (once as a REST resource table, once as a custom action class), the agent uses ordinary WordPress Abilities as the action layer. Each action keeps its own input schema, permission callback, validation, and execution hook. The agent adds only three things:
This keeps the implementation substantially smaller than the earlier draft while preserving the security properties in the issue.
How?
Experiment and gates
Site_Agentregisters the screen, REST routes, abilities, and audit listener only when the experiment is enabled.false.manage_optionsby default; sites can narrow or lower this withwpai_site_agent_capability.Abilities as actions
ai/site-agent-read-siteai/site-agent-create-draftedit_posts/edit_pagesai/site-agent-update-postedit_postai/site-agent-update-settingmanage_optionsRead sections use their own capability (
manage_options,edit_posts,edit_pages,activate_plugins) and filter object reads throughread_post. The settings section never exposes URLs, email addresses, roles, or arbitrary options.Proposal and approval flow
readonly => trueruns immediately.check_permissions()with the stored arguments.$ability->execute( $stored_args )as the current user. WordPress validates the input, sanitizes it, checks permissions again, and fires its hooks.Proposals are single-use and expire after 30 minutes. Conversations expire after two hours.
Audit
wp_after_execute_ability.site_agentlog type, with the ability name as the operation and the phase in context.wpai_site_agent_action.UI
What is intentionally not included
Use of AI Tools
AI assistance: Yes
Tool(s): Ollama
Model(s): Deepseek-v4.1-flash:cloud
Used for: Initial implementation, the refactor to the abilities-first design, tests, documentation, and manual verification. The final code, tests, and security behaviour were reviewed and edited by the author.
Testing Instructions
Automated
Run the Site Agent e2e spec with the AI plugin active in the wp-env test site:
Validated locally:
1937 tests, 5537 assertions, 42 skipped.35 testsacross the abilities, agent loop, and experiment/gates.phpcsandphpstanclean for the new backend code.Manual
ai/site-agent-read-site.blogdescriptionand the exact new value. Approve and verify under Settings → General.site_agent, and confirm proposal/execute/approval/decline rows exist without content or secret values.I also tested the above end-to-end on a real WordPress 7.1.3 site with a Google connector, including the read, proposal, approve, decline, settings update, and audit paths.
Screenshots or screencast
Changelog Entry