mirror of
https://github.com/openai/codex.git
synced 2026-10-28 18:58:46 +00:00
## Why When a local proxy request disconnects before network approval completes, the owning tool call needs a model-visible explanation instead of remaining tied to the abandoned request. ## What changed - Track disconnect timing while plain HTTP and CONNECT requests await policy decisions. - Cancel the owning execution and report how long the request waited when it disconnects before approval completes. - Preserve an explicit approval outcome when disconnect cleanup runs afterward. ## Testing Added unit coverage for disconnect tracking and outcome precedence, plus end-to-end coverage for plain HTTP and CONNECT requests. GitOrigin-RevId: b354b29bbe86f38e252fcaf529541f177480136b
42 lines
1.2 KiB
Rust
42 lines
1.2 KiB
Rust
use super::NetworkRequestDisconnect;
|
|
use pretty_assertions::assert_eq;
|
|
use std::future::pending;
|
|
use std::time::Duration;
|
|
use std::time::Instant;
|
|
|
|
#[tokio::test]
|
|
async fn disconnect_is_published_before_policy_cleanup() {
|
|
struct ObserveOnDrop(NetworkRequestDisconnect);
|
|
impl Drop for ObserveOnDrop {
|
|
fn drop(&mut self) {
|
|
assert!(self.0.elapsed().is_some());
|
|
}
|
|
}
|
|
|
|
let disconnect = NetworkRequestDisconnect::default();
|
|
let observer = ObserveOnDrop(disconnect.clone());
|
|
let started_at = Instant::now();
|
|
let decision = disconnect.track_http_request(started_at, async move {
|
|
let _observer = observer;
|
|
pending::<()>().await;
|
|
});
|
|
assert!(
|
|
tokio::time::timeout(Duration::from_millis(1), decision)
|
|
.await
|
|
.is_err()
|
|
);
|
|
assert!(disconnect.elapsed().expect("disconnect time") <= started_at.elapsed());
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn completed_policy_request_is_not_a_disconnect() {
|
|
let disconnect = NetworkRequestDisconnect::default();
|
|
assert_eq!(
|
|
disconnect
|
|
.track_http_request(Instant::now(), async { 42 })
|
|
.await,
|
|
42
|
|
);
|
|
assert_eq!(disconnect.elapsed(), None);
|
|
}
|