Skip to content

Unify realtime shutdown in core#14902

Merged
aibrahim-oai merged 14 commits intomainfrom
codex/realtime-end-core
Mar 17, 2026
Merged

Unify realtime shutdown in core#14902
aibrahim-oai merged 14 commits intomainfrom
codex/realtime-end-core

Conversation

@aibrahim-oai
Copy link
Collaborator

  • route realtime startup, input, and transport failures through a single shutdown path
  • emit one realtime error/closed lifecycle while clearing session state once

aibrahim-oai and others added 5 commits March 17, 2026 00:11
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai
Copy link
Collaborator Author

@codex review

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 24ffd8d6f8

ℹ️ 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 +355 to +365
if let Err(err) = handle_start_inner(sess, &sub_id, params).await {
error!("failed to start realtime conversation: {err}");
let message = err.to_string();
sess.send_event_raw(Event {
id: sub_id.clone(),
msg: EventMsg::RealtimeConversationRealtime(RealtimeConversationRealtimeEvent {
payload: RealtimeEvent::Error(message),
}),
})
.await;
end_realtime_conversation(sess, sub_id, RealtimeConversationEnd::Error).await;
Copy link
Contributor

Choose a reason for hiding this comment

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

P1 Badge Do not shutdown active session on pre-start validation failure

handle_start now calls end_realtime_conversation for any handle_start_inner error. But realtime_api_key() / realtime_request_headers() can fail before conversation.start() runs. In that case, a malformed new start request can terminate an unrelated already-running realtime session via shutdown(). Previously these preflight failures only emitted an error event and did not close existing state.

Useful? React with 👍 / 👎.

aibrahim-oai and others added 2 commits March 17, 2026 10:34
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai
Copy link
Collaborator Author

@codex review this

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 0e0481ba0f

ℹ️ 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 +534 to +544
if sess.conversation.running_state().await.is_some() {
let message = err.to_string();
sess.send_event_raw(Event {
id: sub_id.clone(),
msg: EventMsg::RealtimeConversationRealtime(RealtimeConversationRealtimeEvent {
payload: RealtimeEvent::Error(message),
}),
})
.await;
end_realtime_conversation(sess, sub_id, RealtimeConversationEnd::Error).await;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

P1 Badge Gate error shutdown to avoid out-of-order realtime lifecycle

This branch can emit RealtimeEvent::Error + RealtimeConversationClosed("error") from input ops while the transport task has already queued upstream realtime events. When that queue drains afterward, clients may receive additional realtime events/errors after closed, or duplicate error notifications. This violates the intended single ordered error/closed lifecycle and can confuse app-server/TUI state machines.

Useful? React with 👍 / 👎.

Co-own the realtime fanout task so shutdown stops the full session before closed is emitted. Also keep start/connect failures as error-only until started is sent.\n\nCo-authored-by: Codex <noreply@openai.com>
@aibrahim-oai
Copy link
Collaborator Author

@codex review this

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Can't wait for the next one!

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

aibrahim-oai and others added 2 commits March 17, 2026 21:04
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai and others added 4 commits March 17, 2026 21:57
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai merged commit 98be562 into main Mar 17, 2026
33 checks passed
@aibrahim-oai aibrahim-oai deleted the codex/realtime-end-core branch March 17, 2026 22:58
@github-actions github-actions bot locked and limited conversation to collaborators Mar 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants