Skip to content

Add is_supported_* checks for better error handling#362

Merged
dkotter merged 17 commits intoWordPress:developfrom
dkotter:fix/is-supported-checks
Apr 9, 2026
Merged

Add is_supported_* checks for better error handling#362
dkotter merged 17 commits intoWordPress:developfrom
dkotter:fix/is-supported-checks

Conversation

@dkotter
Copy link
Copy Markdown
Collaborator

@dkotter dkotter commented Apr 1, 2026

What?

Use the AI Clients built-in is_supported_* checks to show better errors when a connected provider isn't supported. Follow up to #332

Why?

Right now if you try and use a provider for something it doesn't support, this is caught and an error message is shown. But this error message isn't super helpful.

It's also best practice to utilize the AI Client's built-in is_supported_* checks which also allows us to output more specific error messages.

How?

Updates all of our AI Abilities to use the proper is_supported_* method and return an error if the prompt isn't supported.

Adds a new get_prompt_builder method to all of those Abilities to handle this, making it easier to abstract out the building of the prompt builder.

Fixes a bug where errors weren't showing when they occurred during generation of review notes. Also removed an extra "Error" text when an error happened during title generation.

Use of AI Tools

None

Testing Instructions

  1. Pull down this PR
  2. Turn on all Experiments that utilize AI
  3. Don't connect any AI Provider
  4. Test each Experiment and verify you get an error message with a specific error
  5. Connect an AI Provider and test again ensuring everything works
Open WordPress Playground Preview

dkotter added 8 commits April 1, 2026 13:55
…ethod and within it, check if we have a model that supports that prompt. If not, return a more specific error message
…method and within it, check if we have a model that supports that prompt. If not, return a more specific error message
…der method and within it, check if we have a model that supports that prompt. If not, return a more specific error message
…der method and within it, check if we have a model that supports that prompt. If not, return a more specific error message
… and within it, check if we have a model that supports that prompt. If not, return a more specific error message
…hod and within it, check if we have a model that supports that prompt. If not, return a more specific error message
@dkotter dkotter added this to the 0.7.0 milestone Apr 1, 2026
@dkotter dkotter self-assigned this Apr 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 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: TylerB24890 <tyb@git.wordpress.org>

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

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 19.54023% with 70 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.25%. Comparing base (aa6409b) to head (dd2f937).
⚠️ Report is 22 commits behind head on develop.

Files with missing lines Patch % Lines
includes/Abilities/Image/Alt_Text_Generation.php 0.00% 13 Missing ⚠️
includes/Abilities/Review_Notes/Review_Notes.php 0.00% 12 Missing ⚠️
...bilities/Excerpt_Generation/Excerpt_Generation.php 0.00% 10 Missing ⚠️
includes/Abilities/Image/Generate_Image_Prompt.php 0.00% 10 Missing ⚠️
includes/Abilities/Summarization/Summarization.php 0.00% 10 Missing ⚠️
...es/Abilities/Title_Generation/Title_Generation.php 0.00% 10 Missing ⚠️
includes/Abilities/Image/Generate_Image.php 0.00% 4 Missing ⚠️
.../Content_Classification/Content_Classification.php 90.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #362      +/-   ##
=============================================
- Coverage      63.81%   63.25%   -0.57%     
- Complexity       684      697      +13     
=============================================
  Files             49       49              
  Lines           3529     3573      +44     
=============================================
+ Hits            2252     2260       +8     
- Misses          1277     1313      +36     
Flag Coverage Δ
unit 63.25% <19.54%> (-0.57%) ⬇️

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.

@dkotter dkotter requested a review from jeffpaul April 1, 2026 20:45
jeffpaul
jeffpaul previously approved these changes Apr 6, 2026
@jeffpaul jeffpaul requested a review from TylerB24890 April 8, 2026 19:44
@jeffpaul jeffpaul mentioned this pull request Apr 8, 2026
31 tasks
Copy link
Copy Markdown
Contributor

@TylerB24890 TylerB24890 left a comment

Choose a reason for hiding this comment

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

All looks good to me.
Could we apply the same ensure_text_generation_supported() approach to the Content_Classification ability? Happy to open a separate PR for that if you'd like, or apply it to this one.

Edit: Disregard the Content_Classification note. I'll apply it in #240 after this is merged in.

@dkotter
Copy link
Copy Markdown
Collaborator Author

dkotter commented Apr 9, 2026

All looks good to me. Could we apply the same ensure_text_generation_supported() approach to the Content_Classification ability? Happy to open a separate PR for that if you'd like, or apply it to this one.

Edit: Disregard the Content_Classification note. I'll apply it in #240 after this is merged in.

Sorry, didn't see your edit until I had already pushed up change so this is done now in dd2f937

@dkotter dkotter merged commit d9e09f4 into WordPress:develop Apr 9, 2026
15 of 17 checks passed
@github-project-automation github-project-automation bot moved this from Needs review to Done in WordPress AI Planning & Roadmap Apr 9, 2026
@dkotter dkotter deleted the fix/is-supported-checks branch April 9, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants