diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index c76396b5e7..721b6a4171 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -1935,6 +1935,7 @@ mod handlers { use crate::review_prompts::resolve_review_request; use crate::tasks::CollaborationTask; use crate::tasks::CompactTask; + use crate::tasks::RegularTask; use crate::tasks::UndoTask; use crate::tasks::UserShellCommandTask; use codex_protocol::custom_prompts::CustomPrompt; @@ -2015,8 +2016,13 @@ mod handlers { .await; } - sess.spawn_task(Arc::clone(¤t_context), items, CollaborationTask) - .await; + if sess.enabled(Feature::MultiAgents) { + sess.spawn_task(Arc::clone(¤t_context), items, CollaborationTask) + .await; + } else { + sess.spawn_task(Arc::clone(¤t_context), items, RegularTask) + .await; + } *previous_context = Some(current_context); } } diff --git a/codex-rs/core/src/features.rs b/codex-rs/core/src/features.rs index 431eabe3c6..b30f3f1c49 100644 --- a/codex-rs/core/src/features.rs +++ b/codex-rs/core/src/features.rs @@ -64,6 +64,8 @@ pub enum Feature { ShellSnapshot, /// Experimental TUI v2 (viewport) implementation. Tui2, + /// Enable multi-agent collaboration workflows. + MultiAgents, } impl Feature { @@ -353,6 +355,12 @@ pub const FEATURES: &[FeatureSpec] = &[ stage: Stage::Experimental, default_enabled: false, }, + FeatureSpec { + id: Feature::MultiAgents, + key: "multi_agents", + stage: Stage::Experimental, + default_enabled: false, + }, FeatureSpec { id: Feature::ShellSnapshot, key: "shell_snapshot", diff --git a/codex-rs/core/src/tasks/mod.rs b/codex-rs/core/src/tasks/mod.rs index f919648698..4db058df03 100644 --- a/codex-rs/core/src/tasks/mod.rs +++ b/codex-rs/core/src/tasks/mod.rs @@ -1,6 +1,7 @@ mod collaboration; mod compact; mod ghost_snapshot; +mod regular; mod review; mod undo; mod user_shell; @@ -33,6 +34,7 @@ pub(crate) use collaboration::CollaborationSupervisor; pub(crate) use collaboration::CollaborationTask; pub(crate) use compact::CompactTask; pub(crate) use ghost_snapshot::GhostSnapshotTask; +pub(crate) use regular::RegularTask; pub(crate) use review::ReviewTask; pub(crate) use undo::UndoTask; pub(crate) use user_shell::UserShellCommandTask; diff --git a/codex-rs/core/src/tasks/regular.rs b/codex-rs/core/src/tasks/regular.rs index e69de29bb2..73d0973bfa 100644 --- a/codex-rs/core/src/tasks/regular.rs +++ b/codex-rs/core/src/tasks/regular.rs @@ -0,0 +1,39 @@ +use std::sync::Arc; + +use async_trait::async_trait; +use codex_protocol::user_input::UserInput; +use tokio_util::sync::CancellationToken; +use tracing::Instrument; +use tracing::info_span; + +use crate::codex::TurnContext; +use crate::codex::run_task; +use crate::state::TaskKind; + +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, + session: Arc, + ctx: Arc, + input: Vec, + cancellation_token: CancellationToken, + ) -> Option { + let sess = session.clone_session(); + let run_task_span = + info_span!(parent: sess.services.otel_manager.current_span(), "run_task"); + run_task(sess, ctx, input, cancellation_token) + .instrument(run_task_span) + .await + } +} diff --git a/docs/config.md b/docs/config.md index 9a1f23e1c1..de739a0934 100644 --- a/docs/config.md +++ b/docs/config.md @@ -51,6 +51,7 @@ Supported features: | `enable_experimental_windows_sandbox` | false | Experimental | Use the Windows restricted-token sandbox | | `tui2` | false | Experimental | Use the experimental TUI v2 (viewport) implementation | | `skills` | false | Experimental | Enable discovery and injection of skills | +| `multi_agents` | false | Experimental | Enable multi-agent collaboration workflows | Notes: @@ -59,7 +60,7 @@ Notes: ## Agent profiles -Codex can optionally load multi-agent profiles from `$CODEX_HOME/agents.toml`. When this file exists and is valid, Codex starts as the `main` profile (agent 0) and, on supported models, exposes the `collaboration_*` tools. Each profile can control which sub-agents it can spawn. +Codex can optionally load multi-agent profiles from `$CODEX_HOME/agents.toml`. When this file exists and is valid, Codex starts as the `main` profile (agent 0) and, on supported models, exposes the `collaboration_*` tools. Each profile can control which sub-agents it can spawn. Enable the `multi_agents` feature flag to run the collaboration workflow. Example: