Skip to main content

Callback In

Defines a callback entry point that intercepts agent operations at specific lifecycle stages.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.

Inputs

  • Caller ID - (string) Caller ID for correlation, automatically passed by the agent when the callback is triggered.

Options

  • Callback Type - Type of callback to register. Options:
    • Before Agent - Triggered before a sub-agent executes
    • After Agent - Triggered after a sub-agent completes
    • Before Model - Triggered before an LLM API call
    • After Model - Triggered after an LLM API call returns
    • Before Tool - Triggered before a tool is called
    • After Tool - Triggered after a tool completes

Outputs

  • Callback Type - (string) The type of callback that was triggered.
  • Agent Name - (string) Name of the agent being executed (for agent callbacks).
  • Invocation ID - (string) Unique identifier for the current invocation.
  • Tool Name - (string) Name of the tool being called (for tool callbacks).
  • Tool Arguments - (object) Arguments passed to the tool (for before_tool callback).
  • Tool Response - (object) Response from the tool (for after_tool callback).
  • LLM Request - (string) Request sent to the LLM (for before_model callback).
  • LLM Response - (string) Response from the LLM (for after_model callback).

How It Works

The Callback In node creates an interception point in the agent lifecycle:

  1. Registration - When connected to an agent's callbacks port, registers for the selected callback type
  2. Triggering - The agent calls the callback at the appropriate lifecycle stage
  3. Context Population - The callback receives context data (agent name, tool info, etc.)
  4. Workflow Execution - The connected workflow executes with the callback context
  5. Return - The workflow must end with a Callback Out node to return control to the agent

Common Use Cases

  • Logging and Monitoring - Track agent and tool executions
  • Debugging - Inspect agent behavior and LLM interactions
  • Metrics Collection - Gather performance and usage metrics
  • Custom Logic - Implement custom behavior at specific lifecycle stages
  • Error Handling - Add custom error handling or recovery logic
  • Validation - Validate inputs before tool calls or agent executions
  • Transformation - Modify LLM requests or responses
  • Auditing - Record all agent interactions for compliance

Callback Types Explained

Before Agent:

  • Triggered before a sub-agent starts executing
  • Outputs: Agent Name, Invocation ID
  • Use for: Pre-processing, validation, logging

After Agent:

  • Triggered after a sub-agent completes
  • Outputs: Agent Name, Invocation ID
  • Use for: Post-processing, result transformation, cleanup

Before Model:

  • Triggered before sending a request to the LLM
  • Outputs: LLM Request, Invocation ID
  • Use for: Request logging, prompt modification, rate limiting

After Model:

  • Triggered after receiving a response from the LLM
  • Outputs: LLM Response, Invocation ID
  • Use for: Response processing, content filtering, caching

Before Tool:

  • Triggered before calling a tool
  • Outputs: Tool Name, Tool Arguments, Invocation ID
  • Use for: Argument validation, permission checks, logging

After Tool:

  • Triggered after a tool completes
  • Outputs: Tool Name, Tool Response, Invocation ID
  • Use for: Result processing, error handling, logging

Usage Notes

  • Must Use Callback Out - Every callback workflow must end with a Callback Out node to return control
  • Connection Required - Connect to an agent's callbacks port for the callback to be registered
  • Multiple Callbacks - You can connect multiple callback nodes of different types to the same agent
  • Execution Flow - Callbacks are synchronous; the agent waits for the callback to complete
  • Error Handling - Enable Continue On Error to prevent callback failures from stopping the agent
  • Caller ID - The Caller ID is automatically set by the agent and used for correlation

Error Handling

The node will return errors in the following cases:

  • Missing Caller ID - Callback context is not properly set
  • Invalid callback type - Unrecognized callback type
  • Connection errors - Not properly connected to an agent
  • Workflow errors - Errors in the callback workflow execution

When Continue On Error is enabled, callback failures won't stop the agent execution.

Example Workflows

Logging Callback:

  1. Callback In (Before Tool)
  2. Log node - Log tool name and arguments
  3. Callback Out - Return control

Validation Callback:

  1. Callback In (Before Agent)
  2. Validation logic - Check if agent should execute
  3. Conditional logic - Allow or reject execution
  4. Callback Out - Return control

Transformation Callback:

  1. Callback In (After Model)
  2. Processing node - Transform LLM response
  3. Update State - Store transformed result
  4. Callback Out - Return control

Best Practices

  • Keep Callbacks Fast - Callbacks block agent execution; keep them lightweight
  • Handle Errors - Use error handling to prevent callback failures from breaking agents
  • Use Appropriate Types - Choose the callback type that matches your needs
  • Avoid State Modification - Be careful when modifying state in callbacks to avoid side effects
  • Return Properly - Always end with Callback Out to return control to the agent
  • Log Strategically - Use callbacks for important events, not every operation

Integration with Agents

To use callbacks with agents:

  1. Add a Callback In node to your workflow
  2. Select the callback type
  3. Connect the Callback In node to an agent's callbacks port
  4. Build the callback workflow
  5. End with a Callback Out node

The agent will automatically trigger the callback at the appropriate time.