Context Governance Plugin
The Context Governance plugin of Tair Semantic Cache automatically identifies, governs, and reuses context between AI Coding Agents and models. It requires zero changes on the Agent side — as long as requests pass through the gateway, the plugin takes effect, reducing Token consumption while maintaining response quality.
The Context Governance feature is currently in invitational preview. To use this feature, submit a form to apply for access.
Overview
AI Coding Agents (such as Claude Code, Cursor, Cline, etc.) continuously push intermediate information — tool calls, code snippets, build logs, test outputs, error stacks — into the Prompt at each step. A user's question may only contain a few dozen Tokens, but the Agent's context can quickly grow to tens of thousands or even hundreds of thousands of Tokens. This not only increases costs but also dilutes key information, degrading model response quality.
The Context Governance plugin of Tair Semantic Cache is designed to solve this problem. It automatically identifies, governs, and reuses context between the Agent and the model. Zero changes are required on the Agent side — the plugin takes effect as long as requests pass through the gateway.
Integration: Zero changes on the Agent side. Cursor, Claude Code, Cline, and custom Agents that are compatible with the OpenAI API can simply point base_url to the gateway. No plugin installation or toolchain modification is required.
Core capabilities include:
-
Context type identification: Automatically distinguishes between user questions, system instructions, tool outputs, code snippets, logs, test results, diffs, error stacks, and other sources to determine which information is more valuable for the current task.
-
Context value density improvement: Performs semantic-level governance on context — preserving decision signals while weakening repetitive templates, irrelevant formatting, and low-value noise, making the context cleaner and more focused.
-
Quality gate fallback: Performs a lightweight quality assessment after each governance operation. If critical information may be lost, the original text is passed through unchanged — preferring no savings over incorrect results.
Benchmark data
Based on 123 typical AI Coding operations:
|
Metric |
Original |
With governance |
Change |
|
Avg. Prompt Tokens |
1530 |
1119 |
-27% |
|
Pass Rate |
68.3% |
69.1% |
+0.8pp |
Breaking down by context length, the benefits are more pronounced:
-
Short context (<500 tokens): Minimal processing, as it is unnecessary.
-
Medium context: Consistently saves 5%~15% Tokens with comparable response quality.
-
Large context (4K+ tokens): Average Prompt Tokens dropped from 4754 to 3098, a reduction of approximately 35%; extreme cases saved over 90% on a single request.
Getting started
-
Enable Tair Semantic Cache Gateway. See the gateway documentation for details Semantic cache instance setup.
NoteYou only need to refer to Step 2: Create a semantic cache gateway instance.
-
Enable the Context Governance plugin.
-
Go to the console, navigate to the instance list page. Make sure the region is the one where you created the instance. The instance will be in the creating state.
-
Wait about 3 minutes for the instance to be created. Click the instance ID or the Manage button on the right to enter the instance management page.
-
The instance provides internal and external HTTPS access addresses by default. To access via public network, click the Request button to enable public network access at no additional cost.
-
Go to the API Key management page from the right-side menu. You can manage multiple Keys, with a maximum of 10 Keys per instance.
-
Disabled: Disables the Key. Requests using this Key will fail.
-
Reset: Rotates the Key (equivalent to replacing the secret). Requests using the pre-rotation Key will fail.
-
Delete: Deletes the Key. Requests using this Key will fail.
-
-
Model Service: The default model service includes only some qwen family models. Other models can be enabled upon request. Each Tair Semantic Cache AI Gateway instance supports access to multiple models.
-
Click , Select Plugin Type as Context Governance, then click OK at the bottom.
-
Use the Whitelist Settings menu on the right to restrict accessible clients. The default is
127.0.0.1, which blocks all addresses. Add the client IP or IP range to allow access.
-
-
Use the Context Governance plugin.
-
The gateway supports OpenAI-compatible format. Simply replace the Base URL and API Key with the gateway address and key to connect.
curl -X POST https://<Base URL>/compatible-mode/v1/chat/completions \ -H "Authorization: Bearer <API Key>" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen3.6-plus", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is Semantic Cache?"} ] }' -
The context governance feature is automatically enabled when making requests — no manual intervention required.
-