mirror of
https://github.com/openai/codex.git
synced 2026-05-02 04:11:39 +03:00
Record realtime close marker on replacement (#13058)
## 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 --------- Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Charles Cunningham <ccunningham@openai.com>
This commit is contained in:
@@ -14,6 +14,8 @@ use crate::protocol::AskForApproval;
|
||||
use crate::protocol::COLLABORATION_MODE_CLOSE_TAG;
|
||||
use crate::protocol::COLLABORATION_MODE_OPEN_TAG;
|
||||
use crate::protocol::NetworkAccess;
|
||||
use crate::protocol::REALTIME_CONVERSATION_CLOSE_TAG;
|
||||
use crate::protocol::REALTIME_CONVERSATION_OPEN_TAG;
|
||||
use crate::protocol::SandboxPolicy;
|
||||
use crate::protocol::WritableRoot;
|
||||
use crate::user_input::UserInput;
|
||||
@@ -340,6 +342,9 @@ const SANDBOX_MODE_WORKSPACE_WRITE: &str =
|
||||
include_str!("prompts/permissions/sandbox_mode/workspace_write.md");
|
||||
const SANDBOX_MODE_READ_ONLY: &str = include_str!("prompts/permissions/sandbox_mode/read_only.md");
|
||||
|
||||
const REALTIME_START_INSTRUCTIONS: &str = include_str!("prompts/realtime/realtime_start.md");
|
||||
const REALTIME_END_INSTRUCTIONS: &str = include_str!("prompts/realtime/realtime_end.md");
|
||||
|
||||
impl DeveloperInstructions {
|
||||
pub fn new<T: Into<String>>(text: T) -> Self {
|
||||
Self { text: text.into() }
|
||||
@@ -409,6 +414,20 @@ impl DeveloperInstructions {
|
||||
))
|
||||
}
|
||||
|
||||
pub fn realtime_start_message() -> Self {
|
||||
DeveloperInstructions::new(format!(
|
||||
"{REALTIME_CONVERSATION_OPEN_TAG}\n{}\n{REALTIME_CONVERSATION_CLOSE_TAG}",
|
||||
REALTIME_START_INSTRUCTIONS.trim()
|
||||
))
|
||||
}
|
||||
|
||||
pub fn realtime_end_message(reason: &str) -> Self {
|
||||
DeveloperInstructions::new(format!(
|
||||
"{REALTIME_CONVERSATION_OPEN_TAG}\n{}\n\nReason: {reason}\n{REALTIME_CONVERSATION_CLOSE_TAG}",
|
||||
REALTIME_END_INSTRUCTIONS.trim()
|
||||
))
|
||||
}
|
||||
|
||||
pub fn personality_spec_message(spec: String) -> Self {
|
||||
let message = format!(
|
||||
"<personality_spec> The user has requested a new communication style. Future messages should adhere to the following personality: \n{spec} </personality_spec>"
|
||||
|
||||
5
codex-rs/protocol/src/prompts/realtime/realtime_end.md
Normal file
5
codex-rs/protocol/src/prompts/realtime/realtime_end.md
Normal file
@@ -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.
|
||||
|
||||
Subsequent user input may return to typed text rather than transcript-style text. Do not assume recognition errors or missing punctuation once realtime has ended. Resume normal chat behavior.
|
||||
10
codex-rs/protocol/src/prompts/realtime/realtime_start.md
Normal file
10
codex-rs/protocol/src/prompts/realtime/realtime_start.md
Normal file
@@ -0,0 +1,10 @@
|
||||
Realtime conversation started.
|
||||
|
||||
You are operating as a backend executor behind an intermediary. The user does not talk to you directly. Any response you produce will be consumed by the intermediary and may be summarized before the user sees it.
|
||||
|
||||
When invoked, you receive the latest conversation transcript and any relevant mode or metadata. The intermediary may invoke you even when backend help is not actually needed. Use the transcript to decide whether you should do work. If backend help is unnecessary, avoid verbose responses that add user-visible latency.
|
||||
|
||||
When user text is routed from realtime, treat it as a transcript. It may be unpunctuated or contain recognition errors.
|
||||
|
||||
- Ask brief clarification questions when needed.
|
||||
- Keep responses concise and action-oriented.
|
||||
@@ -70,6 +70,8 @@ pub const ENVIRONMENT_CONTEXT_OPEN_TAG: &str = "<environment_context>";
|
||||
pub const ENVIRONMENT_CONTEXT_CLOSE_TAG: &str = "</environment_context>";
|
||||
pub const COLLABORATION_MODE_OPEN_TAG: &str = "<collaboration_mode>";
|
||||
pub const COLLABORATION_MODE_CLOSE_TAG: &str = "</collaboration_mode>";
|
||||
pub const REALTIME_CONVERSATION_OPEN_TAG: &str = "<realtime_conversation>";
|
||||
pub const REALTIME_CONVERSATION_CLOSE_TAG: &str = "</realtime_conversation>";
|
||||
pub const USER_MESSAGE_BEGIN: &str = "## My request for Codex:";
|
||||
|
||||
/// Submission Queue Entry - requests from user
|
||||
@@ -2146,6 +2148,8 @@ pub struct TurnContextItem {
|
||||
pub personality: Option<Personality>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub collaboration_mode: Option<CollaborationMode>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub realtime_active: Option<bool>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub effort: Option<ReasoningEffortConfig>,
|
||||
pub summary: ReasoningSummaryConfig,
|
||||
@@ -3376,6 +3380,7 @@ mod tests {
|
||||
model: "gpt-5".to_string(),
|
||||
personality: None,
|
||||
collaboration_mode: None,
|
||||
realtime_active: None,
|
||||
effort: None,
|
||||
summary: ReasoningSummaryConfig::Auto,
|
||||
user_instructions: None,
|
||||
|
||||
Reference in New Issue
Block a user