Prompt cache key ignores `label`, so labelled and unlabelled lookups share an entry

Aperta Adatta ai principianti
#1,520 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 5 giorni

@shhhhhhjokerist ci sta già lavorando.

Dal 8/11/2026.

  • #1521 di @shhhhhhjokerist — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
77/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
backend

Direzione di ricerca

Inizia leggendo VoltOpsPromptManagerImpl.getCacheKey() e la specifica esistente della cache dei prompt menzionata nell’issue. Controlla come i selettori PromptReference e VoltOpsPromptApiClient.buildPromptUrl gestiscono la versione e l’etichetta, quindi aggiungi o aggiorna test per le ricerche con etichetta, con versione e senza etichetta. Il lavoro è completato quando selettori diversi ottengono voci di cache separate, mentre selettori identici ripetuti continuano a usare la cache.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Current behavior

VoltOpsPromptManagerImpl.getCacheKey() builds the cache key from promptName and version only, defaulting version to "latest":

const { promptName, version = "latest" } = reference;
return `${promptName}:${version}`;

PromptReference.label is a supported selector (@voltagent/core types and VoltOpsPromptApiClient.buildPromptUrl both use it), but it is ignored here. So { promptName: "greeting", label: "production" } and { promptName: "greeting" } map to the same key (greeting:latest). Whichever call stores first wins the entry for the whole TTL (default 5 minutes), and the other selector is then served that prompt's content and metadata. Two different labels (production / staging) also share one entry.

Reproduction

With a mocked VoltOpsPromptApiClient that returns different text per selector (same pattern as the existing spec):

  1. getPrompt({ promptName: "greeting", label: "production" }) → returns "Production prompt" and caches it.
  2. getPrompt({ promptName: "greeting" }) → expected "Latest prompt", actually returns the cached "Production prompt", with no second API call.

This is observable as wrong prompt content in an app that mixes labelled (pinned) and unlabelled (latest) lookups.

Expected behavior

Cache entries should be scoped to the selector that was requested: name:version:<v>, name:label:<l>, and name:latest for no selector. Version keeps precedence over label, matching the documented PromptReference contract, and repeating the same selector should still hit the cache.

Environment

  • @voltagent/core on main (e9fc599), pnpm 11, Windows, Node 25.
  • Found while auditing the prompt cache; no related open issue that I could find.
Lingua principale
TypeScript
Stelle
11k
Fork
1.2k
Merge medio
4g 10h
PR unite (30g)
6

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di VoltAgent/voltagent

Tutte le issue di VoltAgent/voltagent

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.