AI Filters
This page documents filters for customizing the AI assistant — prompts, tools, models, and request parameters.
| Filter | Description |
|---|---|
unblock/ai/skills | AI skills configuration |
unblock/ai/agents | AI agents configuration |
unblock/ai/prompts | System prompt parts before assembly |
unblock/ai/tools | AI tool declarations |
unblock/ai/capabilities | AI capabilities map |
unblock/ai/timeout | AI request timeout |
unblock/ai/max_tokens | Maximum tokens for responses |
unblock/ai/model_preference | AI model override |
unblock/ai/server_tool_handler/$name | Custom server-side tool handler |
ai/skills
Filter AI skills configuration.
apply_filters( 'unblock/ai/skills', array $skills );
| Parameter | Type | Description |
|---|---|---|
$skills | array | Registered skills configuration |
ai/agents
Filter AI agents configuration.
apply_filters( 'unblock/ai/agents', array $agents );
| Parameter | Type | Description |
|---|---|---|
$agents | array | Registered agents configuration |
ai/prompts
Filter AI system prompt parts before assembly.
apply_filters( 'unblock/ai/prompts', array $parts, string $agent );
| Parameter | Type | Description |
|---|---|---|
$parts | string[] | Array of prompt instruction strings |
$agent | string | Agent identifier ('builder', 'designer', 'writer', etc.) |
Example: Add Custom Instruction
add_filter( 'unblock/ai/prompts', function ( $parts, $agent ) {
$parts[] = 'Use {{ product.price | currency }} for product prices.';
return $parts;
}, 10, 2 );
Example: Agent-Specific Prompt
add_filter( 'unblock/ai/prompts', function ( $parts, $agent ) {
if ( 'writer' === $agent ) {
$parts[] = 'Always write in British English.';
}
return $parts;
}, 10, 2 );
ai/tools
Filter AI tool declarations.
apply_filters( 'unblock/ai/tools', array $tools );
| Parameter | Type | Description |
|---|---|---|
$tools | array | Registered tool declarations |
ai/capabilities
Filter the AI capabilities map (e.g., image generation support).
apply_filters( 'unblock/ai/capabilities', array $capabilities );
| Parameter | Type | Description |
|---|---|---|
$capabilities | array | Capabilities key-value map |
ai/timeout
Filter the AI request timeout.
apply_filters( 'unblock/ai/timeout', int $timeout );
| Parameter | Type | Description |
|---|---|---|
$timeout | int | Timeout in seconds. Default: 600 |
ai/max_tokens
Filter the maximum tokens for AI responses.
apply_filters( 'unblock/ai/max_tokens', int $max_tokens );
| Parameter | Type | Description |
|---|---|---|
$max_tokens | int | Maximum token count |
ai/model_preference
Filter the AI model preference. Return a model identifier to override the default.
apply_filters( 'unblock/ai/model_preference', string $model );
| Parameter | Type | Description |
|---|---|---|
$model | string | Model identifier |
ai/server_tool_handler/{$name}
Dynamic filter for custom server-side tool calls. The $name part is the tool name.
apply_filters( "unblock/ai/server_tool_handler/{$name}", null, array $args, Stream $stream, int $index, int $total );
| Parameter | Type | Description |
|---|---|---|
$value | mixed | Return value. Default: null |
$args | array | Tool call arguments |
$stream | Stream | Response stream instance |
$index | int | Current tool call index |
$total | int | Total tool calls in the request |
Common mistake
If you return null, the default handler runs. Return any non-null value to override the tool response.
Next steps
- Data filters — register custom providers and functions
- Actions — plugin lifecycle hooks