Summary
A wp-codebox.agent-sandbox-run step fails with:
AgentRuntimeError: The canonical agents/chat ability is not available inside the sandbox.
This is reproducible (2/2 clean runs) when the runtime is composed with a current Data Machine that vendors its own copy of agents-api. The agent never starts because wp_get_ability('agents/chat') returns null inside the sandbox-run eval.
Root cause
The generated sandbox PHP (packages/cli/src/agent-code.ts) loads agents-api as a standalone runtime plugin before Data Machine:
$plugins = array_merge(array(
'agents-api/agents-api.php', // standalone mount, loaded first
'data-machine/data-machine.php',
'data-machine-code/data-machine-code.php',
), ...);
Data Machine then requires its own vendored agents-api in data-machine.php:
require_once __DIR__ . '/vendor/wordpress/agents-api/agents-api.php';
agents-api guards against double-load:
if ( defined( 'AGENTS_API_LOADED' ) ) { return; }
define( 'AGENTS_API_LOADED', true );
So the standalone-mounted copy wins and Data Machine's vendored load is skipped. In the standalone-mounted path, agents/chat does not end up registered by the time the sandbox fires wp_abilities_api_init and calls wp_get_ability('agents/chat').
Evidence that agents-api itself is fine
Loaded the normal way — via Data Machine's vendored copy (data-machine/vendor/wordpress/agents-api/) — agents/chat registers and is executable. Confirmed with a WordPress PHPUnit test:
AGENTS_API_PATH=/wordpress/wp-content/plugins/data-machine/vendor/wordpress/agents-api/
agents/chat registered: yes, executable: yes
So this is a composition/load-order problem in the sandbox boot, not an agents-api bug.
Proposed fix
Do not mount/require agents-api as a separate runtime plugin when Data Machine already vendors it. Let Data Machine load its own vendored agents-api (the version it was built against), avoiding the double-load guard and version skew. Remove agents-api/agents-api.php from the standalone $plugins list and rely on data-machine.php's require_once .../vendor/wordpress/agents-api/agents-api.php.
This also fixes a latent version-skew risk: the standalone mount can be a different agents-api version than the one Data Machine vendors and expects.
Impact
This blocks WP Codebox coding agents end to end: the agent can't start, so no tool resolution or file edits happen. Related work that depends on this:
Context
Found while landing the WP Codebox Claude Code coding-agent path. The tool-resolution chain (sandbox tool policy → ability projection → ToolPolicyResolver → provider) is proven correct in isolation; this agents-api double-load is the remaining end-to-end blocker.
Summary
A
wp-codebox.agent-sandbox-runstep fails with:This is reproducible (2/2 clean runs) when the runtime is composed with a current Data Machine that vendors its own copy of agents-api. The agent never starts because
wp_get_ability('agents/chat')returns null inside the sandbox-run eval.Root cause
The generated sandbox PHP (
packages/cli/src/agent-code.ts) loads agents-api as a standalone runtime plugin before Data Machine:Data Machine then requires its own vendored agents-api in
data-machine.php:agents-api guards against double-load:
So the standalone-mounted copy wins and Data Machine's vendored load is skipped. In the standalone-mounted path,
agents/chatdoes not end up registered by the time the sandbox fireswp_abilities_api_initand callswp_get_ability('agents/chat').Evidence that agents-api itself is fine
Loaded the normal way — via Data Machine's vendored copy (
data-machine/vendor/wordpress/agents-api/) —agents/chatregisters and is executable. Confirmed with a WordPress PHPUnit test:So this is a composition/load-order problem in the sandbox boot, not an agents-api bug.
Proposed fix
Do not mount/require agents-api as a separate runtime plugin when Data Machine already vendors it. Let Data Machine load its own vendored agents-api (the version it was built against), avoiding the double-load guard and version skew. Remove
agents-api/agents-api.phpfrom the standalone$pluginslist and rely ondata-machine.php'srequire_once .../vendor/wordpress/agents-api/agents-api.php.This also fixes a latent version-skew risk: the standalone mount can be a different agents-api version than the one Data Machine vendors and expects.
Impact
This blocks WP Codebox coding agents end to end: the agent can't start, so no tool resolution or file edits happen. Related work that depends on this:
Context
Found while landing the WP Codebox Claude Code coding-agent path. The tool-resolution chain (sandbox tool policy → ability projection → ToolPolicyResolver → provider) is proven correct in isolation; this agents-api double-load is the remaining end-to-end blocker.