Skip to content

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

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

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

Conversation

@apcha-oai

Copy link
Copy Markdown
Contributor

Summary

Expose optional prompt cache comparison diagnostics across the stable and beta Responses APIs. Clarify how Fast and Priority service tier requests resolve for different models.

Changes

  • Add the optional comparison_response_id prompt cache option to response creation parameters and client events.
  • Add prompt_cache_diagnostics to response models with typed cache hit, cache miss, comparison-not-found, and unavailable outcomes.
  • Expose cache miss reasons, affected token estimates, and reusable-prefix token counts in diagnostic results.
  • Include the comparison response ID in returned prompt cache options when supplied.
  • Clarify that Fast or Priority requests resolve to fast for models with a dedicated Fast tier and to priority for other models.

Castiron-Internal-PR: openai/openai-python-internal#80
Castiron-Source-SHA: f763d450ff4e6b141a929462aa3c6830f0f0bff3
Castiron-Public-Base-SHA: 3cc8d78
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

36 mixed files remain; 0 existing customizations changed; 5 generated baselines changed.

Compared 3cc8d784ad0532697326a51d. Generated baselines verified.

File Result Current custom patch
src/openai/resources/beta/responses/responses.py Generated baseline changed +12 / −11
src/openai/resources/responses/responses.py Generated baseline changed +851 / −18
src/openai/types/responses/response.py Generated baseline changed +15 / −0
src/openai/types/responses/responses_client_event.py Generated baseline changed +30 / −0
src/openai/types/responses/responses_client_event_param.py Generated baseline changed +30 / −0
31 existing customizations unchanged
  • api.md
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_report.py
  • src/openai/init.py
  • src/openai/_client.py
  • src/openai/resources/audio/transcriptions.py
  • src/openai/resources/audio/translations.py
  • src/openai/resources/beta/beta.py
  • src/openai/resources/beta/threads/runs/runs.py
  • src/openai/resources/beta/threads/threads.py
  • src/openai/resources/chat/completions/completions.py
  • src/openai/resources/embeddings.py
  • src/openai/resources/files.py
  • src/openai/resources/realtime/realtime.py
  • src/openai/resources/uploads/uploads.py
  • src/openai/resources/vector_stores/file_batches.py
  • src/openai/resources/vector_stores/files.py
  • src/openai/resources/videos.py
  • src/openai/resources/webhooks/init.py
  • src/openai/resources/webhooks/webhooks.py
  • src/openai/types/chat/init.py
  • src/openai/types/chat/chat_completion_message_tool_call.py
  • src/openai/types/fine_tuning/fine_tuning_job_integration.py
  • src/openai/types/responses/init.py
  • src/openai/types/responses/response_function_web_search.py
  • src/openai/types/responses/response_function_web_search_param.py
  • src/openai/types/responses/tool.py
  • src/openai/types/responses/tool_param.py
  • src/openai/types/webhooks/init.py
  • tests/api_resources/test_videos.py

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 33889316229 --repo openai/openai-python \
  --name castiron-custom-code-33889316229-1 --dir /tmp/castiron-custom-code-33889316229-1
git apply --stat /tmp/castiron-custom-code-33889316229-1/custom-code.patch
cat /tmp/castiron-custom-code-33889316229-1/custom-code.patch

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

git fetch --no-tags origin 3cc8d784ad05f75a265012ee86638adaf93d8bf2 32697326a51de0c5949b23135f724819b2ac8b88
python3 scripts/castiron/custom_code_report.py report \
  --base 3cc8d784ad05f75a265012ee86638adaf93d8bf2 \
  --head 32697326a51de0c5949b23135f724819b2ac8b88 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-32697326a51d
cat /tmp/castiron-custom-code-32697326a51d/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

@apcha-oai
apcha-oai marked this pull request as ready for review September 4, 2026 15:24
@apcha-oai
apcha-oai requested a review from a team as a code owner September 4, 2026 15:24
@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:27:03.749171Z 3269732 Draft marked ready
🔒 Security Review Completed 2026-09-04T15:26:20.409562Z 3269732 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 11.721s for Python SDK PR #3800.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 195ms
tests/chat-completions-create.test.ts ✅ Passed 248ms
tests/chat-completions-stream.test.ts ✅ Passed 128ms
tests/files-content-binary.test.ts ✅ Passed 222ms
tests/files-create-multipart.test.ts ✅ Passed 267ms
tests/files-list-pagination.test.ts ✅ Passed 181ms
tests/initialize-config.test.ts ✅ Passed 171ms
tests/instance-isolation.test.ts ✅ Passed 239ms
tests/models-list.test.ts ✅ Passed 157ms
tests/responses-background-lifecycle.test.ts ✅ Passed 256ms
tests/responses-body-method-errors.test.ts ✅ Passed 352ms
tests/responses-cancel-timeout.test.ts ✅ Passed 225ms
tests/responses-cancel.test.ts ✅ Passed 302ms
tests/responses-compact-retries.test.ts ✅ Passed 388ms
tests/responses-compact.test.ts ✅ Passed 276ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 129ms
tests/responses-create-advanced.test.ts ✅ Passed 277ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.207s
tests/responses-create-errors.test.ts ✅ Passed 209ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 267ms
tests/responses-create-retries.test.ts ✅ Passed 274ms
tests/responses-create-stream-failures.test.ts ✅ Passed 145ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 208ms
tests/responses-create-stream-wire.test.ts ✅ Passed 3.875s
tests/responses-create-stream.test.ts ✅ Passed 285ms
tests/responses-create-terminal-states.test.ts ✅ Passed 259ms
tests/responses-create-timeout.test.ts ✅ Passed 243ms
tests/responses-create.test.ts ✅ Passed 220ms
tests/responses-delete.test.ts ✅ Passed 209ms
tests/responses-input-items-errors.test.ts ✅ Passed 325ms
tests/responses-input-items-list.test.ts ✅ Passed 434ms
tests/responses-input-items-options.test.ts ✅ Passed 314ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 276ms
tests/responses-input-tokens-count.test.ts ✅ Passed 311ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.992s
tests/responses-not-found-errors.test.ts ✅ Passed 279ms
tests/responses-parse.test.ts ✅ Passed 411ms
tests/responses-retrieve-retries.test.ts ✅ Passed 324ms
tests/responses-retrieve.test.ts ✅ Passed 312ms
tests/responses-stored-method-errors.test.ts ✅ Passed 595ms
tests/retry-behavior.test.ts ✅ Passed 3.118s
tests/sdk-error-shape.test.ts ✅ Passed 288ms

View OkTest run #33889280768

SDK merge (be82aa1456c0) · head (32697326a51d) · base (3cc8d784ad05) · OkTest (2b1bdfd25e98)

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 32697326a5

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1900 to +1902
Completions. For models with a dedicated Fast tier, either value resolves to
`service_tier=fast`; for other models, either value resolves to
`service_tier=priority`. - When not set, the default behavior is 'auto'. When

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Update Fast-tier guidance for response creation

When users call the primary responses.create APIs with a dedicated Fast-tier model, their sync, async, stable, beta, and WebSocket documentation still says either request value is returned as service_tier=priority (for example, this file's lines 320-324), while only the compact endpoint now documents the corrected fast result. This leaves contradictory guidance for the exact behavior this commit intends to clarify; update the shared response service-tier schemas and regenerate all affected SDK surfaces rather than changing only compact.

AGENTS.md reference: AGENTS.md:L5-L6

Useful? React with 👍 / 👎.

@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 3269732. The stable and beta request fields, discriminated diagnostic response union, prompt cache option echo, generated tests, and service tier documentation are consistent with the transformed schema. 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 8326784 Sep 4, 2026
28 checks passed
@apcha-oai
apcha-oai deleted the castiron/promotions/pr-80 branch September 4, 2026 15:49
@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.

2 participants