Skip to content

feat(api): add service-account API key expiration fields - #3802

Open
jbeckwith-oai wants to merge 1 commit into
mainfrom
castiron/promotions/pr-84
Open

feat(api): add service-account API key expiration fields#3802
jbeckwith-oai wants to merge 1 commit into
mainfrom
castiron/promotions/pr-84

Conversation

@jbeckwith-oai

@jbeckwith-oai jbeckwith-oai commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds optional expiration fields for service-account API keys, clarifies the Responses store option, and honors WebSocket retry limits across repeated reconnects.

Changes

  • Allow service-account API key creation requests to specify expires_in_seconds.
  • Expose expires_at on service-account API key responses.
  • Clarify the default and retention behavior of the Responses store option.
  • Honor the configured retry limit when WebSocket connections repeatedly fail before receiving a non-error application event.

Castiron-Internal-PR: openai/openai-python-internal#84
Castiron-Source-SHA: 6eefcc34b79ca8c3087a3f6ee6fbbaf5b8ac7510
Castiron-Public-Base-SHA: 2a98f6a
@jbeckwith-oai
jbeckwith-oai marked this pull request as ready for review September 5, 2026 00:40
@jbeckwith-oai
jbeckwith-oai requested a review from a team as a code owner September 5, 2026 00:40
@github-actions

github-actions Bot commented Sep 5, 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 2a98f6a1dee47863fba58838. Generated baselines verified.

File Result Current custom patch
src/openai/resources/beta/responses/responses.py Generated baseline changed +12 / −11
src/openai/resources/realtime/realtime.py Generated baseline changed +65 / −32
src/openai/resources/responses/responses.py Generated baseline changed +851 / −18
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/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.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 33934453127 --repo openai/openai-python \
  --name castiron-custom-code-33934453127-1 --dir /tmp/castiron-custom-code-33934453127-1
git apply --stat /tmp/castiron-custom-code-33934453127-1/custom-code.patch
cat /tmp/castiron-custom-code-33934453127-1/custom-code.patch

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

git fetch --no-tags origin 2a98f6a1dee448c6410531c89c2de0af4383c6a7 7863fba58838380e273caf8e320d26b25b261f77
python3 scripts/castiron/custom_code_report.py report \
  --base 2a98f6a1dee448c6410531c89c2de0af4383c6a7 \
  --head 7863fba58838380e273caf8e320d26b25b261f77 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-7863fba58838
cat /tmp/castiron-custom-code-7863fba58838/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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 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-05T00:44:45.809445Z 7863fba Draft marked ready
🔒 Security Review Completed 2026-09-05T00:43:45.230023Z 7863fba 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 5, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 11.003s for Python SDK PR #3802.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 193ms
tests/chat-completions-create.test.ts ✅ Passed 236ms
tests/chat-completions-stream.test.ts ✅ Passed 128ms
tests/files-content-binary.test.ts ✅ Passed 178ms
tests/files-create-multipart.test.ts ✅ Passed 182ms
tests/files-list-pagination.test.ts ✅ Passed 153ms
tests/initialize-config.test.ts ✅ Passed 165ms
tests/instance-isolation.test.ts ✅ Passed 176ms
tests/models-list.test.ts ✅ Passed 128ms
tests/responses-background-lifecycle.test.ts ✅ Passed 205ms
tests/responses-body-method-errors.test.ts ✅ Passed 304ms
tests/responses-cancel-timeout.test.ts ✅ Passed 207ms
tests/responses-cancel.test.ts ✅ Passed 226ms
tests/responses-compact-retries.test.ts ✅ Passed 341ms
tests/responses-compact.test.ts ✅ Passed 302ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 128ms
tests/responses-create-advanced.test.ts ✅ Passed 246ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.272s
tests/responses-create-errors.test.ts ✅ Passed 181ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 239ms
tests/responses-create-retries.test.ts ✅ Passed 268ms
tests/responses-create-stream-failures.test.ts ✅ Passed 127ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 227ms
tests/responses-create-stream-wire.test.ts ✅ Passed 3.638s
tests/responses-create-stream.test.ts ✅ Passed 290ms
tests/responses-create-terminal-states.test.ts ✅ Passed 233ms
tests/responses-create-timeout.test.ts ✅ Passed 200ms
tests/responses-create.test.ts ✅ Passed 204ms
tests/responses-delete.test.ts ✅ Passed 228ms
tests/responses-input-items-errors.test.ts ✅ Passed 318ms
tests/responses-input-items-list.test.ts ✅ Passed 398ms
tests/responses-input-items-options.test.ts ✅ Passed 365ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 259ms
tests/responses-input-tokens-count.test.ts ✅ Passed 276ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.731s
tests/responses-not-found-errors.test.ts ✅ Passed 228ms
tests/responses-parse.test.ts ✅ Passed 484ms
tests/responses-retrieve-retries.test.ts ✅ Passed 273ms
tests/responses-retrieve.test.ts ✅ Passed 273ms
tests/responses-stored-method-errors.test.ts ✅ Passed 571ms
tests/retry-behavior.test.ts ✅ Passed 3.037s
tests/sdk-error-shape.test.ts ✅ Passed 289ms

View OkTest run #33933774634

SDK merge (e6e830fb1209) · head (7863fba58838) · base (2a98f6a1dee4) · 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: 7863fba588

ℹ️ 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 +341 to +342
if isinstance(event_type, str) and event_type and event_type != "error":
self._reconnect_attempt = 0

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 Reset retries after recoverable error events

When a successful reconnect is followed by a normal request-level error event, this condition leaves the previous attempt count active even though RealtimeErrorEvent explicitly documents that most errors are recoverable and the session remains open. If that healthy session later experiences an unrelated network disconnect before producing a non-error event, reconnection starts from the stale count and can eventually be refused after several independent incidents. Distinguish admission failures from recoverable application errors instead of treating every type == "error" event as a failed reconnect; the same condition is duplicated in the sync and Responses connection implementations.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I checked the actual sync/async Realtime, Responses, and beta Responses connection classes. For Realtime, session.created is the first event on an established connection; it resets the count before later recoverable errors. A probe starting at the retry limit, receiving that event and then a request error, reconnects at attempt 1 after a later network close.

For a Responses connection that has received only errors since reconnecting, your observation about retaining the count is correct. This guard currently requires a non-error application event (such as response.created) to replenish the budget. Error events remain available to the caller and do not themselves close the connection or consume another retry. Resetting on a subset of errors needs a reliable distinction from errors followed by admission failure/closure, so I am preserving the current behavior pending maintainer agreement on that policy rather than adding an unverified classification. Leaving this thread open for that decision.

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

The reconnect counter is reset only in recv() after the parsed event is known to be non-error. The byte-oriented receive path still calls recv_bytes() directly, so a caller using that public API can successfully receive frames after a reconnect without ever clearing _reconnect_attempt. Separate transient disconnects would then consume one shared retry budget across otherwise healthy periods until a later reconnect is refused. Is the raw receive path intentionally excluded from the new retry semantics? If not, it would be useful to cover reconnect -> successful raw frame -> disconnect again and make sure the budget resets without treating an application error event as success.

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