Support OpenAI prompt_cache_breakpoint on Responses API input content

Chiusa
#6,831 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@brandon-julio-t ci sta già lavorando.

Dal 1/8/2026.

  • #6833 di @brandon-julio-t — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
56/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
typescript
Ambito
api

Direzione di ricerca

Start with the InputTextContent, InputImageContent, InputFileContent, and InputContent definitions in packages/ai/openai/src/OpenAiSchema.ts, then inspect the system, user, image, and PDF conversions in packages/ai/openai/src/OpenAiLanguageModel.ts. Define an OpenAI-specific way to carry a breakpoint through prompt conversion and verify that the intended input_text, input_image, and input_file blocks emit it without conflating request-level cache options.

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

Descrizione

Support OpenAI prompt_cache_breakpoint on Responses API input content

Summary

@effect/ai-openai currently has no way to mark an explicit OpenAI prompt-cache breakpoint on a Responses API input content block.

OpenAI's GPT-5.6 prompt-caching API supports prompt_cache_breakpoint on input_text, input_image, and input_file blocks. This is distinct from prompt_cache_key, which is a request-level cache-routing control.

Version checked

Why this matters

GPT-5.6 and later cache exact prefixes at cache breakpoints. With the default implicit policy, the service places a breakpoint at the latest user or tool message. If a stable system prompt or document is followed by changing content, the implicit breakpoint can repeatedly select a changing prefix instead of the stable reusable prefix.

An explicit breakpoint lets an application mark the end of the stable prefix. Combined with prompt_cache_options.mode: "explicit", it can also prevent writes for changing suffixes.

See OpenAI's current documentation for the behavior and supported blocks:

Evidence in Effect

The high-level Responses content schemas have no breakpoint field:

The prompt translator constructs those blocks without a breakpoint:

A repository-wide search of packages/ai/openai and packages/ai/openai-compat at c9b56ab507f224426ee8388dc450da447ec4715f finds no prompt_cache_breakpoint or prompt_cache_options support.

Expected behavior

Effect prompt content should provide an OpenAI-specific way to request:

{
  "type": "input_text",
  "text": "stable reusable instructions",
  "prompt_cache_breakpoint": {
    "mode": "explicit"
  }
}

The same capability should be representable for input_image and input_file parts supported by OpenAI.

The exact Effect API could use provider options on prompt parts or another provider-specific mechanism. The important behavior is that the marker survives prompt conversion and is emitted on the intended content block.

Request-level prompt_cache_key and prompt_cache_options support is tracked separately in #6830 because those fields belong to OpenAiLanguageModel.Config rather than individual prompt content blocks.

Related work

  • #6342 reported that encoding system messages as strings prevented OpenAI cache hits.
  • #6549 changed system-message encoding to an input_text block, which is one of the content types on which OpenAI now supports explicit breakpoints.
  • #6504 / #6519 added the cache-write usage accounting needed to measure explicit caching behavior.
Lingua principale
TypeScript
Stelle
16.7k
Fork
808
Merge medio
11h 3m
PR unite (30g)
839

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 Effect-TS/effect

Tutte le issue di Effect-TS/effect

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.