Skip to content

Controllers

Defined in: agent/hooks.ts:617

Controllers: Async lifecycle hooks that control execution flow.

  • Can short-circuit execution
  • Can modify options and provide fallbacks
  • Run at specific lifecycle points

optional afterGadgetExecution: (context) => Promise<AfterGadgetExecutionAction>

Defined in: agent/hooks.ts:648

Called after a gadget execution (success or error). Can provide a fallback result to recover from errors.

AfterGadgetExecutionControllerContext

Promise<AfterGadgetExecutionAction>


optional afterLLMCall: (context) => Promise<AfterLLMCallAction>

Defined in: agent/hooks.ts:628

Called after a successful LLM call (after interceptors have run). Can append messages to conversation or modify the final message.

AfterLLMCallControllerContext

Promise<AfterLLMCallAction>


optional afterLLMError: (context) => Promise<AfterLLMErrorAction>

Defined in: agent/hooks.ts:634

Called after an LLM call fails. Can provide a fallback response to recover from the error.

LLMErrorControllerContext

Promise<AfterLLMErrorAction>


optional beforeGadgetExecution: (context) => Promise<BeforeGadgetExecutionAction>

Defined in: agent/hooks.ts:640

Called before executing a gadget (after interceptors have run). Can skip execution and provide a synthetic result.

GadgetExecutionControllerContext

Promise<BeforeGadgetExecutionAction>


optional beforeLLMCall: (context) => Promise<BeforeLLMCallAction>

Defined in: agent/hooks.ts:622

Called before making an LLM API call. Can modify options or skip the call entirely.

LLMCallControllerContext

Promise<BeforeLLMCallAction>


optional onDependencySkipped: (context) => Promise<DependencySkipAction>

Defined in: agent/hooks.ts:656

Called before skipping a gadget due to a failed dependency. Can override the default skip behavior to execute anyway or provide a fallback.

DependencySkipControllerContext

Promise<DependencySkipAction>