defineHarnessHook
Purpose and behavior
Section titled “Purpose and behavior”Define control code that runs at one point of the built-in harness loop: session-start, before-model, after-model, before-tool, after-tool or stop. Unlike observers, a hook can add instructions, deny or rewrite a tool call, replace its result or refuse to stop; an exception from a hook fails the turn.
Complete example and detailed rules.
Parameters and properties
Section titled “Parameters and properties”optionsRequiredHarnessHookOptions<Phase>Loop phase, optional name and control function of the hook.options.onRequiredPhaseLoop point where the hook runs.options.nameOptionalstring | undefinedName for diagnostics, default the phase name.options.runRequired(input: HarnessHookInput<Phase>) => HarnessHookResult<Phase> | Promise<HarnessHookResult<Phase>>Control function for this phase. Hooks of a phase run in declaration order; an exception fails the turn, and an invalid decision fails it with code configuration.