Skip to content

Conversation

zamalali
Copy link

@zamalali zamalali commented Aug 9, 2025

Please describe the purpose of this pull request.
This PR fixes a bug: an ImportError: cannot import name 'Function' from 'openai.types.chat.chat_completion_message_tool_call' encountered when using openai = "^1.60.0". The issue was resolved by updating the OpenAI dependency to >=1.76.2,<1.99 in pyproject.toml and regenerating poetry.lock.

How to test
To test this PR during review: Clone the repository and checkout this branch.
Ensure Poetry is installed and set up the virtual environment:
poetry install
Set the OPENAI_API_KEY environment variable:
export OPENAI_API_KEY="your_openai_api_key" # On Windows: $env:OPENAI_API_KEY="your_openai_api_key"
Start the Letta server:
poetry run letta server
Expected Outcome: The server starts at http://localhost:8283 without the ImportError. Logs should show sqlite-vec extension successfully loaded and no OpenAI-related errors.
Connect to the ADE and interact with an agent (e.g., create or send a chat message).
Expected Outcome: Agent interactions work without OpenAI errors.

Have you tested this PR?
Yes, I tested the latest commit on this PR on Windows 10 with the SQLite backend. Below are the test outputs: Ran poetry run letta server:

Letta.letta.server.db - INFO - Database throttling is disabled
Letta.letta.server.db - INFO - Creating sqlite engine sqlite:///C:\Users\Zamal Ali\.letta\sqlite.db
Letta.letta.orm.sqlite_functions - INFO - sqlite-vec extension successfully loaded for sqlite3 (sync)
Letta.letta.orm.sqlite_functions - INFO - Successfully registered cosine_distance for sync connection
Letta.letta.otel.db_pool_monitoring - INFO - Database pool monitoring initialized for engine: default
Letta.letta.server.db - INFO - Database pool monitoring enabled for default
Letta.letta.otel.metrics - WARNING - Metrics are not initialized or meter is not available.
Letta.letta.server.server - INFO - Successfully created default local sandbox config:
{'sandbox_dir': 'C:\\Users\\Zamal Ali\\.letta\\tool_execution_dir', 'use_venv': False, 'venv_name': 'venv', 'pip_requirements': []}
[[ Letta server // v0.11.2 ]]
Server running at: http://localhost:8283
View using ADE at: https://app.letta.com/development-servers/local/dashboard
INFO:     Started server process [22376]
INFO:     Waiting for application startup.
Letta.letta.server.rest_api.app - INFO - [Worker 22376] Starting lifespan initialization
...
INFO:     Application startup complete.
INFO:     Uvicorn running on http://localhost:8283 (Press CTRL+C to quit)

Outcome: Server started successfully, sqlite-vec loaded, and no OpenAI ImportError occurred.

Tested with ADE: Connected to the local server and performed basic agent interactions (e.g., chat). No OpenAI-related errors were observed.

Related issues or PRs
Searched open issues in letta-ai/letta for ImportError: cannot import name 'Function' from 'openai.types.chat.chat_completion_message_tool_call'. No matching issues found among the 21 open issues. Closest issues include:#2605: Mentions agent crashes with tool calls, potentially related to OpenAI SDK changes but not specific to this ImportError.
#2714: References OpenAI Chat Completion compatibility but doesn’t mention this error.

Is your PR over 500 lines of code?
No, this PR is minimal, modifying only pyproject.toml (1 line, changing openai version) and poetry.lock (dependency updates). The changes are focused and don’t require splitting.

Additional context
Not required for now.

@sarahwooders sarahwooders added the safe to test Lets CI tests which require secrets to be ran label Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test Lets CI tests which require secrets to be ran
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants