Expose the model selected for a running turn's next step (#50128)

## What changed

Add `CodexThread::current_turn_model` to return the model slug selected for the named running turn's next step, independently of settings for future turns. Return `None` when the turn ID does not match, the task is cancelled, or the turn is no longer running.

## Testing

Extend the step-settings test to verify that the accessor ignores model changes for future turns, reflects active-turn model updates, and returns `None` for a mismatched ID or a completed turn.

GitOrigin-RevId: 2cae7c07fa761ed4d64befaa3419a2f9bce4b161
This commit is contained in:
sayan-oai
2026-10-02 00:45:26 +00:00
committed by copyberry
parent b707714ae4
commit 4f99920b8c
2 changed files with 21 additions and 0 deletions
+11
View File
@@ -304,6 +304,17 @@ impl CodexThread {
task.turn_context.extension_data.get::<T>()
}
/// Returns the model selected for the named running turn's next step, not future turns.
/// Returns `None` if that turn is no longer running.
pub async fn current_turn_model(&self, expected_turn_id: &str) -> Option<String> {
let active = self.session.active_turn.lock().await;
let task = active.as_ref()?.task.as_ref()?;
if task.turn_context.sub_id != expected_turn_id || task.cancellation_token.is_cancelled() {
return None;
}
Some(task.turn_context.capture_current_model_info().slug.clone())
}
pub async fn shutdown_and_wait(&self) -> CodexResult<()> {
self.io.shutdown_and_wait().await
}