Skip to main content

build_process_tools_with_subagents

Function build_process_tools_with_subagents 

Source
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 access spawn_agent—preventing recursion; they also cannot access skill (skill is a top-level agent capability; child agents use their own profile prompt); similarly they cannot access inspect_background_task / cancel_background_task (the background task table belongs to the top-level session, and child agents’ nested turns have ToolContext::background as None).
  • 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).