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:
jif-oai
2026-02-20 14:39:49 +00:00
committed by GitHub
parent 03ff04cd65
commit 0f9eed3a6f
39 changed files with 1125 additions and 109 deletions
+4
View File
@@ -37,6 +37,8 @@ fn apply_session_meta_from_item(metadata: &mut ThreadMetadata, meta_line: &Sessi
}
metadata.id = meta_line.meta.id;
metadata.source = enum_to_string(&meta_line.meta.source);
metadata.agent_nickname = meta_line.meta.agent_nickname.clone();
metadata.agent_role = meta_line.meta.agent_role.clone();
if let Some(provider) = meta_line.meta.model_provider.as_deref() {
metadata.model_provider = provider.to_string();
}
@@ -216,6 +218,8 @@ mod tests {
created_at,
updated_at: created_at,
source: "cli".to_string(),
agent_nickname: None,
agent_role: None,
model_provider: "openai".to_string(),
cwd: PathBuf::from("/tmp"),
cli_version: "0.0.0".to_string(),
@@ -62,6 +62,10 @@ pub struct ThreadMetadata {
pub updated_at: DateTime<Utc>,
/// The session source (stringified enum).
pub source: String,
/// Optional random unique nickname assigned to an AgentControl-spawned sub-agent.
pub agent_nickname: Option<String>,
/// Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.
pub agent_role: Option<String>,
/// The model provider identifier.
pub model_provider: String,
/// The working directory for the thread.
@@ -101,6 +105,10 @@ pub struct ThreadMetadataBuilder {
pub updated_at: Option<DateTime<Utc>>,
/// The session source.
pub source: SessionSource,
/// Optional random unique nickname assigned to the session.
pub agent_nickname: Option<String>,
/// Optional role (agent_role) assigned to the session.
pub agent_role: Option<String>,
/// The model provider identifier, if known.
pub model_provider: Option<String>,
/// The working directory for the thread.
@@ -135,6 +143,8 @@ impl ThreadMetadataBuilder {
created_at,
updated_at: None,
source,
agent_nickname: None,
agent_role: None,
model_provider: None,
cwd: PathBuf::new(),
cli_version: None,
@@ -163,6 +173,8 @@ impl ThreadMetadataBuilder {
created_at,
updated_at,
source,
agent_nickname: self.agent_nickname.clone(),
agent_role: self.agent_role.clone(),
model_provider: self
.model_provider
.clone()
@@ -201,6 +213,12 @@ impl ThreadMetadata {
if self.source != other.source {
diffs.push("source");
}
if self.agent_nickname != other.agent_nickname {
diffs.push("agent_nickname");
}
if self.agent_role != other.agent_role {
diffs.push("agent_role");
}
if self.model_provider != other.model_provider {
diffs.push("model_provider");
}
@@ -252,6 +270,8 @@ pub(crate) struct ThreadRow {
created_at: i64,
updated_at: i64,
source: String,
agent_nickname: Option<String>,
agent_role: Option<String>,
model_provider: String,
cwd: String,
cli_version: String,
@@ -274,6 +294,8 @@ impl ThreadRow {
created_at: row.try_get("created_at")?,
updated_at: row.try_get("updated_at")?,
source: row.try_get("source")?,
agent_nickname: row.try_get("agent_nickname")?,
agent_role: row.try_get("agent_role")?,
model_provider: row.try_get("model_provider")?,
cwd: row.try_get("cwd")?,
cli_version: row.try_get("cli_version")?,
@@ -300,6 +322,8 @@ impl TryFrom<ThreadRow> for ThreadMetadata {
created_at,
updated_at,
source,
agent_nickname,
agent_role,
model_provider,
cwd,
cli_version,
@@ -319,6 +343,8 @@ impl TryFrom<ThreadRow> for ThreadMetadata {
created_at: epoch_seconds_to_datetime(created_at)?,
updated_at: epoch_seconds_to_datetime(updated_at)?,
source,
agent_nickname,
agent_role,
model_provider,
cwd: PathBuf::from(cwd),
cli_version,
+13 -1
View File
@@ -211,6 +211,8 @@ SELECT
created_at,
updated_at,
source,
agent_nickname,
agent_role,
model_provider,
cwd,
cli_version,
@@ -310,6 +312,8 @@ SELECT
created_at,
updated_at,
source,
agent_nickname,
agent_role,
model_provider,
cwd,
cli_version,
@@ -691,6 +695,8 @@ INSERT INTO threads (
created_at,
updated_at,
source,
agent_nickname,
agent_role,
model_provider,
cwd,
cli_version,
@@ -704,12 +710,14 @@ INSERT INTO threads (
git_sha,
git_branch,
git_origin_url
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT(id) DO UPDATE SET
rollout_path = excluded.rollout_path,
created_at = excluded.created_at,
updated_at = excluded.updated_at,
source = excluded.source,
agent_nickname = excluded.agent_nickname,
agent_role = excluded.agent_role,
model_provider = excluded.model_provider,
cwd = excluded.cwd,
cli_version = excluded.cli_version,
@@ -730,6 +738,8 @@ ON CONFLICT(id) DO UPDATE SET
.bind(datetime_to_epoch_seconds(metadata.created_at))
.bind(datetime_to_epoch_seconds(metadata.updated_at))
.bind(metadata.source.as_str())
.bind(metadata.agent_nickname.as_deref())
.bind(metadata.agent_role.as_deref())
.bind(metadata.model_provider.as_str())
.bind(metadata.cwd.display().to_string())
.bind(metadata.cli_version.as_str())
@@ -3092,6 +3102,8 @@ VALUES (?, ?, ?, ?, ?)
created_at: now,
updated_at: now,
source: "cli".to_string(),
agent_nickname: None,
agent_role: None,
model_provider: "test-provider".to_string(),
cwd,
cli_version: "0.0.0".to_string(),
+2
View File
@@ -95,6 +95,8 @@ SELECT
created_at,
updated_at,
source,
agent_nickname,
agent_role,
model_provider,
cwd,
cli_version,