Skip to main content
Version: 2.0

Create and test lambda tools

To create a Lambda Tool with the API:

  1. Meet the following prerequisites:
    • Access to the Vectara API with tool creation permissions.
    • Basic Python familiarity.
    • API key.
  2. 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.
    1
    Notes
    • Use type annotations for automatic schema discovery.
    • Parameters with default values become optional in the schema.
    • Return a JSON-serializable dictionary.
  3. Create the Lambda Tool with the API.

    CREATE LAMBDA TOOL REQUEST

    Code example with curl syntax.
    1
    Example response:

    CREATE 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 math
  • pandas - DataFrames for tabular data analysis
  • python-calamine, openpyxl, and xlrd - Spreadsheet reading; import python-calamine as python_calamine
  • xlsxwriter - XLSX generation
  • python-pptx - PPTX creation and editing; import it as pptx
  • python-docx - DOCX creation and editing; import it as docx

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.

Security Constraints

Lambda Tools cannot:

  • Install additional packages (pip install is not available)
  • Access the network directly (use composable lambda tools to call tools like web_get instead)
  • Persist state between executions — the temporary workspace is writable but discarded after each execution
Deprecated: max_memory_mb

The 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 $ref to 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