mirror of
https://github.com/openai/codex.git
synced 2026-04-28 08:34:54 +00:00
feat(analytics): generate an installation_id and pass it in responsesapi client_metadata (#16912)
## Summary This adds a stable Codex installation ID and includes it on Responses API requests via `x-codex-installation-id` passed in via the `client_metadata` field for analytics/debugging. The main pieces are: - persist a UUID in `$CODEX_HOME/installation_id` - thread the installation ID into `ModelClient` - send it in `client_metadata` on Responses requests so it works consistently across HTTP and WebSocket transports
This commit is contained in:
@@ -31,6 +31,8 @@ fn normalize_git_remote_url(url: &str) -> String {
|
||||
.to_string()
|
||||
}
|
||||
|
||||
const TEST_INSTALLATION_ID: &str = "11111111-1111-4111-8111-111111111111";
|
||||
|
||||
#[tokio::test]
|
||||
async fn responses_stream_includes_subagent_header_on_review() {
|
||||
core_test_support::skip_if_no_network!();
|
||||
@@ -98,6 +100,7 @@ async fn responses_stream_includes_subagent_header_on_review() {
|
||||
let client = ModelClient::new(
|
||||
/*auth_manager*/ None,
|
||||
conversation_id,
|
||||
/*installation_id*/ TEST_INSTALLATION_ID.to_string(),
|
||||
provider.clone(),
|
||||
session_source,
|
||||
config.model_verbosity,
|
||||
@@ -147,6 +150,10 @@ async fn responses_stream_includes_subagent_header_on_review() {
|
||||
Some(expected_window_id.as_str())
|
||||
);
|
||||
assert_eq!(request.header("x-codex-parent-thread-id"), None);
|
||||
assert_eq!(
|
||||
request.body_json()["client_metadata"]["x-codex-installation-id"].as_str(),
|
||||
Some(TEST_INSTALLATION_ID)
|
||||
);
|
||||
assert_eq!(request.header("x-codex-sandbox"), None);
|
||||
}
|
||||
|
||||
@@ -218,6 +225,7 @@ async fn responses_stream_includes_subagent_header_on_other() {
|
||||
let client = ModelClient::new(
|
||||
/*auth_manager*/ None,
|
||||
conversation_id,
|
||||
/*installation_id*/ TEST_INSTALLATION_ID.to_string(),
|
||||
provider.clone(),
|
||||
session_source,
|
||||
config.model_verbosity,
|
||||
@@ -331,6 +339,7 @@ async fn responses_respects_model_info_overrides_from_config() {
|
||||
let client = ModelClient::new(
|
||||
/*auth_manager*/ None,
|
||||
conversation_id,
|
||||
/*installation_id*/ TEST_INSTALLATION_ID.to_string(),
|
||||
provider.clone(),
|
||||
session_source,
|
||||
config.model_verbosity,
|
||||
|
||||
Reference in New Issue
Block a user