◉GEMINI LABJP
●OMNI 1.2 — Gemini Omni 1.2 Flash is generally available (11/5) with up to 15-second video and conversational editing; 1.1 Flash is routed to 1.2 on 12/3●COMPUTER — Computer Use is now generally available in the Interactions and GenerateContent APIs (10/30)●LIVE — Live and TTS preview models shut down as early as 11/17 (7 days left). Move to gemini-3.8-live and the 3.8 TTS models●CLI — Gemini API CLI (gemini-api) is out in beta (10/27): a zero-dependency client for agents and CI●2.5 PRO — gemini-2.5-pro and 2.5-flash are routed automatically on 12/1 (21 days left), to 3.8 Flash and 3.5 Flash-Lite●NEW — Stop Re-Reading Every Crash Report: Gre…●OMNI 1.2 — Gemini Omni 1.2 Flash is generally available (11/5) with up to 15-second video and conversational editing; 1.1 Flash is routed to 1.2 on 12/3●COMPUTER — Computer Use is now generally available in the Interactions and GenerateContent APIs (10/30)●LIVE — Live and TTS preview models shut down as early as 11/17 (7 days left). Move to gemini-3.8-live and the 3.8 TTS models●CLI — Gemini API CLI (gemini-api) is out in beta (10/27): a zero-dependency client for agents and CI●2.5 PRO — gemini-2.5-pro and 2.5-flash are routed automatically on 12/1 (21 days left), to 3.8 Flash and 3.5 Flash-Lite●NEW — Stop Re-Reading Every Crash Report: Gre…
Articles/API / SDK
◈ API / SDK/2026-07-27Advanced

Retiring Prompt Assets That Refuse to Die — A Ledger for Paths Static Analysis Cannot See

A prompt I had supposedly consolidated away was still running daily. Here is the retirement ledger I built to cross-check static references, flag defaults, observation windows, model end-of-life dates, and cache effectiveness.

Gemini API255Prompt ManagementProduction OperationsContext Caching5Architecture10

✦ Premium Article

I was scanning a billing breakdown when my finger stopped moving.

The prompt that classifies wallpaper images had been consolidated onto v3 some time ago. And yet the v2 lineage was still being invoked, every single day. I searched the codebase for the string wallpaper.classify.v2 and found nothing. Nothing at all — and it was still running.

The cause itself turned out to be mundane. What stayed with me was the shape of the problem rather than its cause. As an indie developer maintaining several apps at once, the number of places you call a model keeps growing, and past some point prompts stop dying the way code dies. A reference disappears, but the prompt lingers in configuration, in a scheduler, as a cache handle. And it keeps billing you, quietly, somewhere nobody is looking.

The retirement ledger described here is what I built that weekend.

Prompts Do Not Die the Way Code Dies

When a function loses its last caller, static analysis tells you. The linter flags it as unused, you delete it, and nothing breaks. Prompts do not behave that way.

There are three reasons for this, as far as I can tell.

First, a prompt identifier is a string. Once it lives in a config file, an environment variable, or a database row, it drops out of the compiler's field of view. Second, the entry point often sits outside the application itself — schedulers, webhooks, batch jobs, Apps Script. Whoever calls the prompt is not guaranteed to live in your repository. Third, with the Gemini API a prompt asset is not self-contained. A pinned model ID, a cachedContents handle, and a responseSchema version hang off it, and each has its own lifetime.

That third point has grown heavier through 2026. Default models have been swapped underneath users without an announcement, and the older image generation models carry a published shutdown date. An asset that pins a model ID inside the prompt definition does not come back to you as a forgotten cleanup task. It comes back as an expiry.

So what you need is not a tool for deleting prompts. It is a ledger that judges, from several angles at once, whether deletion is safe.

My First Version Told Me to Delete Something That Was Running

The first implementation was the obvious one. Walk the source tree, collect string references to prompt IDs, and mark anything unreferenced as retirable. I added flag defaults and last-run timestamps, and returned the first classification that matched.

Here is what it printed against a sample ledger.

store.screenshot.caption.v1  MODEL_EOL      gemini-3.1-flash-image-preview shut down 2026-06-25
wallpaper.classify.v2        UNREACHABLE    No source reference; last run 1 day ago. Safe to retire
wallpaper.caption.legacy     UNREACHABLE    No source reference; last run 162 days ago. Safe to retire
review.reply.draft.v2        GATED          Flag review_autoreply defaults to false

Read the second line again.

"No source reference" and "last run 1 day ago" sit on the same row, and the verdict is "safe to retire." Had I followed that advice, I would have deleted a path that runs every single day.

Not being findable and not being alive are two different facts. I knew that in the abstract, but a first-match classifier collapses them into a single label. The moment it prioritized the static result, it discarded the far stronger evidence sitting right next to it: this thing ran yesterday.

So I gave the state its own name. PHANTOM — a path that is invisible to static analysis yet actively running. In a retirement ledger this is the opposite of "safe to delete." It is the first thing you should investigate, precisely because not knowing where the ID is assembled is itself proof that the asset has slipped out of management.

The rewritten branch:

referenced = pid in refs
live = idle <= period          # ran within the last scheduling period
 
if not referenced and live:
    findings.append(("PHANTOM",
        f"No source reference, yet ran {idle} days ago. ID is likely built dynamically"))
elif not referenced:
    findings.append(("UNREACHABLE", f"No source reference; idle {idle} days. Retirable"))

One extra branch, but it changed the character of the tool. "No reference found" became a hypothesis to be checked against observation, rather than grounds for deletion.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦Detection logic for phantom paths — assets with no static reference that are nevertheless running in production
✦A measured comparison showing how a fixed idle threshold deletes annual batches while missing genuinely stalled prompts
✦A multi-label design that stops findings from hiding each other, plus why cache effectiveness must be fixed before retirement
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

◈ API / SDK2026-04-26
Architecting a Multi-Tenant SaaS on Gemini API — Tenant Isolation, Usage Metering, and Runaway Cost Defense in Production
A field-tested blueprint for serving Gemini API to multiple tenants on a single backend — covering tenant isolation choices, per-tenant rate limiting in Redis, request-level usage metering for billing, and runaway-cost defenses.
◈ API / SDK2026-10-30
An 'API key expired' Error Doesn't Always Mean Expired. Check Which Key Is Actually Sent Before You Renew It
A 400 with API_KEY_INVALID from the Gemini API cannot tell you whether the key expired or something else is wrong. A small diagnostic script checks env-var precedence and stray quotes first, run here against dummy keys.
◈ API / SDK2026-10-30
My ADK Agent Never Ran and Said 'API key expired' — Reading the Reason Code Gave Me a Triage Order
When ADK returns 400 INVALID_ARGUMENT 'API key expired. Please renew the API key.' on every run, check this order before assuming the key expired: read the reason code, compare shell and .env keys by their last four characters, then test the key alone over REST.