Skip to main content

AI Filters

This page documents filters for customizing the AI assistant — prompts, tools, models, and request parameters.

FilterDescription
unblock/ai/skillsAI skills configuration
unblock/ai/agentsAI agents configuration
unblock/ai/promptsSystem prompt parts before assembly
unblock/ai/toolsAI tool declarations
unblock/ai/capabilitiesAI capabilities map
unblock/ai/timeoutAI request timeout
unblock/ai/max_tokensMaximum tokens for responses
unblock/ai/model_preferenceAI model override
unblock/ai/server_tool_handler/$nameCustom server-side tool handler

ai/skills

Filter AI skills configuration.

apply_filters( 'unblock/ai/skills', array $skills );
ParameterTypeDescription
$skillsarrayRegistered skills configuration

ai/agents

Filter AI agents configuration.

apply_filters( 'unblock/ai/agents', array $agents );
ParameterTypeDescription
$agentsarrayRegistered agents configuration

ai/prompts

Filter AI system prompt parts before assembly.

apply_filters( 'unblock/ai/prompts', array $parts, string $agent );
ParameterTypeDescription
$partsstring[]Array of prompt instruction strings
$agentstringAgent 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 );
ParameterTypeDescription
$toolsarrayRegistered tool declarations

ai/capabilities

Filter the AI capabilities map (e.g., image generation support).

apply_filters( 'unblock/ai/capabilities', array $capabilities );
ParameterTypeDescription
$capabilitiesarrayCapabilities key-value map

ai/timeout

Filter the AI request timeout.

apply_filters( 'unblock/ai/timeout', int $timeout );
ParameterTypeDescription
$timeoutintTimeout in seconds. Default: 600

ai/max_tokens

Filter the maximum tokens for AI responses.

apply_filters( 'unblock/ai/max_tokens', int $max_tokens );
ParameterTypeDescription
$max_tokensintMaximum 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 );
ParameterTypeDescription
$modelstringModel 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 );
ParameterTypeDescription
$valuemixedReturn value. Default: null
$argsarrayTool call arguments
$streamStreamResponse stream instance
$indexintCurrent tool call index
$totalintTotal 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