[codex] Remove remote compaction failure log (#27106)

## Why

`log_remote_compact_failure` was the only consumer of the
compact-request logging payload and most of the token-usage breakdown
fields. Once that failure log is removed, keeping the surrounding
carrier types leaves dead plumbing in the compaction path and context
manager.

## What changed

- Remove `log_remote_compact_failure`, `CompactRequestLogData`, and the
v2 wrapper that only fed that log.
- Let both remote compaction implementations return the original
compaction error directly.
- Replace `TotalTokenUsageBreakdown` with a narrow helper that returns
only the remaining value needed by compaction analytics.
- Keep `estimate_response_item_model_visible_bytes` private to the
context manager implementation.

## Validation

- `cargo check -p codex-core`
This commit is contained in:
pakrym-oai
2026-06-08 19:23:35 -07:00
committed by GitHub
parent 0beb5c7f32
commit 08cb633c06
5 changed files with 17 additions and 132 deletions
+6 -35
View File
@@ -50,14 +50,6 @@ pub(crate) struct ContextManager {
reference_context_item: Option<TurnContextItem>,
}
#[derive(Debug, Clone, Copy, Default)]
pub(crate) struct TotalTokenUsageBreakdown {
pub last_api_response_total_tokens: i64,
pub all_history_items_model_visible_bytes: i64,
pub estimated_tokens_of_items_added_since_last_successful_api_response: i64,
pub estimated_bytes_of_items_added_since_last_successful_api_response: i64,
}
impl ContextManager {
pub(crate) fn new() -> Self {
Self {
@@ -321,32 +313,11 @@ impl ContextManager {
}
}
pub(crate) fn get_total_token_usage_breakdown(&self) -> TotalTokenUsageBreakdown {
let last_usage = self
.token_info
.as_ref()
.map(|info| info.last_token_usage.clone())
.unwrap_or_default();
let items_after_last_model_generated = self.items_after_last_model_generated_item();
TotalTokenUsageBreakdown {
last_api_response_total_tokens: last_usage.total_tokens,
all_history_items_model_visible_bytes: self
.items
.iter()
.map(estimate_response_item_model_visible_bytes)
.fold(0i64, i64::saturating_add),
estimated_tokens_of_items_added_since_last_successful_api_response:
items_after_last_model_generated
.iter()
.map(estimate_item_token_count)
.fold(0i64, i64::saturating_add),
estimated_bytes_of_items_added_since_last_successful_api_response:
items_after_last_model_generated
.iter()
.map(estimate_response_item_model_visible_bytes)
.fold(0i64, i64::saturating_add),
}
pub(crate) fn estimated_tokens_after_last_model_generated_item(&self) -> i64 {
self.items_after_last_model_generated_item()
.iter()
.map(estimate_item_token_count)
.fold(0i64, i64::saturating_add)
}
/// This function enforces a couple of invariants on the in-memory history:
@@ -532,7 +503,7 @@ static ORIGINAL_IMAGE_ESTIMATE_CACHE: LazyLock<BlockingLruCache<[u8; 20], Option
)
});
pub(crate) fn estimate_response_item_model_visible_bytes(item: &ResponseItem) -> i64 {
fn estimate_response_item_model_visible_bytes(item: &ResponseItem) -> i64 {
match item {
ResponseItem::Reasoning {
encrypted_content: Some(content),
-2
View File
@@ -3,7 +3,5 @@ mod normalize;
pub(crate) mod updates;
pub(crate) use history::ContextManager;
pub(crate) use history::TotalTokenUsageBreakdown;
pub(crate) use history::estimate_response_item_model_visible_bytes;
pub(crate) use history::is_user_turn_boundary;
pub(crate) use history::truncate_function_output_payload;