Skip to content

Creating a tool from a file failed when generating schema #2511

@lemorage

Description

@lemorage

Describe the bug
The following error will be raised using the "creating a tool from a file" functionality, however, there is no param 'id' in the tool. Please take a look at the reproduce steps for details.

letta_client.core.api_error.ApiError: status_code: 400, body: {'detail': "400: Sc
hema generation failed: Value error in schema generation: Parameter 'id' in funct
ion 'ManageInventoryTool' lacks a description in the docstring", 'trace_id': '85d
72535a2e0c1a3aba659a88844e49d'}

How to reproduce

  1. Using the following code snippet copied from letta custom-tools docs, add some docstrings and put those into a separate file.
from letta_client import Letta
from letta_client.client import BaseTool
from pydantic import BaseModel
from typing import List, Type

class InventoryItem(BaseModel):
    sku: str  # Unique product identifier
    name: str  # Product name
    price: float  # Current price
    category: str  # Product category (e.g., "Electronics", "Clothing")

class InventoryEntry(BaseModel):
    timestamp: int  # Unix timestamp of the transaction
    item: InventoryItem  # The product being updated
    transaction_id: str  # Unique identifier for this inventory update

class InventoryEntryData(BaseModel):
    data: InventoryEntry
    quantity_change: int  # Change in quantity (positive for additions, negative for removals)


class ManageInventoryTool(BaseTool):
    name: str = "manage_inventory"
    args_schema: Type[BaseModel] = InventoryEntryData
    description: str = "Update inventory catalogue with a new data entry"
    tags: List[str] = ["inventory", "shop"]

    def run(self, data: InventoryEntry, quantity_change: int) -> bool:
        print(f"Updated inventory for {data.item.name} with a quantity change of {quantity_change}")
        return True
  1. run the following code to create a tool from that file.
tool = client.tools.create(
    source_code = open("custom_tool.py", "r").read()
)
  1. the server will complain about the following, but there is no param called id in the above tool.
Traceback (most recent call last):
  File "/Users/clannad/Library/Caches/pypoetry/virtualenvs/yanara-BBYGsHMK-py3.12/lib/python3.12/site-packages/letta/functions/functions.py", line 51, in derive_openai_json_schema
    raise LettaToolCreateError(f"Value error in schema generation: {str(e)}")
letta.errors.LettaToolCreateError: Value error in schema generation: Parameter 'id' in function 'ManageInventoryTool' lacks a description in the docstring
Error occurred during tool creation: Schema generation failed: Value error in schema generation: Parameter 'id' in function 'ManageInventoryTool' lacks a description in the docstring
Traceback (most recent call last):
  File "/Users/clannad/Library/Caches/pypoetry/virtualenvs/yanara-BBYGsHMK-py3.12/lib/python3.12/site-packages/letta/functions/functions.py", line 45, in derive_openai_json_schema
    schema = generate_schema(func, name=name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/clannad/Library/Caches/pypoetry/virtualenvs/yanara-BBYGsHMK-py3.12/lib/python3.12/site-packages/letta/functions/schema_generator.py", line 352, in generate_schema
    raise ValueError(f"Parameter '{param.name}' in function '{function.__name__}' lacks a description in the docstring")
ValueError: Parameter 'id' in function 'ManageInventoryTool' lacks a description in the docstring

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/clannad/Library/Caches/pypoetry/virtualenvs/yanara-BBYGsHMK-py3.12/lib/python3.12/site-packages/letta/functions/functions.py", line 51, in derive_openai_json_schema
    raise LettaToolCreateError(f"Value error in schema generation: {str(e)}")
letta.errors.LettaToolCreateError: Value error in schema generation: Parameter 'id' in function 'ManageInventoryTool' lacks a description in the docstring

Please describe your setup

  • How did you install letta?
    • pip install letta
  • Describe your setup
    • MacOS
    • Terminal

Letta Config

[defaults]
preset = memgpt_chat
persona = sam_pov
human = basic

[archival_storage]
type = postgres
path = /Users/clannad/.letta
uri = postgresql://postgres:@/postgres?host=/Users/clannad/.letta/desktop_data

[recall_storage]
type = postgres
path = /Users/clannad/.letta
uri = postgresql://postgres:@/postgres?host=/Users/clannad/.letta/desktop_data

[metadata_storage]
type = sqlite
path = /Users/clannad/.letta

[version]
letta_version = 0.6.43

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions