Skip to content

WP 7.0: Move away from directly using the AI_Client#275

Merged
dkotter merged 10 commits intoWordPress:developfrom
dkotter:update/core-ai-client
Mar 7, 2026
Merged

WP 7.0: Move away from directly using the AI_Client#275
dkotter merged 10 commits intoWordPress:developfrom
dkotter:update/core-ai-client

Conversation

@dkotter
Copy link
Collaborator

@dkotter dkotter commented Mar 6, 2026

What?

Partially closes #244

Move away from using the AI_Client directly and instead use the new wp_ai_client_prompt function. Also update to use the new Connectors screen instead of the AI Credentials screen. And finally address a few fixes that cropped up now that the OpenAI provider is using the Responses API.

Why?

In the next release, WP 7.0 will be our minimum and as such, we want to rely on the AI Client that is in core instead of bundling that ourselves. This is the final step in a 3-part process to get everything working. Anywhere we were relying on the old approach (AI_Client, AI Credentials screen, built-in providers), as now been updated.

How?

  • Update anywhere we were referencing the AI Credentials screen to point to the new Connectors screen
  • Ensure our API validation check uses the new keys stored as Connectors
  • Switch to using wp_ai_client_prompt instead of using AI_Client directly
  • Run all of our tests on trunk only for now as they'll fail on 6.9
  • Update the JSON schema for the Review Notes Experiment to work with the Responses API

Use of AI Tools

All initial work was done by me with AI helping debug and fix failing tests

Testing Instructions

  1. Install WP 7.0-beta3
  2. Install the plugin from this branch, ensuring you're building assets (npm i && npm run build && composer i)
  3. Verify you see a new Connectors setting under Tools
  4. Install a Connector and add a valid API key
  5. Ensure you don't get an error message on the AI Experiments settings page
  6. Turn on one or more Experiments and ensure those still work

Note

Plugin Check is still failing but that's due to an upstream issue that should be resolved in their next release.

Open WordPress Playground Preview

dkotter added 7 commits March 5, 2026 15:42
…. Start updating our tests to account for this. Install the OpenAI Provider plugin in our test environment
…trunk for now, otherwise those fail. Will change this once 7.0 is released
…ponses API. Update E2E tests to account for the new output format
@dkotter dkotter added this to the 0.5.0 milestone Mar 6, 2026
@dkotter dkotter self-assigned this Mar 6, 2026
@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 36.36364% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.72%. Comparing base (9db302e) to head (19e1327).
⚠️ Report is 31 commits behind head on develop.

Files with missing lines Patch % Lines
includes/helpers.php 0.00% 13 Missing ⚠️
includes/Settings/Settings_Page.php 0.00% 4 Missing ⚠️
includes/bootstrap.php 0.00% 4 Missing ⚠️
...bilities/Excerpt_Generation/Excerpt_Generation.php 0.00% 1 Missing ⚠️
includes/Abilities/Image/Alt_Text_Generation.php 0.00% 1 Missing ⚠️
includes/Abilities/Image/Generate_Image.php 0.00% 1 Missing ⚠️
includes/Abilities/Image/Generate_Image_Prompt.php 0.00% 1 Missing ⚠️
includes/Abilities/Review_Notes/Review_Notes.php 93.33% 1 Missing ⚠️
includes/Abilities/Summarization/Summarization.php 0.00% 1 Missing ⚠️
...es/Abilities/Title_Generation/Title_Generation.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #275      +/-   ##
=============================================
+ Coverage      57.68%   57.72%   +0.03%     
  Complexity       567      567              
=============================================
  Files             35       36       +1     
  Lines           2933     2933              
=============================================
+ Hits            1692     1693       +1     
+ Misses          1241     1240       -1     
Flag Coverage Δ
unit 57.72% <36.36%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jeffpaul jeffpaul modified the milestones: 0.4.1, 0.5.0 Mar 6, 2026
@dkotter dkotter marked this pull request as ready for review March 6, 2026 19:05
@github-actions
Copy link

github-actions bot commented Mar 6, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: Jameswlepage <isotropic@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@dkotter dkotter requested review from felixarntz and jeffpaul March 6, 2026 19:13
Copy link
Member

@jeffpaul jeffpaul left a comment

Choose a reason for hiding this comment

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

Looks good to me, but I defer to @felixarntz for any code review concerns (though also fine to merge in to continue with work building towards 7.0 and we can always come back to iterate in another PR if needed)

@dkotter dkotter merged commit 9e88ddc into WordPress:develop Mar 7, 2026
18 of 33 checks passed
@dkotter dkotter deleted the update/core-ai-client branch March 7, 2026 04:50
@raftaar1191
Copy link

Additional Fix: Resolves Fatal Error with WordPress 6.9+

This PR also resolves a critical fatal error that was occurring in v0.4.1 when the plugin was activated with WordPress 6.9+:

Fatal error: Call to undefined method WordPress\AiClient\Providers\DTO\ProviderMetadata::getAuthenticationMethod() 
in /wp-includes/connectors.php:164

Root Cause: The bundled php-ai-client v0.3.1 (via wp-ai-client ^0.2.0) was missing the getAuthenticationMethod() method that WordPress core's connectors.php was calling.

Resolution: By removing the bundled dependencies and moving to use WordPress core's AI Client, this PR eliminates the version conflict entirely.

Issue: #285
Impact: Critical - caused complete site failure for users on WP 6.9+ with v0.4.1

Great work on this refactor - it solves both the architectural goal AND a blocking compatibility issue! 🎉

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.

Pathway to 7.0

4 participants