Skip to content

Fix: AI Check model preference not being applied#1213

Merged
davidperezgar merged 2 commits intoWordPress:trunkfrom
raftaar1191:fix/model-preference-not-applied
Mar 13, 2026
Merged

Fix: AI Check model preference not being applied#1213
davidperezgar merged 2 commits intoWordPress:trunkfrom
raftaar1191:fix/model-preference-not-applied

Conversation

@raftaar1191
Copy link
Contributor

@raftaar1191 raftaar1191 commented Mar 12, 2026

The model preference was not being applied due to two issues:

  1. method_exists() check was failing because WP_AI_Client_Prompt_Builder
    uses magic __call() method. Changed to directly call the method with
    try-catch error handling instead.

  2. normalize_model_preference() was returning a nested array
    [['provider', 'model']] instead of the expected ['provider', 'model']
    format. Removed the extra array wrapper.

This ensures that when users specify a model preference like
'openai::gpt-5.4-pro', it is correctly passed to the WordPress AI
client instead of falling back to the default model.

Fixes #1212

Issue Video:

Recording.97.mp4

Video after adding the patch

Recording.98.mp4

@github-actions
Copy link

github-actions bot commented Mar 12, 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: raftaar1191 <raftaar1191@git.wordpress.org>
Co-authored-by: davidperezgar <davidperez@git.wordpress.org>
Co-authored-by: ernilambar <nilambar@git.wordpress.org>

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

@davidperezgar
Copy link
Member

Hello, You need to fix the tests before we can review.

@raftaar1191
Copy link
Contributor Author

On it @davidperezgar

The model preference was not being applied due to two issues:

1. method_exists() check was failing because WP_AI_Client_Prompt_Builder
   uses magic __call() method. Changed to directly call the method with
   try-catch error handling instead.

2. normalize_model_preference() was returning a nested array
   [['provider', 'model']] instead of the expected ['provider', 'model']
   format. Removed the extra array wrapper.

This ensures that when users specify a model preference like
'openai::gpt-5.4-pro', it is correctly passed to the WordPress AI
client instead of falling back to the default model.

Fixes WordPress#1212
@raftaar1191 raftaar1191 force-pushed the fix/model-preference-not-applied branch from 2ec35cc to c87de09 Compare March 12, 2026 21:48
@raftaar1191
Copy link
Contributor Author

Hey @davidperezgar, tests are all passing now — the PR is ready for review whenever you get a chance!

@davidperezgar davidperezgar merged commit 1a462c4 into WordPress:trunk Mar 13, 2026
25 checks passed
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.

Plugin Check Namer: Selected AI model is ignored — backend always uses Anthropic regardless of chosen model

3 participants