Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Builds composable LangChain and LangGraph middleware for PII redaction, caching, retries, token budgets and guardrails, with ordering rules.
Use this skill ↓59% 86%+27 ptsof test cases passed
Passed 19 of 22 test cases with the skill, and 13 of 22 without it.
Which cryptographic digest function and delimiter character does the canonical LangChain middleware pattern use for computing fast, collision-safe cache keys across prompt, tool definitions, and tenant ID?
The response selects blake2b as the hashing algorithm.
3 of 3 safety checks passed
Tenant A sends a prompt: "Summarize this support ticket from [email protected]
about her overdue invoice." The chain's caching middleware ran before the PII
redaction middleware, so the raw prompt — email and all — became part of the
cache key. Thirty seconds later Tenant B sends a semantically identical prompt
(different tenant, different customer, same shape). Cache hits. Tenant B's user
gets back a summary that names [email protected] and her overdue invoice. That is
pain-catalog entry P24 in production, and it is a real class of incident —
post-mortems read like "we added caching to cut cost, leaked a customer's PII to
a different tenant within an hour."
The sibling failure modes:
on_llm_end; the token-usage aggregator sums both; a single logical call
bills as two, tenant's per-session budget trips at 50% of true usage.Runnable.invoke does not sanitize prompt injection. A RAG document
containing "Ignore previous instructions and..." is followed verbatim.
Guardrails middleware is your injection defense; without it, indirect prompt
injection is a one-line exploit.set_llm_cache(InMemoryCache()) hashes the prompt string only.
Two chains with different tool bindings return the same cached response;
tools are silently ignored by the cache key.This skill defines the canonical middleware order for LangChain 1.0 chains and
LangGraph 1.0 agents, with an ordering-invariants matrix (every adjacent pair
has a named failure mode if you swap them), six reference implementations, a
cache-key hash that includes prompt plus bound-tools plus tenant_id, retry
telemetry that deduplicates by request_id, and an integration test pattern
that asserts the ordering invariant on every build.
Pin: langchain-core 1.0.x, langchain 1.0.x, langgraph 1.0.x. Pain-catalog
anchors: P10, P24, P25, P34, P61, with supporting references to P27, P29,
P30, P33.
Next to this one in the catalogue, plus more from the same author.