Honor thread analytics opt-outs when using shared clients (#44646)

## Why

An enabled shared analytics client could override a thread's explicit opt-out.
Delegated threads also emitted initialization events through the parent's client,
bypassing the child's analytics setting.

## What changed

- Use a disabled analytics client when `config.analytics_enabled` is `Some(false)`,
  without disabling analytics for sibling threads or overriding a disabled host client.
- Emit delegated thread initialization events through the child's analytics client.
- Expose the effective analytics state through `CodexThread::analytics_enabled()`.

## Testing

Add regression tests for explicit and unset thread settings with enabled, disabled,
and absent shared clients, plus delegated child opt-outs with an enabled parent.
Update compaction and rollout-budget rollback tests to wait for thread idle after
turn completion and fail immediately on rollback errors.

GitOrigin-RevId: 547852909af1a6822b95c0bcd2336b0d6bc7aad1
This commit is contained in:
priyanshusingh-de authored and copyberry committed 2026-09-10 21:30:56 +00:00
1 parent e25bedc166
commit 60825b4988
8 files changed
+295 -19

No files matched your search

+1 -1
View File
@@ -145,7 +145,7 @@ pub(crate) async fn run_codex_thread_interactive(
let thread_config = session.thread_config_snapshot().await;
let client_metadata = parent_session.app_server_client_metadata().await;
emit_subagent_session_started(
&parent_session.services.analytics_events_client,
&session.services.analytics_events_client,
client_metadata,
session.session_id(),
session.thread_id(),