[codex-analytics] Emit structured compaction codex errors (#27082)

## Summary
- replace raw compaction `error` analytics with `codex_error_kind` and
`codex_error_http_status_code`
- derive compaction error telemetry from `CodexErr` using the same
`CodexErrKind` mapping and HTTP status helper used by turn events
- remove the pre-compact hook stop reason from the internal compaction
outcome now that it is no longer emitted as raw analytics text

## Why
Compaction `error` was a raw `CodexErr::to_string()` value, which can
carry free-form provider or user-derived text. Structured Codex error
fields preserve useful low-cardinality telemetry without sending the raw
string.

## Validation
- `just fmt`
- `just test -p codex-analytics`
- `just test -p codex-core
compact::tests::build_token_limited_compacted_history_appends_summary_message`

Attempted `just test -p codex-core`; the changed crate compiled, but the
full target failed in unrelated environment-dependent tests such as
missing helper binaries and shell snapshot timeouts.
This commit is contained in:
rhan-oai authored and GitHub committed 2026-06-11 06:07:06 +00:00
1 parent b5a718ef67
commit 8d9f33c87c
8 files changed
+52 -35

No files matched your search

+4 -2
View File
@@ -762,7 +762,8 @@ pub(crate) struct CodexCompactionEventParams {
pub(crate) phase: CompactionPhase,
pub(crate) strategy: CompactionStrategy,
pub(crate) status: CompactionStatus,
pub(crate) error: Option<String>,
pub(crate) codex_error_kind: Option<CodexErrKind>,
pub(crate) codex_error_http_status_code: Option<u16>,
pub(crate) active_context_tokens_before: i64,
pub(crate) active_context_tokens_after: i64,
pub(crate) retained_image_count: Option<usize>,
@@ -1000,7 +1001,8 @@ pub(crate) fn codex_compaction_event_params(
phase: input.phase,
strategy: input.strategy,
status: input.status,
error: input.error,
codex_error_kind: input.codex_error_kind,
codex_error_http_status_code: input.codex_error_http_status_code,
active_context_tokens_before: input.active_context_tokens_before,
active_context_tokens_after: input.active_context_tokens_after,
retained_image_count: input.retained_image_count,