Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Add realtime wire trace logs (#17838)

Ahmed Ibrahim8b7d0e920186
diff --git a/codex-rs/codex-api/src/endpoint/realtime_call.rs b/codex-rs/codex-api/src/endpoint/realtime_call.rs
index 5f0ad35269..4d0bcfa7bf 100644
--- a/codex-rs/codex-api/src/endpoint/realtime_call.rs
+++ b/codex-rs/codex-api/src/endpoint/realtime_call.rs
@@ -119,6 +119,7 @@ impl<T: HttpTransport, A: AuthProvider> RealtimeCallClient<T, A> {
session_config: RealtimeSessionConfig,
extra_headers: HeaderMap,
) -> Result<RealtimeCallResponse, ApiError> {
+ trace!(target: "codex_api::realtime_websocket::wire", "realtime call request SDP: {sdp}");
// WebRTC can begin inference as soon as the peer connection comes up, so the initial
// session payload is sent with call creation. The sideband WebSocket still sends its normal
// session.update after it joins.
diff --git a/codex-rs/codex-api/src/endpoint/realtime_websocket/methods.rs b/codex-rs/codex-api/src/endpoint/realtime_websocket/methods.rs
index b1fd1ef75c..a6964e6614 100644
--- a/codex-rs/codex-api/src/endpoint/realtime_websocket/methods.rs
+++ b/codex-rs/codex-api/src/endpoint/realtime_websocket/methods.rs
@@ -45,6 +45,8 @@ use tracing::warn;
use tungstenite::protocol::WebSocketConfig;
use url::Url;
+const REALTIME_WIRE_LOG_TARGET: &str = "codex_api::realtime_websocket::wire";
+
struct WsStream {
tx_command: mpsc::Sender<WsCommand>,
pump_task: tokio::task::JoinHandle<()>,
@@ -351,6 +353,7 @@ impl RealtimeWebsocketWriter {
));
}
+ trace!(target: REALTIME_WIRE_LOG_TARGET, "realtime websocket request: {payload}");
self.stream
.send(Message::Text(payload.into()))
.await
@@ -384,6 +387,7 @@ impl RealtimeWebsocketEvents {
match msg {
Message::Text(text) => {
+ trace!(target: REALTIME_WIRE_LOG_TARGET, "realtime websocket event: {text}");
if let Some(mut event) = parse_realtime_event(&text, self.event_parser) {
self.update_active_transcript(&mut event).await;
debug!(?event, "realtime websocket parsed event");