answer-cache
Agent protocol for mycortex answer cache — inserts a cache-check step between RAG miss and model call. Saves tokens by caching LLM answers with quality gating, semantic dedup, and RLS isolation per profile.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 4
- Forks
- 1
01 前言 Front Matter
- name
- answer-cache
- author
- Steadfaste Fleet
- license
- MIT
- version
- 1.0.0
- category
- devops
- platforms
- [ "linux", "macos" ]
- description
- Agent protocol for mycortex answer cache — inserts a cache-check step between RAG miss and model call. Saves tokens by caching LLM answers with quality gating, semantic dedup, and RLS isolation per profile.
03 SKILL.md 正文
Answer Cache — Agent Protocol
Purpose
When mycortex (search) misses and the model answers from training data, that
answer is ephemeral. Next session pays the same token cost. This skill inserts
a cache-check step between RAG miss and model call, so repeated queries hit
the local answer cache for 0 tokens.
Core Flow
Query -> mycortex search (hit? use it, 0 tokens)
-> miss? mycortex answer search (hit? use it, 0 tokens)
-> miss? model answers (costs tokens)
-> quality gate passes? mycortex answer store -> future hits local
CLI Commands
All via the mycortex CLI (~/.steadfaste-fleet/scripts/mycortex):
Store an answer
mycortex answer store "<query>" "<answer>" \
--confidence high|medium|low \
--model deepseek/deepseek-v4-flash \
--tokens 512 \
--source-scope federated|source_name
- Quality gates auto-skip: time-sensitive queries, refusals, PII
- Use
--forceto bypass quality gates - Use
--updateto overwrite an existing entry for the same query - Semantic dedup checks before insert (trigram similarity > 0.6)
Search cached answers
mycortex answer search "<query>" [--limit 10] [--min-score 0.0] [--json]
- Returns exact matches first, then trigram similarity matches
--min-score 0.5filters low-confidence semantic matches--jsonfor machine-readable output
View statistics
mycortex answer stats [--json]
Prune stale entries
mycortex answer prune [--days 90] [--min-access 0] [--dry-run]
Agent Protocol
Step 1: Search mycortex (existing RAG)
result = terminal("mycortex search '<query>' --limit 5 --json")
Step 2: On miss, check the answer cache
result = terminal("mycortex answer search '<query>' --limit 3 --min-score 0.5 --json")
Step 3: Model fallback + auto-store
# Only if both searches yield nothing useful
# After getting the model's answer:
terminal("mycortex answer store '<query>' '<answer>' --confidence medium --tokens <N>")
Step 4: Verify the cached answer is used on repeat
result = terminal("mycortex answer search '<query>' --json")
# -> returns the stored answer with 0 token cost
Quality Gate Rules
| Gate | What it prevents | Bypass |
|---|---|---|
| Time-sensitive | "current weather", "latest news" — content becomes stale | --force |
| Refusal | LLM "I cannot help" patterns — don't cache dead ends | --force |
| PII | Emails, phones, IPs in answers — never cache | --force |
| Semantic dedup | Similar query, same answer — don't duplicate | --force |
Source Scope
federated(default) — visible to ALL agents (like federated brain sources)<source_name>— visible only to agents with a grant for that source (matches the RLS model:mycortex.source_grantscontrols per-role visibility)
RLS Isolation
The same per-profile isolation model applies: each Hermes profile connects as
mycortex_reader_<profile> and sees only answers whose source_scope is
federated OR whose scope matches a source the profile has a grant for.
Pruning
The existing agent-mycortex-retention cron handles stale answers:
- Orphaned answers: archived after 90 days with zero access
- Active low-use: access_count < 3 after 180 days
- Manual:
mycortex answer prune --days 90 --min-access 0
Test Commands
mycortex answer store "What is the capital of France?" "Paris" \
--confidence high --tokens 5 --force
mycortex answer search "capital of France" --json
mycortex answer stats
mycortex answer prune --days 0 --min-access 0 --dry-run
04 同仓库更多 Skills
macbook-linux-maintenance
Legacy MacBook Linux fixes: GPU wedge, reboot hang, thermal.
governance-regression-triage
Triage a host's governance issues: what changed.
enforcement-immutability
Use when enforcement files lose their immutable flag.
steadfaste-fleet-repo-deploy
Use when committing to the steadfaste-fleet repo.
steadfaste-fleet-maintenance
Maintain an installed Steadfaste Fleet instance — update both the upstream Hermes Agent and the fleet repo layer, merge diverged histories, sync skills safely, and troubleshoot common issues. Covers the dual-update workflow (hermes update + fleet-update.sh), encrypted brain data backup, mycortex import, and recovery techniques.
fleet-preflight
DEPRECATED alias — merged into survey-before-action (2026-08-20). Load survey-before-action instead; its "Repo-Specific Pre-Flight" section covers git search, Hermes boundary, and deployment verification.