mirror of
https://github.com/openai/codex.git
synced 2026-04-28 18:32:04 +03:00
feat: add nick name to sub-agents (#12320)
Adding random nick name to sub-agents. Used for UX At the same time, also storing and wiring the role of the sub-agent
This commit is contained in:
@@ -1861,6 +1861,10 @@ pub enum SubAgentSource {
|
||||
ThreadSpawn {
|
||||
parent_thread_id: ThreadId,
|
||||
depth: i32,
|
||||
#[serde(default)]
|
||||
agent_nickname: Option<String>,
|
||||
#[serde(default, alias = "agent_type")]
|
||||
agent_role: Option<String>,
|
||||
},
|
||||
MemoryConsolidation,
|
||||
Other(String),
|
||||
@@ -1879,6 +1883,26 @@ impl fmt::Display for SessionSource {
|
||||
}
|
||||
}
|
||||
|
||||
impl SessionSource {
|
||||
pub fn get_nickname(&self) -> Option<String> {
|
||||
match self {
|
||||
SessionSource::SubAgent(SubAgentSource::ThreadSpawn { agent_nickname, .. }) => {
|
||||
agent_nickname.clone()
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_agent_role(&self) -> Option<String> {
|
||||
match self {
|
||||
SessionSource::SubAgent(SubAgentSource::ThreadSpawn { agent_role, .. }) => {
|
||||
agent_role.clone()
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for SubAgentSource {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
@@ -1888,6 +1912,7 @@ impl fmt::Display for SubAgentSource {
|
||||
SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id,
|
||||
depth,
|
||||
..
|
||||
} => {
|
||||
write!(f, "thread_spawn_{parent_thread_id}_d{depth}")
|
||||
}
|
||||
@@ -1912,6 +1937,12 @@ pub struct SessionMeta {
|
||||
pub cli_version: String,
|
||||
#[serde(default)]
|
||||
pub source: SessionSource,
|
||||
/// Optional random unique nickname assigned to an AgentControl-spawned sub-agent.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub agent_nickname: Option<String>,
|
||||
/// Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.
|
||||
#[serde(default, alias = "agent_type", skip_serializing_if = "Option::is_none")]
|
||||
pub agent_role: Option<String>,
|
||||
pub model_provider: Option<String>,
|
||||
/// base_instructions for the session. This *should* always be present when creating a new session,
|
||||
/// but may be missing for older sessions. If not present, fall back to rendering the base_instructions
|
||||
@@ -1931,6 +1962,8 @@ impl Default for SessionMeta {
|
||||
originator: String::new(),
|
||||
cli_version: String::new(),
|
||||
source: SessionSource::default(),
|
||||
agent_nickname: None,
|
||||
agent_role: None,
|
||||
model_provider: None,
|
||||
base_instructions: None,
|
||||
dynamic_tools: None,
|
||||
|
||||
Reference in New Issue
Block a user