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 with access to the following Python 3.12 standard library modules:

  • json - JSON encoding and decoding
  • math - Mathematical functions
  • datetime - Date and time handling
  • collections - Container datatypes (deque, Counter, OrderedDict, etc.)
  • itertools - Iterator functions
  • functools - Higher-order functions and operations on callable objects
  • re - Regular expression operations
  • time - Time access and conversions
  • typing - Type hints and annotations (List, Dict, Optional, Union, TypedDict, etc.)
Security Constraints

Lambda Tools cannot:

  • Install additional packages (pip install is not available)
  • Access the network (all network operations are blocked)
  • Write to the file system (read-only environment)
  • Execute system commands
  • Import modules outside the allowed list

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