mirror of
https://github.com/openai/codex.git
synced 2026-11-21 22:50:37 +00:00
Tag user reports with the latest reasoning removal status (#62883)
## What changed Set the `cot_removed` tag from the latest completed sampling request on the live thread. Use `true` for reported reasoning removals and `false` for an explicitly empty report. Omit the tag when no report is available and discard any caller-supplied value. Clear the stored result when thread history is replaced. A resumed session starts without a stored result. ## Testing Cover tag values in saved reports across tool calls, compaction, and session resume. Verify that failed compaction preserves the last sampling result. GitOrigin-RevId: f1568567a6b4a62685569478fc7194f4357cb605
This commit is contained in:
@@ -128,6 +128,13 @@ impl FeedbackRequestProcessor {
|
||||
|
||||
let http_client_factory = self.config.http_client_factory();
|
||||
let auth = self.auth_manager.auth_cached();
|
||||
upload_tags.remove("cot_removed");
|
||||
if let Some(id) = conversation_id
|
||||
&& let Ok(thread) = self.thread_manager.get_thread(id).await
|
||||
&& let Some(removed) = thread.last_sampling_cot_removed().await
|
||||
{
|
||||
upload_tags.insert("cot_removed".to_string(), removed.to_string());
|
||||
}
|
||||
let turn_metadata = if let Some(conversation_id) = conversation_id
|
||||
&& let Some(rollout_path) = self
|
||||
.resolve_rollout_path(conversation_id, self.state_db.as_ref(), save_path.as_ref())
|
||||
|
||||
@@ -11,6 +11,104 @@ use tokio::io::BufReader;
|
||||
use tokio::net::TcpListener;
|
||||
use tokio::time::timeout;
|
||||
|
||||
#[tokio::test]
|
||||
async fn feedback_reports_cot_removal_from_latest_completed_sampling_request() -> Result<()> {
|
||||
use core_test_support::responses;
|
||||
|
||||
let server = responses::start_mock_server().await;
|
||||
let removed =
|
||||
json!([{"type":"reasoning", "id":"rs-1", "action":"removed", "reason":"prefix_mismatch"}]);
|
||||
let streams = [
|
||||
("drop", Some(removed.clone())),
|
||||
("replayed", Some(removed.clone())),
|
||||
("tool", Some(removed.clone())),
|
||||
("clean", Some(json!([]))),
|
||||
("unreported", None),
|
||||
("before_compaction", Some(removed.clone())),
|
||||
("summary", Some(removed.clone())),
|
||||
("after", Some(removed)),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(id, transformations)| {
|
||||
let mut completed = responses::ev_completed(id);
|
||||
if let Some(transformations) = transformations {
|
||||
completed["response"]["input_transformations"] = transformations;
|
||||
}
|
||||
// The tool call and clean final response belong to the same user turn.
|
||||
let output = if id == "tool" {
|
||||
responses::ev_function_call("call", "unknown_test_tool", "{}")
|
||||
} else {
|
||||
responses::ev_assistant_message(&format!("msg-{id}"), id)
|
||||
};
|
||||
responses::sse(vec![output, completed])
|
||||
})
|
||||
.collect();
|
||||
responses::mount_sse_sequence(&server, streams).await;
|
||||
let home = tempfile::tempdir()?;
|
||||
app_test_support::MockResponsesConfig::new(&server.uri()).write(home.path())?;
|
||||
app_test_support::write_models_cache(home.path()).await?;
|
||||
let mut app = TestAppServer::builder()
|
||||
.with_codex_home(home.path())
|
||||
.build_initialized()
|
||||
.await?;
|
||||
let thread = app.start_thread(Default::default()).await?.thread;
|
||||
for (step, expected) in [
|
||||
("drop", Some("true")),
|
||||
("replayed", Some("true")),
|
||||
("tool_then_clean", Some("false")),
|
||||
("unreported", None),
|
||||
("before_compaction", Some("true")),
|
||||
("compact", None),
|
||||
("after", Some("true")),
|
||||
("resume", None),
|
||||
] {
|
||||
let mut params = json!({"threadId": thread.id});
|
||||
let method = match step {
|
||||
"compact" => "thread/compact/start",
|
||||
"resume" => {
|
||||
app.shutdown_gracefully().await?;
|
||||
app = TestAppServer::builder()
|
||||
.with_codex_home(home.path())
|
||||
.build_initialized()
|
||||
.await?;
|
||||
"thread/resume"
|
||||
}
|
||||
text => {
|
||||
params["input"] = json!([{"type": "text", "text": text}]);
|
||||
"turn/start"
|
||||
}
|
||||
};
|
||||
let id = app.send_raw_request(method, Some(params)).await?;
|
||||
app.read_response::<serde_json::Value>(id).await?;
|
||||
if matches!(method, "turn/start" | "thread/compact/start") {
|
||||
app.read_stream_until_notification_message("turn/completed")
|
||||
.await?;
|
||||
}
|
||||
|
||||
let destination = home.path().join(format!("{step}.zip"));
|
||||
let id = app
|
||||
.send_raw_request(
|
||||
"feedback/save",
|
||||
Some(json!({
|
||||
"classification": "bad_result",
|
||||
"threadId": thread.id,
|
||||
"tags": {"cot_removed": "untrusted"},
|
||||
"savePath": destination,
|
||||
})),
|
||||
)
|
||||
.await?;
|
||||
app.read_response::<serde_json::Value>(id).await?;
|
||||
let mut archive = zip::ZipArchive::new(std::fs::File::open(destination)?)?;
|
||||
let report: serde_json::Value = serde_json::from_reader(archive.by_name("report.json")?)?;
|
||||
assert_eq!(
|
||||
report["tags"].get("cot_removed").cloned(),
|
||||
expected.map(serde_json::Value::from),
|
||||
"after {step}"
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn feedback_upload_limits_concurrency_and_releases_failed_uploads() -> Result<()> {
|
||||
let proxy = TcpListener::bind("127.0.0.1:0").await?;
|
||||
|
||||
Reference in New Issue
Block a user