[wp-trac] [WordPress Trac] #64865: AI Client: Add agentic loop support for auto-resolving abilities

WordPress Trac noreply at wordpress.org
Mon Mar 16 10:42:49 UTC 2026


#64865: AI Client: Add agentic loop support for auto-resolving abilities
-------------------------+----------------------------
 Reporter:  gziolo       |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Future Release
Component:  AI           |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+----------------------------
 The WP AI Client introduced in #64591 currently exposes abilities via
 `using_abilities()`, which attaches tool definitions to the prompt so the
 LLM can request function calls. However, when the model responds with a
 tool-use request, the developer is responsible for detecting it, executing
 the matching ability, feeding the result back, and re-prompting the model.
 This is a common pain point — see the recent discussion in #core-ai Slack.

 This ticket proposes adding a built-in agentic loop to the WP AI Client
 that automatically resolves ability calls using a ReAct-style (Reasoning +
 Acting) pattern.

 === Proposed API ===

 An `auto_resolve_abilities()` method (name proposed by @jason_the_adams
 [https://github.com/WordPress/wordpress-
 develop/pull/10881#issuecomment-3947473879 here]) on the WP AI Client
 that:

  1. Sends the prompt to the model with registered abilities.
  2. Inspects the response for tool-use requests.
  3. Executes the matching registered ability.
  4. Appends the tool result to the conversation and re-prompts the model.
  5. Repeats until the model produces a final answer or a maximum iteration
 limit is reached.

 Presenting the rough idea:

 {{{#!php
 $ai = wp_ai()->using_abilities( 'site_information', 'recent_posts' );

 // Current behavior — manual loop (unchanged)
 $response = $ai->prompt( 'What is this site about?' );

 // Proposed — auto-resolve loop
 $response = $ai->auto_resolve_abilities()->prompt( 'What is this site
 about?' );
 }}}

 === Design Considerations ===

  * '''Max iterations''' — A sensible default (e.g., 5) with a filter to
 override. Prevents runaway loops.
  * '''Error handling''' — What happens when an ability execution fails
 mid-loop? Options: abort with error, skip and inform the model, retry.
  * '''Streaming support''' — Should the loop support streaming
 intermediate steps, or only return the final response?
  * '''Hooks for observability''' — A filter or action between iterations
 would let developers inspect, log, or approve each step (human-in-the-
 loop).
  * '''Parallel tool calls''' — Some models return multiple tool-use
 requests in a single response. Should the client execute them in parallel?

 === Context ===

 Popular AI frameworks offer a wide spectrum of support for agentic loops —
 from minimal, loop-it-yourself approaches (similar to what the WP AI
 client provides today) to fully managed orchestration like LangChain's
 !AgentExecutor or LangGraph's state-machine-based agents where tool
 dispatch, retries, and multi-step reasoning are handled automatically. The
 goal here is to start simple and iterate — a basic sequential loop that
 covers the 80% use case, with filters for extensibility.

 === Related ===

  * [https://wordpress.slack.com/archives/C08TJ8BPULS/p1773652484432309
 Discussion] in #core-ai Slack channel
  * [https://github.com/WordPress/wordpress-
 develop/pull/10881#issuecomment-3934437267 Code review comment] when
 introducing WP AI client.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64865>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list