cd /news/developer-tools/cache-break-notifier-plugin-for-gith… · home topics developer-tools article
[ARTICLE · art-66652] src=gist.github.com ↗ pub= topic=developer-tools verified=true sentiment=· neutral

Cache Break Notifier plugin for GitHub Copilot CLI

A developer created a Cache Break Notifier plugin for GitHub Copilot CLI that warns users when the AI assistant's context cache drops significantly between turns, helping to identify costly cache misses. The plugin monitors cache read tokens per model and logs warnings when a drop of 4096 or more tokens is detected.

read2 min views2 publishedJul 20, 2026

| import { joinSession } from "@github/copilot-sdk/extension"; | | | | const DROP_TOKENS = 4096; // the only tunable: how big a cache-read drop is worth a warning | | | | /** @type {Map<string, number>} last turn-entry cacheRead per model */ | | const perModel = new Map(); | | | | // Only the FIRST eligible main-agent call of each turn is evaluated. | | let acceptingTurnEntry = false; | | | | const session = await joinSession({}); | | await session.log("cache-drop-notifier active", { ephemeral: true }); | | | | session.on("assistant.turn_start", () => { | | acceptingTurnEntry = true; | | }); | | session.on("assistant.turn_end", () => { | | acceptingTurnEntry = false; | | }); | | | | session.on("assistant.usage", (event) => { | | const d = event.data ?? {}; | | | | // Main context only: skip separate-context calls entirely (don't consume the slot). | | const initiator = d.initiator; | | const isMain = | | initiator !== "sub-agent" && | | initiator !== "mcp-sampling" && | | d.parentToolCallId == null; | | if (!acceptingTurnEntry || !isMain) return; | | | | // This is the turn-entry sample — consume the slot even if the metrics are unusable, | | // so a later continuation call can't masquerade as the entry. | | acceptingTurnEntry = false; | | | | // Unknown != zero: a missing counter means "no data," so we skip this turn's line. | | // Only cacheReadTokens matters now (inputTokens is no longer part of detection), so a | | // missing inputTokens must not be allowed to suppress a real drop. | | const cached = d.cacheReadTokens; | | if (!Number.isFinite(cached) || cached < 0) return; | | | | const model = d.model ?? "unknown"; | | const prev = perModel.get(model); | | | | // A "drop" (not a "miss"): reused tokens fell by a large absolute amount versus the last | | // turn on this model. An intentional context shrink looks identical in the counts. | | const isDrop = prev !== undefined && prev - cached >= DROP_TOKENS; | | | | if (isDrop) { | | session.log( | | Cache break detected on ${model}., | | { level: "warning" } | | ).catch(() => {}); | | } else if (cached === 0) { | | session.log( | | No cache tokens reused on ${model}., | | { level: "warning" } | | ).catch(() => {}); | | } | | | | // Always update — this is why a drop is reported once and the baseline self-heals. | | perModel.set(model, cached); | | }); |

── more in #developer-tools 4 stories · sorted by recency
── more on @github copilot 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/cache-break-notifier…] indexed:0 read:2min 2026-07-20 ·