fix: Clean up orphaned sub-agents when the parent agent

This commit is contained in:
2026-02-18 09:12:32 -07:00
parent 948466d771
commit 7884adc7c1
2 changed files with 9 additions and 1 deletions
+5 -1
View File
@@ -1,10 +1,10 @@
mod agent;
mod input;
mod macros;
mod prompts;
mod role;
mod session;
pub(crate) mod todo;
mod prompts;
pub use self::agent::{Agent, AgentVariables, complete_agent_variables, list_agents};
pub use self::input::Input;
@@ -1898,6 +1898,10 @@ impl Config {
self.exit_session()?;
self.load_functions()?;
if self.agent.take().is_some() {
if let Some(ref supervisor) = self.supervisor {
supervisor.read().cancel_all();
}
self.supervisor.take();
self.rag.take();
self.discontinuous_last_message();
}
+4
View File
@@ -305,6 +305,10 @@ fn run_child_agent(
input = input.merge_tool_results(output, tool_results);
}
if let Some(ref supervisor) = child_config.read().supervisor {
supervisor.read().cancel_all();
}
Ok(accumulated_output)
})
}