Files
codex/codex-rs/core/src/turn_extension_data.rs
T
sayan-oai 408f48ce0c Capture host-supplied extension data for each turn (#49846)
## What changed

Add `turn_extension_init` to thread startup and settings, and expose `WithTurnExtensionData` for turn input, recovery, and settings requests. Accept or reject data updates together with the request that supplies them.

Each new turn captures the configured data, including automatically started turns. Accepted steering updates the data for future turns while preserving the running turn's capture. Plain requests preserve the configured data; an empty initializer clears it. The data is not persisted and must be supplied again on cold resume.

Expose `current_turn_extension_data` to retrieve typed data only when the requested turn is still running and has not been cancelled.

## Testing

Add an integration test covering initial capture, accepted and rejected steering, inheritance by an automatic turn, clearing future data without changing the active capture, and rejection of lookups for an earlier turn.

GitOrigin-RevId: dd81eda3e32c7b62d783c772221858f4c0e68264
2026-10-01 03:31:48 +00:00

34 lines
1.0 KiB
Rust

//! Carries host-owned data through settings acceptance and into each new turn.
use codex_extension_api::ExtensionDataInit;
/// A request that also replaces the host data inherited by future turns.
///
/// Core accepts or rejects both together. Steering leaves the running turn's
/// data unchanged. Plain requests preserve the saved data; an empty initializer
/// clears it. Values should be immutable: initializers share their values by `Arc`.
/// This data is not persisted, so hosts must supply it again on cold resume.
#[derive(Debug)]
pub struct WithTurnExtensionData<T> {
pub(crate) request: T,
pub(crate) turn_extension_init: Option<ExtensionDataInit>,
}
impl<T> WithTurnExtensionData<T> {
pub fn new(request: T, turn_extension_init: ExtensionDataInit) -> Self {
Self {
request,
turn_extension_init: Some(turn_extension_init),
}
}
}
impl<T> From<T> for WithTurnExtensionData<T> {
fn from(request: T) -> Self {
Self {
request,
turn_extension_init: None,
}
}
}