GEMINI LABJP
PRICE — Gemini 3.6 Flash consumes about 17% fewer output tokens and costs less at $1.50 per 1M input and $7.50 per 1M output, against $9 output for 3.5 FlashLITE — Gemini 3.5 Flash-Lite targets high-throughput work at $0.3 per million input tokensCYBER — Gemini 3.5 Flash Cyber powers vulnerability detection and patching inside Google's CodeMender agentGEMINI4 — Google says it has already begun its most ambitious pre-training run yet, for Gemini 4, even as 3.5 Pro slipsSUNSET — The Imagen 4 and Gemini 3 Image generation models shut down on August 17, 2026, so integrations need moving to newer stable or preview endpointsSTUDIO — Gemini Omni Flash is available in Google AI Studio for the first time, putting cost-efficient video generation and conversational editing within reachPRICE — Gemini 3.6 Flash consumes about 17% fewer output tokens and costs less at $1.50 per 1M input and $7.50 per 1M output, against $9 output for 3.5 FlashLITE — Gemini 3.5 Flash-Lite targets high-throughput work at $0.3 per million input tokensCYBER — Gemini 3.5 Flash Cyber powers vulnerability detection and patching inside Google's CodeMender agentGEMINI4 — Google says it has already begun its most ambitious pre-training run yet, for Gemini 4, even as 3.5 Pro slipsSUNSET — The Imagen 4 and Gemini 3 Image generation models shut down on August 17, 2026, so integrations need moving to newer stable or preview endpointsSTUDIO — Gemini Omni Flash is available in Google AI Studio for the first time, putting cost-efficient video generation and conversational editing within reach
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 API196Prompt 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 in this article 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 shuts down 2026-08-17
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-07-18
Keeping a Long-Running Managed Agent Alive Across Sandbox Recycling — Durable Checkpoints and Idempotent Resume
A Managed Agents sandbox can be recycled out from under you. Before 40 minutes of work resets to zero, we design a durable checkpoint that pushes progress outside the sandbox and an idempotent resume that never runs a side effect twice. With working SQLite code.
API / SDK2026-07-11
When Gemini's Context Cache Quietly Expires Mid-Run: A TTL Guard for Pipelines That Pause
When a nightly batch or a retry backoff pauses your pipeline, Gemini's explicit context cache can expire on the wall clock while nothing errors out, sending later calls back to full-token billing. Here is a small lease guard that decides whether to re-arm or run uncached based on cost.
API / SDK2026-07-06
When Context Caching Didn't Lower My Gemini Bill — Field Notes on Measuring the Real Hit Rate
When Context Caching is enabled but the Gemini API bill barely drops, this field note measures the real hit rate from usage_metadata, separates TTL churn from fragmentation, and walks through a staged recovery.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →