agent skills

Redis Semantic Cache (LangCache)

Redis's redis-semantic-cache skill from redis/agent-skills — cache-aside pattern for LLM responses on Redis Cloud LangCache. Calls search/set via SDK or REST, tunes the similarity threshold (0.95+ strict / 0.9 default / 0.8 loose), splits one app's LLM workloads into separate caches per task type, and filters with custom attributes. Use when wrapping an LLM call (OpenAI, Anthropic) to cut cost and
by Redis, Inc. updated Sep 10, 2026 MIT
install via your agent of choice
❯ npx skills add redis/agent-skills (interactive picker chooses redis-semantic-cache). Manual: git clone https://github.com/redis/agent-skills && cp -r redis-development/skills/redis-semantic-cache your-project/.claude/skills/. Plugin-packaged version also lives under plugins/redis-development/ with manifests for Claude Code (.claude-plugin), Cursor (.cursor-plugin), and ChatGPT/Codex (.codex-plugin).

## what it does

tl;dr: the only one of the eight Redis skills that is specifically an LLM cache, and the most thematic hit on this shelf given the site name. LangCache lives on Redis Cloud (preview), stores prompts as embeddings, returns a cached answer when the new prompt is semantically close. The skill encodes the cache-aside flow, three threshold bands, and the one rule that breaks more demos than anything else — never share one cache across two different task types.

What it actually does

Fetched SKILL.md (~4.4 KB) runs three sections plus a references link, all instruction-only markdown — no executable scripts.

1. The cache-aside flow. Standard pattern in front of any LLM call.

from langcache import LangCache
import os

lang_cache = LangCache(
    server_url=f"https://{os.getenv('HOST')}",
    cache_id=os.getenv("CACHE_ID"),
    api_key=os.getenv("API_KEY"),
)

result = lang_cache.search(prompt="What is Redis?", similarity_threshold=0.9)
if result:
    response = result[0]["response"]
else:
    response = llm.generate("What is Redis?")
    lang_cache.set(prompt="What is Redis?", response=response)

The same search and set operations are exposed via REST (POST /v1/caches/{cacheId}/entries/search and POST /v1/caches/{cacheId}/entries) when the SDK doesn’t fit. Full SDK + REST samples and attribute-based storage live in references/langcache-usage.md.

2. Tune the similarity threshold. Threshold = how close (cosine distance in embedding space) a new prompt must be to count as a hit. Three bands from the skill:

ThresholdBehaviorUse when
0.95+Near-exact requiredCustomer-facing answers where wrong responses are costly
0.9Balanced defaultMost workloads — start here
0.8Loose matchInternal tools, exploratory queries, FAQ deduplication

Adjust by watching the actual hit rate and spot-checking that returned answers are still relevant. Full table and tuning playbook: references/best-practices.md.

3. Separate caches per task type. The rule that breaks demos: a “code question” prompt is semantically close to other code questions but has nothing to do with a password-reset support query. Sharing one cache across them returns garbage. The skill’s recommended shape:

support_cache = LangCache(server_url=..., cache_id="support-cache-id", api_key=...)
code_cache    = LangCache(server_url=..., cache_id="code-cache-id",    api_key=...)

Create distinct cache IDs in Redis Cloud per task, route each call to the right one. Finer-grained alternative when the same prompt format spans subtopics: store and search with custom attributes (e.g. {"category": "database"}) to keep tasks in the same cache but isolated by attribute filter.

Install

# Wizard — installs the bundle, then pick redis-semantic-cache
npx skills add redis/agent-skills

# Manual — clone the repo and copy the single skill folder
git clone https://github.com/redis/agent-skills
cp -r redis/agent-skills/skills/redis-semantic-cache \
  your-project/.claude/skills/

The same repo ships plugin manifests for three hosts:

  • Claude Code — .claude-plugin/marketplace.json and a per-skill .claude-plugin/plugin.json under each skill.
  • Cursor — .cursor-plugin/marketplace.json and matching plugin.json.
  • ChatGPT / Codex — .codex-plugin/plugin.json with real (non-symlinked) copies of every skill under plugins/redis-development/, since plugin flows can drop symlinks. Regenerate with npm run sync:plugins; pre-commit hook keeps them in sync.

Requires Node + npx on PATH for the wizard. Manual install needs the same Git / filesystem access as any other skills-folder drop.

Gotchas

  • LangCache is preview. The SKILL.md header says so explicitly: “LangCache is currently in preview on Redis Cloud. Features and behavior may change.” Pricing and SLAs are not in the README — confirm on Redis Cloud before production.
  • One cache per task type — non-negotiable. Sharing across two task types is the silent failure mode the skill hammers on. If the demo answers look wrong, that’s the first place to look, not the threshold.
  • Threshold is a knob, not a default. Start at 0.9 per the skill, then watch hit rate and spot-check returned answers. Lower threshold = more hits, more off-topic answers. There is no auto-tune in the skill.
  • Custom attributes ≠ magic isolation. Custom attributes filter within one cache. They do not turn one cache into many. Use distinct cache IDs when the workloads are genuinely different.
  • SDK vs REST parity. The README points to references/langcache-usage.md for REST when the SDK doesn’t fit — but the threshold tuning and per-task cache rule apply the same way regardless of transport. Don’t let a REST switch become a silent regression.
  • Three env vars, no defaults. HOST, CACHE_ID, API_KEY are all required. The Python sample uses os.getenv(...) directly — if any one is unset the call will fail at runtime, not at load.
  • sandbox_test untested. We read SKILL.md and the README this session. We did not call LangCache end-to-end from a sandbox.
  • Static scan verdict: allow. No BLOCK patterns (curl|sh, subprocess, id_rsa, secret env names, install hooks, C2-style hosts). No REVIEW patterns either (all URLs are redis.io/docs or github.com). The skill is instructions + Python samples — no executable scripts.
  • Redis Core (redis/agent-skills) — same bundle, the data-type-and-key-naming skill that precedes this one in any realistic Redis modeling job.
  • Redis Search (redis/agent-skills) — same bundle, FT.SEARCH / vector / RAG retrieval; what you build the cache in front of when the answer requires a fresh retrieval each call.
  • Redis Observability (redis/agent-skills) — same bundle, INFO / SLOWLOG / FT.PROFILE; the skill you pair with this one to see if the cache is actually hitting at the rate the threshold implies.
  • Find Skills (vercel-labs/skills) — meta-skill for the discovery CLI that found this one; routes “how do I cache LLM responses” to the right skill instead of guessing.

## compatibility

claude-code ✓
cursor ✓
cline
aider
github-copilot ✓

## embed this badge

cache ✓ in cache.directory
![cached](https://cache.directory/badge/redis-semantic-cache.svg)