Exclude per-item usage attribution by default (#63219)

## What changed

Add `usage.attribution` to the `x-codex-exclude` header for Responses HTTP
requests and WebSocket handshakes by default. Threads started with
`experimentalRawEvents` keep receiving per-item attribution in raw responses.
Subagents inherit the policy, and the app server restores it when a thread
resumes with an existing raw-event subscription.

## Testing

Cover the default exclusion, raw completion events with upstream usage,
subagent inheritance, and resuming a closed subagent after both its runtime
and its parent's runtime have unloaded.

GitOrigin-RevId: 0dad92f97606300907f1294f09dd7845d1e6476f
This commit is contained in:
Charlie Marsh
2026-11-23 01:06:41 +00:00
committed by copyberry
parent 9e3479e00a
commit ae6c0c8ac1
13 changed files with 237 additions and 19 deletions
@@ -206,11 +206,8 @@ pub(super) async fn attach_created_thread_listener(
!connection_ids.is_empty()
&& listener_task_context
.thread_state_manager
.thread_state(parent_thread_id)
.raw_events_enabled(parent_thread_id)
.await
.lock()
.await
.experimental_raw_events
} else {
false
};
@@ -1646,6 +1646,9 @@ impl ThreadRequestProcessor {
.then_some(ThreadHistoryMode::Paginated)
});
let mut thread_extension_init = ExtensionDataInit::new();
if experimental_raw_events {
thread_extension_init.insert(codex_core::UsageAttributionPolicy::Retain);
}
if !selected_capability_roots.is_empty() {
thread_extension_init.insert(selected_capability_roots);
}