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
2026-09-10 21:30:56 +00:00
committed by copyberry
parent e25bedc166
commit 60825b4988
8 changed files with 295 additions and 19 deletions
+5
View File
@@ -232,6 +232,11 @@ impl CodexThread {
self.session.services.session_telemetry.clone()
}
/// Whether analytics is enabled for this thread after configuration and host overrides.
pub fn analytics_enabled(&self) -> bool {
self.session.services.analytics_events_client.is_enabled()
}
/// Returns extension-owned data attached to this thread runtime.
pub fn thread_extension_data(&self) -> &codex_extension_api::ExtensionData {
&self.session.services.thread_extension_data