0xPlaygrounds / 0xPlaygrounds/rig

feat: support OpenAI prompt cache breakpoints (Responses API)

Aperta
#2,170 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
8.6k
Fork
959
Merge medio
4h 32m
PR unite (30g)
117

Descrizione

- [x] I have looked for existing issues (including closed) about this

## Feature Request

Support OpenAI's [explicit prompt cache breakpoints](https://developers.openai.com/api/docs/guides/prompt-caching#prompt-cache-breakpoints) (GPT-5.6+): the per-block `prompt_cache_breakpoint` field on `input_text` / `input_image` / `input_file` content parts, and the request-level `prompt_cache_options` object.

### Motivation

rig's Responses API already carries `prompt_cache_key` and `prompt_cache_retention`, but has no way to express the new breakpoint fields. `prompt_cache_options` passed via request `additional_params` is silently dropped today, because `AdditionalParameters` is a closed struct. This is the OpenAI counterpart of the manual `cache_control` placement proposed for Anthropic in #2168.

### Proposal

- Wire types `PromptCacheBreakpoint` (`{"mode": "explicit"}` — the only valid value) and `PromptCacheOptions { mode, ttl }`; a `prompt_cache_options` field on `AdditionalParameters`.
- A documented `additional_params` key, `OPENAI_PROMPT_CACHE_BREAKPOINT_KEY` (`"openai_prompt_cache_breakpoint"`), on generic `Text` / `Image` / `Document` blocks, extracted by **both** message conversion paths onto the corresponding content part (same key-in-`additional_params` pattern as the Anthropic proposal and the existing Anthropic document `title`/`citations` keys).

PR to follow. Same design note as #2168: the carrier mechanism is speculative — happy to redo it differently.

### Alternatives

- First-class fields on generic message types, or typed attach helpers — same trade-offs as discussed in #2168.
- The Chat Completions API also supports these fields on its content parts; this proposal covers the Responses API only. Can follow up with Chat Completions support if wanted.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

The issue is about extending rig's Responses API to support OpenAI's prompt cache breakpoints. Start by examining the existing `AdditionalParameters` struct and the message conversion paths for `Text`, `Image`, and `Document` blocks. Look for the handling of `additional_params` keys like `OPENAI_PROMPT_CACHE_BREAKPOINT_KEY`. The PR mentioned in the description may provide a reference implementation. Check the linked issue #2168 for context on the `cache_control` pattern. 'Done' means the new fields are correctly wired and extracted in both conversion paths.

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

Valutazione

Stack tecnologico
rust
Ambito
ai-infra-agents, backend-api-design
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.