feat: cap number of agents (#9855)

Adding more guards to agent:
* Max depth or 1 (i.e. a sub-agent can't spawn another one)
* Max 12 sub-agents in total
This commit is contained in:
jif-oai
2026-01-25 15:57:22 +01:00
committed by GitHub
parent a748600c42
commit 73b5274443
5 changed files with 143 additions and 12 deletions

View File

@@ -1518,7 +1518,10 @@ pub enum SessionSource {
pub enum SubAgentSource {
Review,
Compact,
ThreadSpawn { parent_thread_id: ThreadId },
ThreadSpawn {
parent_thread_id: ThreadId,
depth: i32,
},
Other(String),
}
@@ -1540,8 +1543,11 @@ impl fmt::Display for SubAgentSource {
match self {
SubAgentSource::Review => f.write_str("review"),
SubAgentSource::Compact => f.write_str("compact"),
SubAgentSource::ThreadSpawn { parent_thread_id } => {
write!(f, "thread_spawn_{parent_thread_id}")
SubAgentSource::ThreadSpawn {
parent_thread_id,
depth,
} => {
write!(f, "thread_spawn_{parent_thread_id}_d{depth}")
}
SubAgentSource::Other(other) => f.write_str(other),
}