Overview

When working with custom agents in Narada, you can provide input variables beyond the simple prompt string. This allows for more sophisticated data passing and enables your custom agents to access structured information during execution.

Video Walkthrough

Watch this demonstration of input variables in action:

Default Behavior

When calling a custom agent with a simple prompt, the string becomes the $userQuery variable:
# Simple prompt - becomes $userQuery variable
await window.agent(
    prompt="Search for the latest AI research papers",
    agent="my-custom-agent"
)
In your custom agent, this would be accessible as:
  • $userQuery = “Search for the latest AI research papers”

Providing Multiple Input Variables

To provide more than just the $userQuery value, use the inputVariables= format with a JSON object:
await window.agent(
    prompt="""
    inputVariables={
        "searchTerm": "artificial intelligence",
        "maxResults": 5,
        "includeAbstracts": true,
        "keywords": ["deep learning", "neural networks", "transformers"],
        "websites": [
            "https://arxiv.org",
            "https://scholar.google.com",
            "https://pubmed.ncbi.nlm.nih.gov"
        ],
        "userQuery": "Find recent AI papers"
    }
    """,
    agent="research-assistant"
)

Variable Types

Input variables support basic JSON data types:

Strings

"searchTerm": "machine learning"
Text values for search terms, descriptions, etc.

Numbers

"maxResults": 10,
"threshold": 0.85
Integer and floating-point values for limits and scores.

Booleans

"includeImages": true,
"strictMode": false
True/false values for feature flags and options.

Arrays

"tags": ["ai", "ml", "research"],
"websites": ["site1.com", "site2.com"]
Lists of basic values like strings, numbers, or booleans.
Complex nested objects are not supported yet. Use only basic data types (strings, numbers, booleans) and arrays of basic types.

Best Practices

1

Use Descriptive Variable Names

Choose clear, descriptive names for your input variables:
# Good
"searchQuery": "AI research",
"maxResults": 10,
"includeMetadata": true

# Avoid
"q": "AI research",
"max": 10,
"meta": true
2

Include userQuery When Needed

If your custom agent expects a main user query, include it explicitly:
inputVariables={
    "specificData": "some value",
    "userQuery": "The main user instruction"
}
3

Validate JSON Format

Ensure your JSON is properly formatted. Use tools or linters to validate syntax:
# Properly escaped quotes and valid JSON structure
inputVariables={
    "message": "This is a \"quoted\" string",
    "data": {"nested": "value"}
}
4

Use Basic Data Types Only

Stick to basic data types - complex nested objects are not supported:
# Supported
inputVariables={
    "count": 5,                    # Number
    "enabled": true,               # Boolean
    "searchTerm": "AI research",   # String
    "tags": ["ai", "ml", "nlp"],   # Array of strings
    "scores": [0.8, 0.9, 0.7]      # Array of numbers
}

# Not supported
inputVariables={
    "config": {                    # Nested objects not supported
        "timeout": 30,
        "retries": 3
    }
}

Next Steps

Start with simple input variables and gradually add complexity as your custom agents become more sophisticated. This approach makes debugging easier and helps you understand which variables provide the most value.