- Bring Your Own Key (BYOK) Multi-Provider Vault (
AiKeyVault.php): Encrypts separate API keys for OpenAI, Anthropic Claude, Google Gemini, and OpenRouter locally viaSecretBox(libsodium/ AES-256-GCM) and calls provider HTTPS endpoints directly from WordPress — zero AI keys or prompts ever touch KadiCache Cloud. - In-Chat Active Agent & Model Switcher: Switch instantly between your configured providers and live-synced
/modelsright above the chat composer without reopening settings. - Transparent Read-Only Diagnostics & Tool Traces: Auto-executes read-only tools (
get_status,diagnose_url,get_settings,get_rum_analytics,inspect_page_dom,run_pagespeed_audit,simulate_settings) one step per HTTP request with collapsible millisecond timing traces,Stopcancellation, and 1-click Copy Report. - 3-Viewport Live CSS Lab & 1-Click Rollback (
PreviewResponder.php+CustomCssStore.php): Stages non-live Custom CSS drafts, verifies Mobile (390px), Tablet (820px), and Desktop (1440px) via signed preview URLs, requires explicit admin approval before publishing, and writes an atomicMcpCheckpointssnapshot (cp_...).
Table of Contents (4 sections)
Why Performance Debugging Belongs Inside WP Admin (With Guardrails)#
Chasing down why a mobile menu broke under Delay JS, why a WooCommerce category page returned X-KadiCache: MISS, or why a hero slider shifts layout by 0.18 CLS normally requires juggling browser DevTools, server logs, cache diagnostics, and manual CSS edits across three screen sizes. Pasting raw HTML snippets into an external chat tab gives an LLM zero visibility into your live WordPress cache headers, active exclusions, or real-user RUM histograms.
KadiCache Pro AI Agent (WP Admin -> KadiCache -> AI Agent) brings a guarded, tool-enabled performance engineer directly inside your WordPress dashboard. Unlike opaque SaaS AI wrappers that mark up token costs or route your site diagnostics through third-party proxies, KadiCache AI Agent is 100% BYOK: your WordPress server speaks directly to OpenAI, Anthropic, Google Gemini, or OpenRouter using your own encrypted API key.
Multi-Provider Encrypted BYOK Vault (AiKeyVault.php & AiProviderClient.php)#
You do not have to lock your team into a single AI vendor. AiKeyVault.php stores encrypted keys per provider inside encrypted_keys_by_provider, validates key prefixes (sk-or-, sk-ant-, AIza / AQ.) to prevent pasting a key into the wrong provider card, and calls strictly allowlisted HTTPS endpoints (wp_safe_remote_post with sslverify => true and redirection => 0):
| Provider | Official HTTPS Endpoint (AiProviderClient::ENDPOINTS) | Live Model Discovery | Vision Support |
|---|---|---|---|
| OpenAI | https://api.openai.com/v1/chat/completions | /v1/models live sync | Auto + manual override |
| Anthropic Claude | https://api.anthropic.com/v1/messages | /v1/models live sync | Auto + manual override |
| Google Gemini | https://generativelanguage.googleapis.com/v1beta/models/ | /v1beta/models live sync | Auto + manual override |
| OpenRouter | https://openrouter.ai/api/v1/chat/completions | /api/v1/models live sync | Auto + manual override |
Once you save one or more provider keys in API & Models, the setup banner disappears automatically, the header switches to a green Connected badge, and the Active Agent dropdown in Chat lists only providers with verified keys so you can switch models mid-workflow.
Step-by-Step Execution, Live Tool Traces & Zero Shared-Host Timeouts#
Traditional PHP plugins that run a multi-turn LLM loop inside a single HTTP request routinely hit 30-second or 60-second Nginx/Cloudflare gateway timeouts (HTTP 502 / 504). AiAgentController::restChatStep() avoids timeouts architecturally by executing exactly one LLM turn or one tool call per REST request (MAX_STEPS_PER_PROMPT = 10), returning structured JSON error payloads instead of raw 502 responses, and supporting instant client cancellation via AbortController (Stop).
Every assistant reply surfaces a collapsible Used X tools · Y ms execution trace listing each tool name and exact latency in milliseconds alongside a 1-click Copy Report button for client tickets or agency handoffs.
Vision Screenshots, 3-Viewport CSS Drafts & Atomic 1-Click Rollback#
- In-Memory Vision Screenshots (
AiProviderClient::validateImage()): Paste (Ctrl+V) or attach a PNG, JPEG, or WebP screenshot (verified via magic bytes up to1.2 MB). Image bytes stay strictly in request memory and are never written to disk. - 3-Viewport Non-Live Draft Verification (
PreviewResponder.php): Before proposing a CSS layout fix, AI Agent stages a non-live draft viamanage_custom_css(action: "stage_draft")and runsrun_viewport_labagainst signed preview URLs at Mobile (390px), Tablet (820px), and Desktop (1440px) to check overflow, element overlaps, CLS, and console errors. - Human-Approved Mutations & Scoped Custom CSS (
CustomCssStore.php): No setting change or CSS publication executes silently. Every mutating tool renders an interactive approval card, records an atomicMcpCheckpointsrollback checkpoint (cp_...), and injects published CSS rules cleanly after Cloud Remove Unused CSS (RUCSS) inside Early Cache.
Ready to configure your keys and run your first diagnostic? Follow the illustrated AI Agent Step-by-Step Setup & Usage Guide.
Creator of KadiCache’s Early PHP Drop-In, 7-Driver Object Cache Engine, Cloud Remove Unused CSS, and Zero-CLS Lazy Render pipeline.