Shuai Guo’s post on Towards Data Science lands on a conclusion I keep reaching from the WordPress side: what reliably ships is an LLM workflow, code that owns the path with the model as one node in it. You can build that in plain Python with no agent framework at all. I agree with the post, and I’d push it further for store work, because the things a framework would sell you are already running on the site.
Guo says frameworks earn their keep once you stop asking “does this work” and start asking “does this keep working in production”, and the answer runs through failure handling, observability, human-in-the-loop control, and persistence. A WooCommerce store already has a version of most of that. Action Scheduler, the job queue WooCommerce ships with, is a persistent queue with retries and an admin screen. Hooks give you the edges between steps, and post meta gives you state. The gap between a prototype and something a client runs every day is smaller here than almost anywhere else.
Where the agent-shaped fix breaks down
The request tends to arrive as “add AI to the store” and then turn into something concrete: cleaning up supplier product copy after an import, triaging reviews, drafting a follow-up for orders that shipped to the wrong address. The reflex move is an all-in-one AI plugin or a PHP wrapper around an agent library, and either way the model ends up deciding what happens next. Two things go wrong. The path disappears into the library, so when the output is bad you can’t tell which step failed. And the call usually lands in the request path, hooked onto something like save_post or a WooCommerce email. A customer or an admin waits on PHP while the API thinks, and shared hosting kills the worker long before your 60-second timeout does.
Anthropic’s building effective agents guide draws the line the same way Guo does: workflows orchestrate LLMs and tools through predefined code paths, and agents let the model direct its own process. Their advice is to start with the simplest thing that works and add complexity only when it demonstrably improves outcomes. Store tasks are mostly the deterministic kind. Fetch the product, call the model, write the fields back, branch on the result. An autonomous loop spends tokens deciding things an if statement already knows.
The LLM workflow in plain PHP
Guo’s four ingredients for an LLM workflow all have a WordPress home. Control flow is add_action plus the queue. Role instructions are your system message, one per node, saying what this node is for and what it must not do. Prompt builders are a plain function that assembles context from the store, and they matter more here than in a notebook, because the description field is where clients paste entire spec sheets and the builder is your only chance to trim it. Structured output is a JSON schema with strict set to true, which OpenAI’s docs describe as constraining generation so the response matches the schema rather than merely trying to.
The first move is getting the node off the request path. Schedule it from an import handler or wherever the new data lands:
// the group keeps these off the lane subscription renewals use
as_schedule_single_action(
time() + 120,
'bbioon_enrich_product',
[ $product_id ],
'bbioon-ai'
);The hook name is the node, the args are the payload on the edge, and the callback makes one model call and writes the result somewhere durable:
add_action( 'bbioon_enrich_product', 'bbioon_run_enrichment_step', 10, 1 );
function bbioon_run_enrichment_step( int $product_id ): void {
$product = wc_get_product( $product_id );
if ( ! $product instanceof WC_Product ) {
return;
}
$schema = [
'type' => 'object',
'additionalProperties' => false,
'required' => [ 'summary', 'tags', 'severity' ],
'properties' => [
'summary' => [ 'type' => 'string' ],
'tags' => [ 'type' => 'array', 'items' => [ 'type' => 'string' ] ],
'severity' => [ 'type' => 'string', 'enum' => [ 'low', 'medium', 'high' ] ],
],
];
$response = wp_remote_post(
'https://api.openai.com/v1/chat/completions',
[
'timeout' => 60,
'headers' => [
'Authorization' => 'Bearer ' . getenv( 'OPENAI_API_KEY' ),
'Content-Type' => 'application/json',
],
'body' => wp_json_encode(
[
'model' => 'gpt-4.1-mini',
'messages' => [
[
'role' => 'system',
'content' => 'You enrich WooCommerce product data. Use only the text provided.',
],
[
'role' => 'user',
'content' => bbioon_build_product_prompt( $product ),
],
],
'response_format' => [
'type' => 'json_schema',
'json_schema' => [
'name' => 'product_enrichment',
'strict' => true,
'schema' => $schema,
],
],
]
),
]
);
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
return; // no write, so the failed attempt stays visible on the queue
}
$body = json_decode( wp_remote_retrieve_body( $response ), true );
$fields = json_decode( $body['choices'][0]['message']['content'] ?? '', true );
if ( ! isset( $fields['severity'], $fields['summary'] ) ) {
return;
}
$product->update_meta_data( '_bbioon_enrichment', $fields );
$product->save();
}
function bbioon_build_product_prompt( WC_Product $product ): string {
return sprintf(
"Title: %s\n\nDescription:\n%s",
$product->get_name(),
wp_strip_all_tags( $product->get_description() )
);
}A few details in there are doing quiet work. The group name keeps your jobs in their own lane on the queue, so a slow enrichment batch never delays a subscription renewal. If the request fails or the body doesn’t parse, the callback returns without writing, the attempt gets marked failed, and it shows up under WooCommerce, Status, Scheduled Actions, which is a screen store owners already know. That little bbioon_build_product_prompt function is the entire prompt builder, and it’s the one place the model’s context gets decided. I’m not certain strict mode covers every edge, since a truncated response can still come back with a 200, which is why the code checks the parsed fields before trusting them. And the key comes from the environment, never the database or the repo.
This is the kind of work I take on: picking the node, writing the schema, and moving the call onto the queue so one bad API afternoon never touches checkout. If your store has an AI feature stuck in the request path, moving it is a contained job, and most of the prep is what I covered in getting client stores ready for WooCommerce AI workflows: keys in the environment, a staging run, a cap on spend.
State, traces, and the one case for an agent
Workflow state lives in post meta. Write the parsed fields, and write the trace next to them: step name, model, token counts from the response’s usage object, elapsed seconds. Guo logs exactly that into a list he calls llm_telemetry. When a client asks why last month’s enrichment cost what it did, that’s where you look. update_meta_data on the product does the same job in PHP.
The enum in the schema handles the rest. Constrained to low, medium, and high, the next node in PHP can be a switch statement, and the model can’t invent a label your switch doesn’t handle. Guo makes the same point about predefining assessment categories: closed label sets are where your domain knowledge enters the workflow, and they’re what makes chaining one node into another safe to leave running.
Guo gives two cases where an agent belongs: you genuinely don’t know how to solve the problem, or the space of possible paths is too large to enumerate by hand. Store work rarely hits either. If it does, keep the loop on the queue and give it a round cap. I wrote about what a WooCommerce data agent actually needs before, and the short version is a handful of narrow tools with typed arguments. Model the loop on the one in Guo’s post: a for loop bounded by MAX_ROUNDS, one tool call per round, evidence appended each round.
With the round count capped and every tool argument behind an enum, the worst failure you get is a failed action in a queue you already watch.