The plugin architecture enables third-party developers to extend agent capabilities with standardized interfaces.
5.1 Agent Plugin Base Class
abstract class WP_Agent_Plugin {
/**
* Register tools this plugin provides to agents
*/
abstract public function register_tools(): array;
/**
* Get the system prompt for this plugin's domain
*/
abstract public function get_system_prompt(): string;
/**
* Define guardrails for this plugin's actions
*/
public function get_guardrails(): array {
return [
'requires_approval' => [],
'rate_limits' => [],
'scope' => 'current_user'
];
}
/**
* Handle agent decisions in this plugin's domain
*/
public function handle_decision( WP_Agent_Decision $decision ): WP_Agent_Result;
}
5.2 Example: WooCommerce Agent Extension
/**
* Plugin Name: WooCommerce Agent Extension
* Agent Capabilities: order_management, inventory_prediction, customer_service
*/
class WC_Agent_Extension extends WP_Agent_Plugin {
public function register_tools(): array {
return [
'check_inventory' => [
'callback' => [$this, 'tool_check_inventory'],
'description' => 'Check current inventory levels for a product',
'parameters' => [
'product_id' => ['type' => 'integer', 'required' => true]
]
],
'process_refund' => [
'callback' => [$this, 'tool_process_refund'],
'description' => 'Process a refund for an order',
'parameters' => [
'order_id' => ['type' => 'integer', 'required' => true],
'amount' => ['type' => 'number', 'required' => false],
'reason' => ['type' => 'string', 'required' => true]
],
'requires_approval' => true
],
'recommend_products' => [
'callback' => [$this, 'tool_recommend_products'],
'description' => 'Get product recommendations based on criteria'
],
'track_order' => [
'callback' => [$this, 'tool_track_order'],
'description' => 'Get tracking information for an order'
]
];
}
public function get_system_prompt(): string {
return "You are a WooCommerce store assistant. Help customers track orders, process returns, find products, and answer questions.";
}
public function get_guardrails(): array {
return [
'requires_approval' => ['process_refund', 'cancel_order'],
'rate_limits' => [
'recommend_products' => '100/hour',
'process_refund' => '10/hour'
],
'scope' => 'current_user_orders'
];
}
}
5.3 Agent Capability Manifest (plugin.json)
{
"name": "WooCommerce Agent Extension",
"version": "1.0.0",
"agent": {
"version": "1.0",
"capabilities": [
"order_management",
"product_recommendation",
"customer_service"
],
"tools": [
{
"name": "check_inventory",
"description": "Check current inventory levels",
"parameters": {
"type": "object",
"properties": {
"product_id": {
"type": "integer",
"description": "The WooCommerce product ID"
}
},
"required": ["product_id"]
}
}
],
"guardrails": {
"requires_approval": ["process_refund", "cancel_order"],
"rate_limit": "100/hour",
"scope": "current_user_orders"
}
}
}
Discussion
Have thoughts on this section? Leave a comment below to join the discussion.