0xPlaygrounds / 0xPlaygrounds/rig

feat: support OpenAI prompt cache breakpoints (Responses API)

未关闭
#2,170 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Rust
星标
8.6k
派生
959
平均合并
4 小时 32 分钟
30 天内合并 PR
117

描述

- [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.

贡献指南

打开贡献指南

调研方向

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.

由索引模型根据 Issue 内容生成。

评估

技术栈
rust
领域
ai-infra-agents, backend-api-design
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
描述清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。