Skip to main content

build_main_session_engine

Function build_main_session_engine 

Source
pub fn build_main_session_engine(
    hooks: &HooksConfig,
    builtins: &BuiltinRegistry,
    rt: &HookEngineCtx<'_>,
    skills: &Arc<BTreeMap<String, SkillEntry>>,
    goal: Option<&Arc<GoalState>>,
) -> Result<Arc<dyn HookEngine>, HookEngineBuildError>
Expand description

Hook engine for the main session: automatically mounts two skill builtins on top of the user’s [hooks] configuration (when any skill is discovered) —

  • skill-manifestafter_session_enter: injects the L1 manifest + always-on body;
  • skill-triggersbefore_ingest: auto-activates relevant skills based on the prompt.

This makes “auto-activation” work out of the box without requiring users to write [[hooks.*]] manually. Both hooks have empty matchers (they match all triggers under that event). When the skill index is empty, nothing is mounted (keeping zero overhead), and when the user also has no [hooks] configured, it falls through to NoopHookEngine. Sub-agent profiles do not take this path (they still use build_engine_arc), so skill hooks do not leak into sub-agents.