Skip to main content

Configure Hooks

Add entry and exit hooks to workflow stages. Hooks are tool calls that run automatically before a stage starts (entry) or after it completes (exit), without consuming agent cycles.

Prerequisites

  • A workflow with at least one stage (see Add Stages)
  • Tool definitions configured in your project

Steps

1. Open the stage edit drawer

Navigate to your workflow's Visual Builder. Click a stage node to open the edit drawer. Switch to the Hooks tab (tab 2).

Stage hooks tab

2. Understand entry vs. exit hooks

Hook typeWhen it runsCommon use cases
Entry hookBefore any agent in the stage executesLoad data, validate preconditions, fetch external state
Exit hookAfter all agents in the stage completeSave results, send notifications, update external systems

3. Add an entry hook

In the Entry Hooks section of the Hooks tab, click Add Hook. Select a tool from the dropdown -- this lists all tool definitions available in the project.

Configure the hook:

  • Tool -- Which tool to execute
  • Output Key -- A key name under which the hook's output is stored, making it accessible to agents in the stage
tip

Entry hooks are ideal for loading data that multiple agents need. Set an output key so agents can reference the data without each making their own tool call.

4. Add an exit hook

In the Exit Hooks section, click Add Hook. The configuration is the same:

  • Tool -- Which tool to execute
  • Output Key -- A key name for the hook's output (available to downstream stages)

Exit hooks commonly persist stage results to external systems, trigger notifications, or clean up temporary resources.

5. View hooks in the Visual Builder

After saving, the Visual Builder shows hooks as nodes flanking the stage:

  • Entry hooks appear to the LEFT of the stage, connected by a dashed line
  • Exit hooks appear to the RIGHT of the stage, connected by a dashed line

Small diamond indicators on the stage's left and right edges indicate that hooks are configured.

Hooks in the Visual Builder

6. Add hooks via drag-and-drop

Alternatively, drag a hook card from the Hooks section of the sidebar palette onto a stage node:

  • Drag "Entry Hook" onto a stage to open the Hooks tab with the entry section focused
  • Drag "Exit Hook" onto a stage to open the Hooks tab with the exit section focused

7. Remove a hook

Open the stage's Hooks tab and click the remove button next to the hook you want to delete. Save the stage form to persist the change.

8. Chain multiple hooks

You can add multiple entry hooks and multiple exit hooks to a single stage. They execute in the order listed. Each hook's output is available under its output key.

warning

Hooks execute synchronously. A slow entry hook delays the entire stage. Keep hook operations lightweight or use them for essential setup and teardown only.

What's next

Learn more