mirror of
https://github.com/openai/codex.git
synced 2026-11-04 00:24:43 +00:00
feat: add manual and remote_v2 tags to compaction metric (#24608)
## Why `codex.task.compact` only distinguished `local` vs `remote`, which made it hard to answer simple counter questions in Statsig. Manual `/compact` and automatic compaction were collapsed together, and the legacy remote path was also collapsed with `remote_compaction_v2`. ## What Changed - route `codex.task.compact` through a shared helper in `core/src/tasks/mod.rs` - add a `manual=true|false` tag so manual and automatic compaction can be counted separately - split the remote tag into `remote` and `remote_v2` - emit the metric from the inline auto-compaction path in `core/src/session/turn.rs` as well as the manual `CompactTask` path in `core/src/tasks/compact.rs` - add focused unit coverage for the new tag shapes in `core/src/tasks/mod_tests.rs` ## Verification - added unit coverage in `core/src/tasks/mod_tests.rs` covering manual `remote_v2` tags and automatic `local` tags
This commit is contained in:
1 parent
f6fd753039
commit
9271e84b79
4 files changed
+88
-9
No files matched your search
@@ -2,6 +2,7 @@ use std::sync::Arc;
|
||||
|
||||
use super::SessionTask;
|
||||
use super::SessionTaskContext;
|
||||
use super::emit_compact_metric;
|
||||
use crate::session::TurnInput;
|
||||
use crate::session::turn_context::TurnContext;
|
||||
use crate::state::TaskKind;
|
||||
@@ -29,24 +30,29 @@ impl SessionTask for CompactTask {
|
||||
) -> Option<String> {
|
||||
let session = session.clone_session();
|
||||
let _ = if crate::compact::should_use_remote_compact_task(ctx.provider.info()) {
|
||||
session.services.session_telemetry.counter(
|
||||
"codex.task.compact",
|
||||
/*inc*/ 1,
|
||||
&[("type", "remote")],
|
||||
);
|
||||
if ctx
|
||||
.features
|
||||
.enabled(codex_features::Feature::RemoteCompactionV2)
|
||||
{
|
||||
emit_compact_metric(
|
||||
&session.services.session_telemetry,
|
||||
"remote_v2",
|
||||
/*manual*/ true,
|
||||
);
|
||||
crate::compact_remote_v2::run_remote_compact_task(session.clone(), ctx).await
|
||||
} else {
|
||||
emit_compact_metric(
|
||||
&session.services.session_telemetry,
|
||||
"remote",
|
||||
/*manual*/ true,
|
||||
);
|
||||
crate::compact_remote::run_remote_compact_task(session.clone(), ctx).await
|
||||
}
|
||||
} else {
|
||||
session.services.session_telemetry.counter(
|
||||
"codex.task.compact",
|
||||
/*inc*/ 1,
|
||||
&[("type", "local")],
|
||||
emit_compact_metric(
|
||||
&session.services.session_telemetry,
|
||||
"local",
|
||||
/*manual*/ true,
|
||||
);
|
||||
let input = vec![UserInput::Text {
|
||||
text: ctx.compact_prompt().to_string(),
|
||||
|
||||
Reference in new issue
Block a user