[wp-trac] [WordPress Trac] #65094: AI: Prompt construction fails with fatal error when wp_ai_client_default_request_timeout filter returns negative number

WordPress Trac noreply at wordpress.org
Sun Apr 26 22:49:38 UTC 2026


#65094: AI: Prompt construction fails with fatal error when
wp_ai_client_default_request_timeout filter returns negative number
-------------------------------------------------+-------------------------
 Reporter:  westonruter                          |       Owner:
                                                 |  westonruter
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  7.0
Component:  AI                                   |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests commit      |     Focuses:
  dev-feedback                                   |
-------------------------------------------------+-------------------------

Comment (by westonruter):

 Here's a quick way to test this.

 Add a this as a `try-wp-ai-client-negative-default-request-timeout.php`
 file to the root of a WP install:

 {{{#!php
 <?php

 add_filter(
         'wp_ai_client_default_request_timeout',
         static function () {
                 return -1;
         }
 );

 echo wp_ai_client_prompt( 'When is Christmas?' )->generate_text();

 }}}

 Then invoke with WP-CLI:

 {{{
 npm run env:cli -- eval-file try-wp-ai-client-negative-default-request-
 timeout.php
 }}}

 Before:

 > Fatal error: Uncaught
 WordPress\AiClient\Common\Exception\InvalidArgumentException: Request
 option "timeout" must be greater than or equal to 0. in /var/www/src/wp-
 includes/php-ai-client/src/Providers/Http/DTO/RequestOptions.php:201

 After:

 > Notice: Function `WP_AI_Client_Prompt_Builder::__construct` was called
 '''incorrectly'''. The `wp_ai_client_default_request_timeout` filter must
 return a non-negative number. Please see [https://developer.wordpress.org
 /advanced-administration/debug/debug-wordpress/ Debugging in WordPress]
 for more information. (This message was added in version 7.0.0.) in
 /var/www/src/wp-includes/functions.php on line 6173
 > Christmas is celebrated on **December 25th** each year.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/65094#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list