diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index a5cac3907..8e7065cde 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -539,12 +539,24 @@ impl Session { features: &per_turn_config.features, }); + let base_instructions = if per_turn_config.features.enabled(Feature::Collab) { + const COLLAB_INSTRUCTIONS: &str = + include_str!("../templates/collab/experimental_prompt.md"); + let base = session_configuration + .base_instructions + .as_deref() + .unwrap_or(model_info.base_instructions.as_str()); + Some(format!("{base}\n\n{COLLAB_INSTRUCTIONS}")) + } else { + session_configuration.base_instructions.clone() + }; + TurnContext { sub_id, client, cwd: session_configuration.cwd.clone(), developer_instructions: session_configuration.developer_instructions.clone(), - base_instructions: session_configuration.base_instructions.clone(), + base_instructions, compact_prompt: session_configuration.compact_prompt.clone(), user_instructions: session_configuration.user_instructions.clone(), approval_policy: session_configuration.approval_policy.value(), diff --git a/codex-rs/core/templates/collab/experimental_prompt.md b/codex-rs/core/templates/collab/experimental_prompt.md new file mode 100644 index 000000000..2b7f09fa2 --- /dev/null +++ b/codex-rs/core/templates/collab/experimental_prompt.md @@ -0,0 +1,18 @@ +## Multi agents +You have the possibility to spawn and user other agents to complete a task. For example, this can be use for: +* Very large tasks with multiple well-defined scopes +* When you want a review from another agent. This can review your own work or the work of another agent. +* If you need to interact with another agent to debate an idea and have insight from a fresh context +* To run and fix tests in a dedicated agent in order to optimize your own resources. + +This feature must be used wisely. For simple or straightforward tasks, you don't need to spawn a new agent. + +**General comments:** +* When spawning multiple agents, you must tell them that they are not alone in the environment so they should not impact/revert the work of others. +* Running tests or some config commands can output a large amount of logs. In order to optimize your own context, you can spawn an agent and ask it to do it for you. In such cases, you must tell this agent that it can't spawn another agent himself (to prevent infinite recursion) +* When you're done with a sub-agent, don't forget to close it using `close_agent`. +* Be careful on the `timeout_ms` parameter you choose for `wait`. It should be wisely scaled. +* Sub-agents have access to the same set of tools as you do so you must tell them if they are allowed to spawn sub-agents themselves or not. + +## Global +You're name is Batman