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:
Alex Kira
2026-11-21 01:30:29 +00:00
committed by copyberry
parent bb1037ba04
commit 619d36f810
7 changed files with 132 additions and 5 deletions
+11 -4
View File
@@ -475,13 +475,15 @@ async fn remote_compact_v2_records_usage_before_output_validation() -> Result<()
.await?;
let codex = &harness.test().codex;
let rollout_path = codex.rollout_path().context("rollout path")?;
let mut sample =
responses::ev_completed_with_tokens("before-compact", /*total_tokens*/ 500);
sample["response"]["input_transformations"] = json!([{
"type": "reasoning", "id": "rs-1", "action": "removed", "reason": "prefix_mismatch",
}]);
let responses_mock = responses::mount_sse_sequence(
harness.server(),
vec![
sse(vec![responses::ev_completed_with_tokens(
"before-compact",
/*total_tokens*/ 500,
)]),
sse(vec![sample]),
sse(vec![
json!({
"type": "response.output_item.done",
@@ -540,6 +542,11 @@ async fn remote_compact_v2_records_usage_before_output_validation() -> Result<()
1,
"the accepted prompt should be saved exactly once after compaction fails"
);
assert_eq!(
codex.last_sampling_cot_removed().await,
Some(true),
"a failed compaction should preserve the last sampling report",
);
codex.shutdown_and_wait().await?;
let record = fs::read_to_string(&rollout_path)?