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
Properties
Section titled “Properties”afterGadgetExecution()?
Section titled “afterGadgetExecution()?”
optionalafterGadgetExecution: (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.
Parameters
Section titled “Parameters”context
Section titled “context”AfterGadgetExecutionControllerContext
Returns
Section titled “Returns”Promise<AfterGadgetExecutionAction>
afterLLMCall()?
Section titled “afterLLMCall()?”
optionalafterLLMCall: (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.
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”Promise<AfterLLMCallAction>
afterLLMError()?
Section titled “afterLLMError()?”
optionalafterLLMError: (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.
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”Promise<AfterLLMErrorAction>
beforeGadgetExecution()?
Section titled “beforeGadgetExecution()?”
optionalbeforeGadgetExecution: (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.
Parameters
Section titled “Parameters”context
Section titled “context”GadgetExecutionControllerContext
Returns
Section titled “Returns”Promise<BeforeGadgetExecutionAction>
beforeLLMCall()?
Section titled “beforeLLMCall()?”
optionalbeforeLLMCall: (context) =>Promise<BeforeLLMCallAction>
Defined in: agent/hooks.ts:622
Called before making an LLM API call. Can modify options or skip the call entirely.
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”Promise<BeforeLLMCallAction>
onDependencySkipped()?
Section titled “onDependencySkipped()?”
optionalonDependencySkipped: (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.
Parameters
Section titled “Parameters”context
Section titled “context”DependencySkipControllerContext
Returns
Section titled “Returns”Promise<DependencySkipAction>