Create and test lambda tools
To create a Lambda Tool with the API:
- Meet the following prerequisites:
- Access to the Vectara API with tool creation permissions.
- Basic Python familiarity.
- API key.
- Define a simple function. The entry point must be
process.
This example calculates customer scores based on their activity metrics:CUSTOMER_SCORE_CALCULATOR.PY
Code example with python syntax.1Notes- Use type annotations for automatic schema discovery.
- Parameters with default values become optional in the schema.
- Return a JSON-serializable dictionary.
- Create the Lambda Tool with the API.
Example response:
CREATE LAMBDA TOOL REQUEST
Code example with curl syntax.1CREATE LAMBDA TOOL RESPONSE
Code example with json syntax.1
The input and output schemas were automatically discovered from the function's type annotations.
Test Lambda Tools​
Before deploying your Lambda Tool to agents, test it with sample inputs to verify correct behavior.
Test your Lambda Tool​
TEST LAMBDA TOOL REQUEST
Code example with curl syntax.1
Test Response:
TEST LAMBDA TOOL RESPONSE
Code example with json syntax.1
Update lambda tools​
Modify existing Lambda Tools to update code, configuration, or metadata:
UPDATE LAMBDA TOOL REQUEST
Code example with curl syntax.1
When you update the code, schemas are automatically re-discovered from the new function signature.
List all lambda tools​
LIST LAMBDA TOOLS
Code example with curl syntax.1
Disable a lambda tool​
DISABLE LAMBDA TOOL
Code example with curl syntax.1
Delete a lambda tool​
DELETE LAMBDA TOOL
Code example with curl syntax.1
Available Python libraries​
Lambda Tools run in a secure sandbox on Python 3.12. Your code can import the Python standard library plus preinstalled third-party packages including:
numpy- Numerical arrays and vectorized mathpandas- DataFrames for tabular data analysispython-calamine,openpyxl, andxlrd- Spreadsheet reading; importpython-calamineaspython_calaminexlsxwriter- XLSX generationpython-pptx- PPTX creation and editing; import it aspptxpython-docx- DOCX creation and editing; import it asdocx
Commonly used standard-library modules include json for encoding and decoding,
math for mathematical functions, datetime for dates and times, collections
for container datatypes, itertools and functools for iterator and
higher-order functions, re for regular expressions, time for time access, and
typing for type hints.
Lambda Tools cannot:
- Install additional packages (pip install is not available)
- Access the network directly (use composable lambda tools to call tools like
web_getinstead) - Persist state between executions — the temporary workspace is writable but discarded after each execution
max_memory_mbThe max_memory_mb field on a lambda tool's execution configuration is
deprecated and ignored. Memory is fixed by the execution environment and cannot
be configured per function. Setting the field has no effect.
Use a lambda tool with an agent​
After creating a Lambda Tool, you can configure agents to use it through inline tool configurations. You reference the tool by its ID and optionally provide argument overrides.
Inline configuration​
Use an inline configuration to point an agent to an existing Lambda Tool by ID:
INLINE LAMBDA TOOL CONFIGURATION (INSIDE AGENT)
Code example with json syntax.1
The argument_override field allows you to:
- Hardcode specific values that the LLM cannot change (e.g.,
"customer_tier": "enterprise") - Use dynamic context references with
$refto pull values from session or agent metadata (e.g.,{"$ref": "session.metadata.search_query"})
Reusable Lambda tool configuration​
You can also create a reusable LambdaToolConfiguration that can be referenced across multiple agents.
This approach is useful for consistent, governed usage of Lambda Tools.
CREATE REUSABLE LAMBDA TOOL CONFIGURATION
Code example with curl syntax.1
Then reference this configuration in your agent:
REFERENCE LAMBDA TOOL CONFIGURATION IN AGENT
Code example with json syntax.1