include sandbox (seatbelt, elevated, etc.) as in turn metadata header (#10946)

This will help us understand retention/usage for folks who use the
Windows (or any other) sandboxes
This commit is contained in:
iceweasel-oai
2026-02-10 11:50:07 -08:00
committed by GitHub
parent 62d0f302fd
commit 82f93a13b2
6 changed files with 106 additions and 75 deletions

View File

@@ -126,6 +126,7 @@ async fn responses_stream_includes_subagent_header_on_review() {
request.header("x-openai-subagent").as_deref(),
Some("review")
);
assert_eq!(request.header("x-codex-sandbox"), None);
}
#[tokio::test]
@@ -366,11 +367,17 @@ async fn responses_stream_includes_turn_metadata_header_for_git_workspace_e2e()
test.submit_turn("hello")
.await
.expect("submit first turn prompt");
let initial_header = first_request
.single_request()
.header("x-codex-turn-metadata")
.expect("x-codex-turn-metadata header should be present");
let initial_parsed: serde_json::Value =
serde_json::from_str(&initial_header).expect("x-codex-turn-metadata should be valid JSON");
assert_eq!(
first_request
.single_request()
.header("x-codex-turn-metadata"),
None
initial_parsed
.get("sandbox")
.and_then(serde_json::Value::as_str),
Some("none")
);
let git_config_global = cwd.join("empty-git-config");
@@ -423,43 +430,48 @@ async fn responses_stream_includes_turn_metadata_header_for_git_workspace_e2e()
.await
.expect("submit post-git turn prompt");
let maybe_header = request_recorder
let maybe_metadata = request_recorder
.single_request()
.header("x-codex-turn-metadata");
if let Some(header_value) = maybe_header {
let parsed: serde_json::Value = serde_json::from_str(&header_value)
.expect("x-codex-turn-metadata should be valid JSON");
let workspaces = parsed
.get("workspaces")
.and_then(serde_json::Value::as_object)
.expect("metadata should include workspaces");
let workspace = workspaces
.values()
.next()
.expect("metadata should include at least one workspace entry");
assert_eq!(
workspace
.get("latest_git_commit_hash")
.and_then(serde_json::Value::as_str),
Some(expected_head.as_str())
);
assert_eq!(
workspace
.get("associated_remote_urls")
.header("x-codex-turn-metadata")
.and_then(|header_value| {
let parsed: serde_json::Value = serde_json::from_str(&header_value).ok()?;
let workspace = parsed
.get("workspaces")
.and_then(serde_json::Value::as_object)
.and_then(|remotes| remotes.get("origin"))
.and_then(serde_json::Value::as_str),
Some(expected_origin.as_str())
);
return;
}
.and_then(|workspaces| workspaces.values().next())
.cloned()?;
Some((parsed, workspace))
});
let Some((parsed, workspace)) = maybe_metadata else {
if tokio::time::Instant::now() >= deadline {
break;
}
tokio::time::sleep(std::time::Duration::from_millis(25)).await;
continue;
};
if tokio::time::Instant::now() >= deadline {
break;
}
tokio::time::sleep(std::time::Duration::from_millis(25)).await;
assert_eq!(
parsed.get("sandbox").and_then(serde_json::Value::as_str),
Some("none")
);
assert_eq!(
workspace
.get("latest_git_commit_hash")
.and_then(serde_json::Value::as_str),
Some(expected_head.as_str())
);
assert_eq!(
workspace
.get("associated_remote_urls")
.and_then(serde_json::Value::as_object)
.and_then(|remotes| remotes.get("origin"))
.and_then(serde_json::Value::as_str),
Some(expected_origin.as_str())
);
return;
}
panic!("x-codex-turn-metadata was never observed within 5s after git setup");
panic!(
"x-codex-turn-metadata with git workspace info was never observed within 5s after git setup"
);
}