feat: change multi-agent to use path-like system instead of uuids (#15313)

This PR add an URI-based system to reference agents within a tree. This
comes from a sync between research and engineering.

The main agent (the one manually spawned by a user) is always called
`/root`. Any sub-agent spawned by it will be `/root/agent_1` for example
where `agent_1` is chosen by the model.

Any agent can contact any agents using the path.

Paths can be used either in absolute or relative to the calling agents

Resume is not supported for now on this new path
This commit is contained in:
jif-oai
2026-03-20 18:23:48 +00:00
committed by GitHub
parent 4ddde54c19
commit 79ad7b247b
57 changed files with 1707 additions and 299 deletions

View File

@@ -12,6 +12,7 @@ use std::path::PathBuf;
use std::str::FromStr;
use std::time::Duration;
use crate::AgentPath;
use crate::ThreadId;
use crate::approvals::ElicitationRequestEvent;
use crate::config_types::ApprovalsReviewer;
@@ -2288,6 +2289,8 @@ pub enum SubAgentSource {
parent_thread_id: ThreadId,
depth: i32,
#[serde(default)]
agent_path: Option<AgentPath>,
#[serde(default)]
agent_nickname: Option<String>,
#[serde(default, alias = "agent_type")]
agent_role: Option<String>,
@@ -2351,6 +2354,16 @@ impl SessionSource {
_ => None,
}
}
pub fn get_agent_path(&self) -> Option<AgentPath> {
match self {
SessionSource::SubAgent(SubAgentSource::ThreadSpawn { agent_path, .. }) => {
agent_path.clone()
}
_ => None,
}
}
pub fn restriction_product(&self) -> Option<Product> {
match self {
SessionSource::Custom(source) => Product::from_session_source_name(source),
@@ -2411,6 +2424,9 @@ pub struct SessionMeta {
/// 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>,
/// Optional canonical agent path assigned to an AgentControl-spawned sub-agent.
#[serde(skip_serializing_if = "Option::is_none")]
pub agent_path: 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
@@ -2434,6 +2450,7 @@ impl Default for SessionMeta {
source: SessionSource::default(),
agent_nickname: None,
agent_role: None,
agent_path: None,
model_provider: None,
base_instructions: None,
dynamic_tools: None,