Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Added deprecation notice for "chat" wire_api (#7897)

Eric Traut43e6e75317bf
diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs
index e23e03298d..c546bb583e 100644
--- a/codex-rs/core/src/codex.rs
+++ b/codex-rs/core/src/codex.rs
@@ -2,7 +2,9 @@ use std::collections::HashMap;
use std::fmt::Debug;
use std::path::PathBuf;
use std::sync::Arc;
+use std::sync::atomic::AtomicBool;
use std::sync::atomic::AtomicU64;
+use std::sync::atomic::Ordering;
use crate::AuthManager;
use crate::SandboxState;
@@ -65,6 +67,7 @@ use tracing::info;
use tracing::warn;
use crate::ModelProviderInfo;
+use crate::WireApi;
use crate::client::ModelClient;
use crate::client_common::Prompt;
use crate::client_common::ResponseEvent;
@@ -80,6 +83,7 @@ use crate::exec::StreamOutput;
use crate::exec_policy::ExecPolicyUpdateError;
use crate::mcp::auth::compute_auth_statuses;
use crate::mcp_connection_manager::McpConnectionManager;
+use crate::model_provider_info::CHAT_WIRE_API_DEPRECATION_SUMMARY;
use crate::project_doc::get_user_instructions;
use crate::protocol::AgentMessageContentDeltaEvent;
use crate::protocol::AgentReasoningSectionBreakEvent;
@@ -167,6 +171,31 @@ pub struct CodexSpawnOk {
pub(crate) const INITIAL_SUBMIT_ID: &str = "";
pub(crate) const SUBMISSION_CHANNEL_CAPACITY: usize = 64;
+static CHAT_WIRE_API_DEPRECATION_EMITTED: AtomicBool = AtomicBool::new(false);
+
+fn maybe_push_chat_wire_api_deprecation(
+ config: &Config,
+ post_session_configured_events: &mut Vec<Event>,
+) {
+ if config.model_provider.wire_api != WireApi::Chat {
+ return;
+ }
+
+ if CHAT_WIRE_API_DEPRECATION_EMITTED
+ .compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst)
+ .is_err()
+ {
+ return;
+ }
+
+ post_session_configured_events.push(Event {
+ id: INITIAL_SUBMIT_ID.to_owned(),
+ msg: EventMsg::DeprecationNotice(DeprecationNoticeEvent {
+ summary: CHAT_WIRE_API_DEPRECATION_SUMMARY.to_string(),
+ details: None,
+ }),
+ });
+}
impl Codex {
/// Spawn a new [`Codex`] and initialize the session.
@@ -584,6 +613,7 @@ impl Session {
msg: EventMsg::DeprecationNotice(DeprecationNoticeEvent { summary, details }),
});
}
+ maybe_push_chat_wire_api_deprecation(&config, &mut post_session_configured_events);
// todo(aibrahim): why are we passing model here while it can change?
let otel_event_manager = OtelEventManager::new(
diff --git a/codex-rs/core/src/lib.rs b/codex-rs/core/src/lib.rs
index f69e7b8fb1..11b49c78c4 100644
--- a/codex-rs/core/src/lib.rs
+++ b/codex-rs/core/src/lib.rs
@@ -49,6 +49,7 @@ pub mod token_data;
mod truncate;
mod unified_exec;
mod user_instructions;
+pub use model_provider_info::CHAT_WIRE_API_DEPRECATION_SUMMARY;
pub use model_provider_info::DEFAULT_LMSTUDIO_PORT;
pub use model_provider_info::DEFAULT_OLLAMA_PORT;
pub use model_provider_info::LMSTUDIO_OSS_PROVIDER_ID;
diff --git a/codex-rs/core/src/model_provider_info.rs b/codex-rs/core/src/model_provider_info.rs
index aa86501014..22f0d99984 100644
--- a/codex-rs/core/src/model_provider_info.rs
+++ b/codex-rs/core/src/model_provider_info.rs
@@ -26,6 +26,7 @@ const DEFAULT_REQUEST_MAX_RETRIES: u64 = 4;
const MAX_STREAM_MAX_RETRIES: u64 = 100;
/// Hard cap for user-configured `request_max_retries`.
const MAX_REQUEST_MAX_RETRIES: u64 = 100;
+pub const CHAT_WIRE_API_DEPRECATION_SUMMARY: &str = r#"Support for the "chat" wire API is deprecated and will soon be removed. Update your model provider definition in config.toml to use wire_api = "responses"."#;
/// Wire protocol that the provider speaks. Most third-party services only
/// implement the classic OpenAI Chat Completions JSON schema, whereas OpenAI