mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
Today `sub_id` is an ID of a single incoming Codex Op submition. We then associate all events triggered by this operation using the same `sub_id`. At the same time we are also creating a TurnContext per submission and we'd like to start associating some events (item added/item completed) with an entire turn instead of just the operation that started it. Using turn context when sending events give us flexibility to change notification scheme.
34 lines
812 B
Rust
34 lines
812 B
Rust
use std::sync::Arc;
|
|
|
|
use async_trait::async_trait;
|
|
use tokio_util::sync::CancellationToken;
|
|
|
|
use crate::codex::TurnContext;
|
|
use crate::codex::run_task;
|
|
use crate::state::TaskKind;
|
|
use codex_protocol::user_input::UserInput;
|
|
|
|
use super::SessionTask;
|
|
use super::SessionTaskContext;
|
|
|
|
#[derive(Clone, Copy, Default)]
|
|
pub(crate) struct RegularTask;
|
|
|
|
#[async_trait]
|
|
impl SessionTask for RegularTask {
|
|
fn kind(&self) -> TaskKind {
|
|
TaskKind::Regular
|
|
}
|
|
|
|
async fn run(
|
|
self: Arc<Self>,
|
|
session: Arc<SessionTaskContext>,
|
|
ctx: Arc<TurnContext>,
|
|
input: Vec<UserInput>,
|
|
cancellation_token: CancellationToken,
|
|
) -> Option<String> {
|
|
let sess = session.clone_session();
|
|
run_task(sess, ctx, input, TaskKind::Regular, cancellation_token).await
|
|
}
|
|
}
|