Tools and RAG
OAssist combines retrieval-augmented generation (RAG) over your indexed content with a tool registry that the LLM can call to take actions in your store.
Built-in tools
Registered on activation in OAssist_Activator::register_built_in_tools(). Each row in oas_tools has a JSON schema, scope (anonymous or authenticated), and handler function.
| Tool | Scope | What it does |
|---|---|---|
search_products | anonymous | Search catalog by query, category, price range, stock |
get_product | anonymous | Full details for one product by ID or slug |
check_stock | anonymous | Stock status for a product (and variation) |
get_order_status | authenticated | Look up order by number + email |
track_shipment | authenticated | Latest shipment/tracking info |
apply_coupon | anonymous | Apply a coupon to the visitor's cart |
get_loyalty_balance | authenticated | OLoyalty points + tier |
get_subscription_status | authenticated | OSubscribe active subs |
get_wishlist | authenticated | OWishlist contents |
get_booking_availability | anonymous | OBook availability check |
escalate_to_human | anonymous | Hand off to a human agent |
create_support_ticket | anonymous | Create a ticket |
log_feedback | anonymous | Log CSAT/satisfaction score |
Tool scope
- anonymous: available to all visitors.
- authenticated: requires the visitor to be a logged-in WP user, or to pass email verification for guest checkout lookups.
Disable individual tools under OAssist -> Tools without removing the row.
Adding a custom tool
phpadd_action( 'plugins_loaded', function() {
global $wpdb;
$wpdb->insert( OAssist_DB::table( 'tools' ), [
'name' => 'recommend_bundle',
'description' => 'Recommend a product bundle based on cart contents.',
'schema_json' => wp_json_encode([
'type' => 'object',
'properties' => [
'cart_items' => [ 'type' => 'array' ],
],
'required' => [ 'cart_items' ],
]),
'scope' => 'anonymous',
'handler' => 'My_Tools::recommend_bundle',
'enabled' => 1,
'built_in' => 0,
]);
});The handler must be a static method or function name that accepts a single args array and returns a JSON-serialisable response.
RAG pipeline
- Sources are chunked and embedded into
oas_chunksvia your configured embedding provider. - On each user message, OAssist embeds the query and retrieves top-K relevant chunks via cosine similarity.
- Retrieved chunks are injected into the prompt as context.
- Citations are stored per message in
oas_messages.citationsso the admin inbox can show which sources backed each response.
Reindexing runs daily via oassist_cron_reindex. Trigger manually via Knowledge tab -> Reindex All.

