turn metadata: per-turn non-blocking (#11677)

This commit is contained in:
pash-openai
2026-02-13 12:48:29 -08:00
committed by GitHub
parent a4bb59884b
commit 6c0a924203
11 changed files with 457 additions and 158 deletions
+3
View File
@@ -197,6 +197,8 @@ impl Session {
turn_context: Arc<TurnContext>,
last_agent_message: Option<String>,
) {
turn_context.cancel_turn_metadata_enrichment_task();
let mut active = self.active_turn.lock().await;
let mut pending_input = Vec::<ResponseInputItem>::new();
let mut should_clear_active_turn = false;
@@ -260,6 +262,7 @@ impl Session {
trace!(task_kind = ?task.kind, sub_id, "aborting running task");
task.cancellation_token.cancel();
task.turn_context.cancel_turn_metadata_enrichment_task();
let session_task = task.task;
select! {
+1 -4
View File
@@ -10,7 +10,6 @@ use async_trait::async_trait;
use codex_otel::OtelManager;
use codex_protocol::openai_models::ModelInfo;
use codex_protocol::user_input::UserInput;
use futures::future::BoxFuture;
use tokio::task::JoinHandle;
use tokio_util::sync::CancellationToken;
use tracing::Instrument;
@@ -39,13 +38,11 @@ impl RegularTask {
model_client: ModelClient,
otel_manager: OtelManager,
model_info: ModelInfo,
turn_metadata_header: BoxFuture<'static, Option<String>>,
) -> Self {
let prewarmed_session_task = tokio::spawn(async move {
let mut client_session = model_client.new_session();
let turn_metadata_header = turn_metadata_header.await;
match client_session
.prewarm_websocket(&otel_manager, &model_info, turn_metadata_header.as_deref())
.prewarm_websocket(&otel_manager, &model_info)
.await
{
Ok(()) => Some(client_session),