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
+6
View File
@@ -1319,6 +1319,12 @@ impl CodexThread {
self.rollout_path.clone()
}
/// Whether the latest completed sampling request in this live context reported a removal.
/// Returns None before sampling or when that response omitted the report.
pub async fn last_sampling_cot_removed(&self) -> Option<bool> {
self.session.last_sampling_cot_removed().await
}
/// Selects a local feedback rollout without materializing an untouched thread.
pub async fn feedback_rollout_path(&self) -> ThreadStoreResult<Option<PathBuf>> {
match self.session.live_thread() {
+4
View File
@@ -1744,6 +1744,10 @@ impl Session {
state.token_info()
}
pub(crate) async fn last_sampling_cot_removed(&self) -> Option<bool> {
self.state.lock().await.last_sampling_cot_removed
}
pub(crate) async fn get_estimated_token_count(
&self,
turn_context: &TurnContext,
+3 -1
View File
@@ -3742,7 +3742,7 @@ async fn try_run_sampling_request(
response_id,
token_usage,
usage_metadata,
reasoning_removals: _,
reasoning_removals,
end_turn,
} => {
let retry_prompt = resampling.finish_response(end_turn, token_usage.is_some());
@@ -3754,6 +3754,8 @@ async fn try_run_sampling_request(
)
.await;
}
sess.state.lock().await.last_sampling_cot_removed =
reasoning_removals.as_ref().map(|counts| !counts.is_empty());
response_completed = true;
sess.services
.analytics_events_client
+3
View File
@@ -109,6 +109,7 @@ pub(crate) struct SessionState {
pub(crate) restored_turn_routing: Option<(String, Vec<String>)>,
/// Runtime accounting state for the active auto-compaction window.
auto_compact_window: AutoCompactWindow,
pub(crate) last_sampling_cot_removed: Option<bool>,
pub(crate) async_compaction: crate::session::async_compaction::AsyncCompactionState,
/// Original request effort for the current model while configuration updates remain active.
pub(crate) reasoning_effort_pin: ReasoningEffortPin,
@@ -155,6 +156,7 @@ impl SessionState {
history_reset: CancellationToken::new(),
latest_rate_limits: None,
latest_token_usage_record: None,
last_sampling_cot_removed: None,
mcp_dependency_prompted: HashSet::new(),
additional_context: AdditionalContextStore::default(),
previous_turn_settings: None,
@@ -229,6 +231,7 @@ impl SessionState {
reference_context_item: Option<TurnContextItem>,
replacement: HistoryReplacement,
) {
self.last_sampling_cot_removed = None;
let invalidate_reviews = match replacement {
HistoryReplacement::Compaction {
reviewer_compaction_hash,