(
code_config: &CodeConfig,
opts: &SessionOptions,
workspace: &Path,
llm_client: Arc<dyn LlmClient>,
tool_executor: &Arc<ToolExecutor>,
subagent_tasks: Arc<crate::subagent_task
| 151 | } |
| 152 | |
| 153 | fn register_task_capability( |
| 154 | code_config: &CodeConfig, |
| 155 | opts: &SessionOptions, |
| 156 | workspace: &Path, |
| 157 | llm_client: Arc<dyn LlmClient>, |
| 158 | tool_executor: &Arc<ToolExecutor>, |
| 159 | subagent_tasks: Arc<crate::subagent_task_tracker::InMemorySubagentTaskTracker>, |
| 160 | ) -> Arc<AgentRegistry> { |
| 161 | use crate::child_run::ChildRunContext; |
| 162 | use crate::subagent::load_agents_from_dir; |
| 163 | use crate::tools::register_task_with_mcp; |
| 164 | |
| 165 | let registry = AgentRegistry::new(); |
| 166 | let auto_delegation = super::session_config::resolve_auto_delegation_config(code_config, opts); |
| 167 | let built_in_agent_dirs = built_in_agent_dirs(workspace); |
| 168 | for dir in code_config |
| 169 | .agent_dirs |
| 170 | .iter() |
| 171 | .chain(built_in_agent_dirs.iter()) |
| 172 | .chain(opts.agent_dirs.iter()) |
| 173 | { |
| 174 | for agent in load_agents_from_dir(dir) { |
| 175 | registry.register(agent); |
| 176 | } |
| 177 | } |
| 178 | for worker in &opts.worker_agents { |
| 179 | registry.register_worker(worker.clone()); |
| 180 | } |
| 181 | |
| 182 | if !auto_delegation.allow_manual_delegation { |
| 183 | // Keep the registry populated for introspection and host-managed worker |
| 184 | // registration even when the model-visible delegation tools are hidden. |
| 185 | return Arc::new(registry); |
| 186 | } |
| 187 | |
| 188 | let parent_context = ChildRunContext { |
| 189 | security_provider: opts.security_provider.clone(), |
| 190 | hook_engine: None, |
| 191 | skill_registry: opts.skill_registry.clone(), |
| 192 | tool_timeout_ms: opts.tool_timeout_ms, |
| 193 | max_parallel_tasks: opts.max_parallel_tasks.or(code_config.max_parallel_tasks), |
| 194 | max_execution_time_ms: opts.max_execution_time_ms, |
| 195 | circuit_breaker_threshold: opts.circuit_breaker_threshold, |
| 196 | confirmation_manager: opts.confirmation_manager.clone(), |
| 197 | workspace_services: opts.workspace_services.clone(), |
| 198 | budget_guard: opts.budget_guard.clone(), |
| 199 | }; |
| 200 | |
| 201 | let registry = Arc::new(registry); |
| 202 | register_task_with_mcp( |
| 203 | tool_executor.registry(), |
| 204 | llm_client, |
| 205 | Arc::clone(®istry), |
| 206 | workspace.display().to_string(), |
| 207 | opts.mcp_manager.clone(), |
| 208 | Some(parent_context), |
| 209 | Some(subagent_tasks), |
| 210 | ); |
no test coverage detected