B-phase-2-cache

An implementation assignment for building a three-level cache: memory LRU, disk storage using CBOR, and compact delta encoding. It adds caching to a tool registry and uses input definitions to create stable cache keys.

In plain words
What is it for?
Use it to implement cache storage, cache lookups and misses, expiry rules, stable key generation, and the connection between caching and reliability handling.
Why use it?
It reduces repeated backend calls and keeps cached results consistent across runs, while defining how long different tools may be cached.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/darkiceinteractive/mcp-conductor/b-phase-2-cache
Clone the repo
git clone --depth 1 https://github.com/darkiceinteractive/mcp-conductor
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 527 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00527
Opus 5 $0.00000 $0.00264
Sonnet 5 $0.00000 $0.00105
Haiku 4.5 $0.00000 $0.00053

Measured yesterday against content hash 9949c994d1a0, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

B-phase-2-cache scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

_plans/v3-enhancements/agents/B-phase-2-cache.md · 50 lines

How it starts

The opening of the file, as written. The whole thing — 50 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agent B — PRD Phase 2 Cache layer

You build the three-tier cache (LRU + disk CBOR + delta encoding) on top of Agent A's registry.

Setup

pwd  # /mcp-executor-darkice-worktrees/B-phase-2
git branch --show-current  # feature/v3-phase-2
git fetch origin && git rebase origin/feature/v3-phase-0-1   # pick up A's foundation
npm install
npm run test:run  # baseline must be green

Read _plans/v3-enhancements/MCP-Conductor-v3-PRD.md §5 Phase 2 (lines ~357–540).

Append start checkpoint to _plans/v3-enhancements/STATUS.md under Agent B.

Scope

Build everything in src/cache/ per PRD §5 Phase 2 file list and public API. Use ToolRegistry annotations to drive TTL policyToolDefinition.cacheable and ToolDefinition.cacheTtl are the registry-level overrides; the per-tool policy table in PRD is the default.

Cache key derivation MUST come from registry inputSchema (use validator.ts's normalisation), not from raw args object — this guarantees stable hashes across runs.

Important wiring point: bridge callTool() invokes cache before reliability gateway (Agent C). Order: cache check → cache miss → reliability gateway → backend. Cache hit short-circuits everything.

Acceptance

PRD §5 Phase 2 "Acceptance criteria" + this addition:

  • Cache invalidation on registry tool-updated event (when an upstream schema changes, related cache entries are flushed).

Commit pattern

feat(v3-phase-2): in-memory LRU + content-addressed key derivation
feat(v3-phase-2): CBOR-encoded disk cache with rotation
feat(v3-phase-2): delta encoding for repeat queries
feat(v3-phase-2): TTL policy table + per-server overrides
feat(v3-phase-2): wire CacheLayer into bridge callTool path
test(v3-phase-2): full lru/disk/key/delta/cache test suites

PR

gh pr create --base feature/v3 --title "v3 Phase 2: Cache layer (LRU + CBOR disk + delta)". Update STATUS.md READY-FOR-MERGE.

When to stop

After PR open, CI green, STATUS.md updated. Don't touch any other phase's files.

Read the full file on GitHub · 50 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 50 lines · 0 tokens per session scan A 9949c994d1a0

Subscribe to this mod's changes

B-phase-2-cache is an agent published in the GitHub repository darkiceinteractive/mcp-conductor (0 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 527 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.