Track history notes thread hint outcomes (#42247)

## What changed

- Emit a `codex_thread_hint_status` analytics event for each native history-notes thread hint attempt.
- Report whether retrieval was successful or failed along with thread context and timing, without including hint contents.
- Treat valid empty responses as successful retrievals while continuing to omit them from the context window.

## Testing

- Extend the app-server history-notes tests to verify success, empty-result success, and backend failure statuses.

GitOrigin-RevId: b9462f312847e8c871ed2be0c8cf8df0928a7fdd
This commit is contained in:
pmccrary-oai authored and copyberry committed 2026-09-02 09:12:17 +00:00
1 parent eb10d91e48
commit bdfd769640
10 files changed
+118 -10

No files matched your search

@@ -1,14 +1,11 @@
use std::time::Duration;
use anyhow::Result;
use app_test_support::ChatGptAuthFixture;
use app_test_support::MockResponsesConfig;
use app_test_support::TestAppServer;
use app_test_support::write_chatgpt_auth;
use codex_app_server_protocol::ThreadStartParams;
use codex_app_server_protocol::TurnStartParams;
use codex_app_server_protocol::UserInput;
use codex_config::types::AuthCredentialsStoreMode;
use core_test_support::load_default_config_for_test;
use core_test_support::responses;
use pretty_assertions::assert_eq;
@@ -116,6 +113,7 @@ async fn app_server_uses_configured_notes_backend_for_context_window_hints(
let codex_home = TempDir::new()?;
MockResponsesConfig::new(&server.uri())
.with_root_config(&format!("chatgpt_base_url = \"{}\"", server.uri()))
.with_model_provider("openai-custom")
.with_provider_name("OpenAI")
.with_provider_base_url(&format!("{}/backend-api/codex", server.uri()))
@@ -125,11 +123,7 @@ async fn app_server_uses_configured_notes_backend_for_context_window_hints(
server.uri(),
))
.write(codex_home.path())?;
write_chatgpt_auth(
codex_home.path(),
ChatGptAuthFixture::new("access-chatgpt"),
AuthCredentialsStoreMode::File,
)?;
mount_analytics_capture(&server, codex_home.path()).await?;
let mut app_server = TestAppServer::builder()
.with_codex_home(codex_home.path())
@@ -143,7 +137,7 @@ async fn app_server_uses_configured_notes_backend_for_context_window_hints(
timeout(
Duration::from_secs(10),
app_server.start_turn_and_wait_for_completion(TurnStartParams {
thread_id: thread.id,
thread_id: thread.id.clone(),
input: vec![UserInput::Text {
text: "inspect history and notes".to_string(),
text_elements: Vec::new(),
@@ -218,6 +212,22 @@ async fn app_server_uses_configured_notes_backend_for_context_window_hints(
&& item["name"] == "thread_hint"
}));
if use_history_notes_extension {
let event = wait_for_matching_analytics_event(&server, DEFAULT_READ_TIMEOUT, |event| {
event["event_type"] == "codex_thread_hint_status"
&& event["event_params"]["thread_id"] == thread.id
})
.await?;
assert_eq!(
event["event_params"]["status"],
if hint_status == 200 {
"succeeded"
} else {
"failed"
},
);
}
Ok(())
}