mirror of
https://github.com/openai/codex.git
synced 2026-09-15 12:08:01 +00:00
Reset websocket turn state on recon−
This commit is contained in:
@@ -522,6 +522,17 @@ impl ModelClient {
|
||||
|
||||
fn set_shared_v2_connection(&self, connection: Option<Arc<ApiWebSocketConnection>>) {
|
||||
self.with_shared_v2_state(|state| {
|
||||
let connection_changed = match (&state.connection, &connection) {
|
||||
(Some(existing), Some(new_connection)) => !Arc::ptr_eq(existing, new_connection),
|
||||
(None, Some(_)) | (Some(_), None) => true,
|
||||
(None, None) => false,
|
||||
};
|
||||
if connection_changed {
|
||||
// Response chaining state is scoped to a single backend websocket connection.
|
||||
// When the connection changes, start the next request as a full create.
|
||||
state.websocket_last_items.clear();
|
||||
state.websocket_last_response_id = None;
|
||||
}
|
||||
state.connection = connection;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -221,9 +221,14 @@ async fn websocket_v2_reconnect_after_turn_boundary_does_not_replay_turn_state()
|
||||
.first()
|
||||
.expect("second websocket connection should have a request")
|
||||
.body_json();
|
||||
assert_eq!(
|
||||
second_request["previous_response_id"].as_str(),
|
||||
Some("resp-1")
|
||||
assert_eq!(second_request.get("previous_response_id"), None);
|
||||
let second_input_len = second_request["input"]
|
||||
.as_array()
|
||||
.map(Vec::len)
|
||||
.unwrap_or(0);
|
||||
assert!(
|
||||
second_input_len > 1,
|
||||
"reconnect should send full input items, got {second_input_len}"
|
||||
);
|
||||
|
||||
server.shutdown().await;
|
||||
|
||||
Reference in New Issue
Block a user