Skip to content

feat(api): Add prompt cache diagnostics - #975

Merged
apcha-oai merged 1 commit into
mainfrom
castiron/promotions/pr-65
Sep 4, 2026
Merged

feat(api): Add prompt cache diagnostics#975
apcha-oai merged 1 commit into
mainfrom
castiron/promotions/pr-65

Conversation

@apcha-oai

@apcha-oai apcha-oai commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Add prompt cache comparison requests and typed diagnostics to the Responses API. The new capabilities are available in both stable and beta response models.

Changes

  • Add the optional comparisonResponseId prompt cache option to response creation and client event inputs.
  • Expose the comparison response ID in returned prompt cache options.
  • Expose diagnostics through the handwritten StructuredResponse wrapper, including raw JSON-field access.
  • Add PromptCacheDiagnostics response data for cache hits, cache misses, missing comparison responses, and unavailable diagnostics.
  • Describe cache misses with affected token counts, optional reusable-token counts, and typed miss reasons.

Validation

  • Formatting and all 75 StructuredResponseTest tests passed against the Jackson compatibility runtime.
  • API compatibility checks passed for both baseline and proposed APIs; the manifest includes the two added wrapper accessors.
  • Custom-code budget passed at 1906 / 2000 lines.

Castiron-Internal-PR: openai/openai-java-internal#65
Castiron-Source-SHA: d1c02da027a59e48ed83c65b35cffa0bfaa35182
Castiron-Public-Base-SHA: 1992a4a
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

55 mixed files remain; 0 existing customizations changed; 7 generated baselines changed.

Compared 1992a4a8517bde17a7b87552. Generated baselines verified.

File Result Current custom patch
openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt Generated baseline changed +58 / −0
openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponsesServerEventTest.kt Generated baseline changed +101 / −0
openai-java-core/src/test/kotlin/com/openai/models/responses/ResponsesServerEventTest.kt Generated baseline changed +101 / −0
openai-java-core/src/test/kotlin/com/openai/services/async/ResponseServiceAsyncTest.kt Generated baseline changed +3 / −0
openai-java-core/src/test/kotlin/com/openai/services/async/beta/ResponseServiceAsyncTest.kt Generated baseline changed +1 / −4
openai-java-core/src/test/kotlin/com/openai/services/blocking/ResponseServiceTest.kt Generated baseline changed +3 / −0
openai-java-core/src/test/kotlin/com/openai/services/blocking/beta/ResponseServiceTest.kt Generated baseline changed +1 / −3
48 existing customizations unchanged
  • openai-java-core/src/main/kotlin/com/openai/models/audio/AudioResponseFormat.kt
  • openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt
  • openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageFunctionToolCall.kt
  • openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionToolMessageParam.kt
  • openai-java-core/src/main/kotlin/com/openai/models/embeddings/Embedding.kt
  • openai-java-core/src/main/kotlin/com/openai/models/embeddings/EmbeddingCreateParams.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionToolCall.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseFunctionWebSearch.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt
  • openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseTextConfig.kt
  • openai-java-core/src/main/kotlin/com/openai/models/videos/Video.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/BetaServiceAsync.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/BetaServiceAsyncImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsync.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/WebhookServiceAsync.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/WebhookServiceAsyncImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsyncImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsync.kt
  • openai-java-core/src/main/kotlin/com/openai/services/async/finetuning/checkpoints/PermissionServiceAsyncImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/BetaService.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/BetaServiceImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseService.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/WebhookService.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/WebhookServiceImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/audio/TranscriptionServiceImpl.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/chat/ChatCompletionService.kt
  • openai-java-core/src/main/kotlin/com/openai/services/blocking/finetuning/checkpoints/PermissionServiceImpl.kt
  • openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseFunctionWebSearchTest.kt
  • openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseFunctionWebSearchTest.kt
  • openai-java-core/src/test/kotlin/com/openai/services/async/CompletionServiceAsyncTest.kt
  • openai-java-core/src/test/kotlin/com/openai/services/async/ImageServiceAsyncTest.kt
  • openai-java-core/src/test/kotlin/com/openai/services/async/WebhookServiceAsyncTest.kt
  • openai-java-core/src/test/kotlin/com/openai/services/async/audio/TranscriptionServiceAsyncTest.kt
  • openai-java-core/src/test/kotlin/com/openai/services/async/beta/ThreadServiceAsyncTest.kt
  • openai-java-core/src/test/kotlin/com/openai/services/async/beta/threads/RunServiceAsyncTest.kt
  • openai-java-core/src/test/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsyncTest.kt
  • openai-java-core/src/test/kotlin/com/openai/services/blocking/CompletionServiceTest.kt
  • openai-java-core/src/test/kotlin/com/openai/services/blocking/ImageServiceTest.kt

8 more in the full report.

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 33890414274 --repo openai/openai-java \
  --name castiron-custom-code-33890414274-1 --dir /tmp/castiron-custom-code-33890414274-1
git apply --stat /tmp/castiron-custom-code-33890414274-1/custom-code.patch
cat /tmp/castiron-custom-code-33890414274-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin 1992a4a8517bb6d9d1c7e99e0641ef85c562bc4e de17a7b87552bae3043d9d18090c328298a638d3
python3 scripts/castiron/custom_code_report.py report \
  --base 1992a4a8517bb6d9d1c7e99e0641ef85c562bc4e \
  --head de17a7b87552bae3043d9d18090c328298a638d3 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-de17a7b87552
cat /tmp/castiron-custom-code-de17a7b87552/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good layering: prompt-cache diagnostics stay on the generated Response model, while StructuredResponse exposes both the typed optional and raw JsonField without duplicating decoding logic. Carrying comparison_response_id through the request and returned cache options also keeps the comparison identity inspectable. One thing I would verify before merge is that the broad regenerated OpenAPI delta is intentional for this spec revision, since it also changes inference error responses outside prompt caching.

@apcha-oai
apcha-oai marked this pull request as ready for review September 4, 2026 15:35
@apcha-oai
apcha-oai requested a review from a team as a code owner September 4, 2026 15:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T15:38:25.856885Z de17a7b Draft marked ready
🔒 Security Review Completed 2026-09-04T15:37:45.522852Z de17a7b Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openai-sdks

openai-sdks Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 14.921s for Java SDK PR #975.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 280ms
tests/chat-completions-create.test.ts ✅ Passed 827ms
tests/chat-completions-stream.test.ts ✅ Passed 287ms
tests/files-content-binary.test.ts ✅ Passed 225ms
tests/files-create-multipart.test.ts ✅ Passed 336ms
tests/files-list-pagination.test.ts ✅ Passed 334ms
tests/initialize-config.test.ts ✅ Passed 167ms
tests/instance-isolation.test.ts ✅ Passed 144ms
tests/models-list.test.ts ✅ Passed 311ms
tests/responses-background-lifecycle.test.ts ✅ Passed 171ms
tests/responses-body-method-errors.test.ts ✅ Passed 524ms
tests/responses-cancel-timeout.test.ts ✅ Passed 243ms
tests/responses-cancel.test.ts ✅ Passed 286ms
tests/responses-compact-retries.test.ts ✅ Passed 438ms
tests/responses-compact.test.ts ✅ Passed 277ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 480ms
tests/responses-create-advanced.test.ts ✅ Passed 1.078s
tests/responses-create-disconnect.test.ts ✅ Passed 1.085s
tests/responses-create-errors.test.ts ✅ Passed 292ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 282ms
tests/responses-create-retries.test.ts ✅ Passed 828ms
tests/responses-create-stream-failures.test.ts ✅ Passed 206ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 226ms
tests/responses-create-stream-wire.test.ts ✅ Passed 5.332s
tests/responses-create-stream.test.ts ✅ Passed 402ms
tests/responses-create-terminal-states.test.ts ✅ Passed 229ms
tests/responses-create-timeout.test.ts ✅ Passed 215ms
tests/responses-create.test.ts ✅ Passed 274ms
tests/responses-delete.test.ts ✅ Passed 202ms
tests/responses-input-items-errors.test.ts ✅ Passed 246ms
tests/responses-input-items-list.test.ts ✅ Passed 236ms
tests/responses-input-items-options.test.ts ✅ Passed 344ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 210ms
tests/responses-input-tokens-count.test.ts ✅ Passed 257ms
tests/responses-malformed-inputs.test.ts ✅ Passed 4.34s
tests/responses-not-found-errors.test.ts ✅ Passed 290ms
tests/responses-parse.test.ts ✅ Passed 462ms
tests/responses-retrieve-retries.test.ts ✅ Passed 259ms
tests/responses-retrieve.test.ts ✅ Passed 391ms
tests/responses-stored-method-errors.test.ts ✅ Passed 1.006s
tests/retry-behavior.test.ts ✅ Passed 3.463s
tests/sdk-error-shape.test.ts ✅ Passed 393ms

View OkTest run #33890387464

SDK merge (3a08c3a45249) · head (de17a7b87552) · base (1992a4a8517b) · OkTest (2b1bdfd25e98)

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head de17a7b. The stable and beta request builders, optional comparison response IDs, diagnostic union models, serialization paths, structured response delegation, and generated tests are consistent. Exact-head CI is green; no blocking findings.

@apcha-oai
apcha-oai added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit b9b9c85 Sep 4, 2026
17 checks passed
@openai-sdks openai-sdks Bot mentioned this pull request Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants