pub fn build_process_tools_with_subagents(
config: &LoadedConfig,
profiles: &BTreeMap<String, ProfileSpec>,
skills: &BTreeMap<String, SkillEntry>,
registry: &Arc<ProviderRegistry>,
policy: &Arc<dyn SandboxPolicy>,
base_prompt: Option<String>,
builtins: &BuiltinRegistry,
hook_rt: &HookEngineCtx<'_>,
) -> Result<Arc<dyn ToolRegistry>, ProfileHookBuildError>Expand description
Assembles the process tool set, overlaying spawn_agent and skill tools when
profiles or skills are present.
Composition: first build the base tool set (bash/fs/fetch/search), then place
spawn_agent (when any profile is found) and skill (when any skill is found) into
an overlay registry, and combine them with CompositeRegistry on top of the base.
spawn_agent‘s “child tool source” is the base tool set (without these overlay tools), so child agents structurally cannot accessspawn_agent—preventing recursion; they also cannot accessskill(skill is a top-level agent capability; child agents use their own profile prompt); similarly they cannot accessinspect_background_task/cancel_background_task(the background task table belongs to the top-level session, and child agents’ nested turns haveToolContext::backgroundasNone).- When both profiles and skills are empty, no overlay is applied and the pure base is returned.
base_prompt is inherited by child agents (the “you are an agent that uses tools”
base prompt); the profile’s role prompt is appended separately.
builtins / hook_rt are used to compile each profile’s [hooks] into a hook engine
(see project_profiles)—a child agent’s hooks are part of its identity and are not
inherited from the parent.
§Errors
If any profile’s hook engine fails to build, it is a hard failure
(ProfileHookBuildError).