Skip to main content
Agent management settings let you configure preprocessing logic and manage the agent lifecycle.

Agent Pre-Processor

The Agent Pre-Processor lets you run custom scripts before an agent is invoked. Scripts can access system memory and context variables to perform data transformation, validation, and context preparation. The configured script runs automatically each time the agent is invoked.
This feature is currently enabled on request.

Common Use Cases

Use CaseDescription
SecurityContent moderation
ValidationInput normalization, schema enforcement, and type checking
EnrichmentAdding user metadata, timestamps, and domain tags
CustomizationDomain-specific prompts and tool filtering

Available Context Keys

The following keys are available within the script, along with any context and memory variables:
KeyDescription
inputThe user input being processed
task_inputThe structured payload passed to the agent for this execution
agent_promptThe prompt used to guide the agent’s behavior and responses
available_toolsMetadata about the tools, agents, and events the agent can use. Contents vary based on the app’s orchestration pattern

Adding a Pre-Processor Script

  1. In the agent configuration, go to Pre-ProcessorAdd Script.
  2. Write your script in JavaScript or Python using the available context keys listed above.
  3. Click Test Execution to verify the script’s behavior.
  4. Click Create to save.
There is no execution timeout for scripts. Ensure your script does not introduce unnecessary delays.

Example Script

The following script adds HR-specific guidance to the agent prompt and appends a timestamp to the task input.
// Read values from the execution context
var prompt = $agent_prompt;
var tools = $available_tools;
var input = $input;
var task_input = $task_input;

// Add HR-specific guidance to the prompt
var updatedPrompt = prompt + "\n\nYou are an HR assistant. Answer concisely and use only verified HR policies.";

// Append a timestamp to the task input
var updatedTaskInput = {
    ...task_input,
    timestamp: new Date().toISOString()
};

// Return updated fields to the agent engine
return {
    agent_prompt: updatedPrompt,
    available_tools: [tools[0]],   // Example: restrict to the first tool
    task_input: updatedTaskInput,
    input: input
};

Delete Agent

Click Delete Agent to permanently delete the agent and all associated data. This action cannot be undone.