Skip to content

Record realtime close marker on replacement#13058

Open
aibrahim-oai wants to merge 9 commits intomainfrom
ibrahim/realtime-replace-close-marker
Open

Record realtime close marker on replacement#13058
aibrahim-oai wants to merge 9 commits intomainfrom
ibrahim/realtime-replace-close-marker

Conversation

@aibrahim-oai
Copy link
Collaborator

@aibrahim-oai aibrahim-oai commented Feb 27, 2026

Summary

  • record a realtime close developer message when a new realtime session replaces an active one
  • assert the replacement marker through the mocked responses request path

@charley-oai
Copy link
Collaborator

@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: fde5bb62aa

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

pub(crate) async fn handle_close(sess: &Arc<Session>, sub_id: String) {
match sess.conversation.shutdown().await {
Ok(()) => {
record_realtime_end_developer_message(sess, &sub_id, "requested").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 Skip end-marker writes when no realtime session is active

handle_close now always records a requested realtime end developer message on any successful shutdown(). But shutdown() returns Ok(()) even when no conversation is running, so duplicate/stray close ops will inject a false "realtime ended" instruction into history and affect later model requests.

Useful? React with 👍 / 👎.

Comment on lines 273 to 275
if let Some(()) = sess_clone.conversation.running_state().await {
info!("realtime conversation transport closed");
record_realtime_end_developer_message(&sess_clone, &sub_id, "transport_closed").await;
Copy link
Contributor

Choose a reason for hiding this comment

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

P2 Badge Tie transport-close marker to the originating session

The spawned event-forwarding task checks only global running_state() before recording transport_closed. During session replacement, an old task can exit after a new session is installed, see running_state == Some, and write a spurious close marker for the replacement path. This races and can add incorrect developer instructions.

Useful? React with 👍 / 👎.

Copy link
Collaborator

@charley-oai charley-oai left a comment

Choose a reason for hiding this comment

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

Hmm does this realtime conversation state need to be recorded in TurnContext / TurnContextItem so that it can be properly handled by our new compaction/resume/backtracking logic? I think all model visible state should be handled similarly right?

aibrahim-oai and others added 5 commits February 27, 2026 17:26
Ensure replaced realtime sessions write the closing developer message and cover it through the mocked responses request.\n\nCo-authored-by: Codex <noreply@openai.com>
Restore the existing replacement runtime test and add a separate request-level integration test using the shared response mock helpers.\n\nCo-authored-by: Codex <noreply@openai.com>
Align the realtime start and end prompts with the intermediary backend-executor framing without naming the backend directly.\n\nCo-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai force-pushed the ibrahim/realtime-replace-close-marker branch from d43d8d2 to da467b0 Compare February 28, 2026 01:34
aibrahim-oai and others added 2 commits February 27, 2026 18:10
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@charley-oai
Copy link
Collaborator

@codex review this

Co-authored-by: Codex <noreply@openai.com>
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: ea82d5956f

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

Replace previous_model with previous_turn_settings, read turn baselines from session state in initial and steady-state context updates, add remote compaction coverage for realtime transition reinjection, and fix synthetic TurnContextItem initializers for the new realtime_active field.

Co-authored-by: Codex <noreply@openai.com>
@charley-oai charley-oai force-pushed the ibrahim/realtime-replace-close-marker branch from 065e8d1 to 60b3bc9 Compare February 28, 2026 07:28
@charley-oai
Copy link
Collaborator

@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: 60b3bc944d

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

Copy link
Collaborator

@charley-oai charley-oai left a comment

Choose a reason for hiding this comment

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

Made some changes to fix edge cases of realtime true -> false (but reference_context_item set to none by compaction), I think this previous_turn_settings object will be useful in the future to have as a scratch space for any useful settings to carry over from the previous user turn (protected from being set to None by compaction, unlike reference_turn_context)

A nice-to-have followup PR would allow model-visible state changes even within a single turn (this is useful both for this realtime setting and e.g. changing permissions mid turn), but that's out of scope for this PR

@@ -0,0 +1,5 @@
Realtime conversation ended.

You are still operating behind an intermediary rather than speaking to the user directly. Use the conversation transcript and current context to decide whether backend help is actually needed, and avoid verbose responses that only add latency.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm is it true that after realtime ends the model is still not speaking to the user directly? Is it impossible to return to a normal codex session after turning on/off realtime mode?

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