Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: cleanup error trace for no llm/embedding_config on POST (#2218)
Charles Packer223b6bc0a98a
diff --git a/letta/server/rest_api/app.py b/letta/server/rest_api/app.pyindex 9b567bf4a..ebbd58601 100644--- a/letta/server/rest_api/app.py+++ b/letta/server/rest_api/app.py@@ -6,7 +6,7 @@ from pathlib import Pathfrom typing import Optionalimport uvicorn-from fastapi import FastAPI+from fastapi import FastAPI, Requestfrom fastapi.responses import JSONResponsefrom starlette.middleware.base import BaseHTTPMiddlewarefrom starlette.middleware.cors import CORSMiddleware@@ -136,17 +136,18 @@ def create_application() -> "FastAPI":},)+ debug_mode = "--debug" in sys.argvapp = FastAPI(swagger_ui_parameters={"docExpansion": "none"},# openapi_tags=TAGS_METADATA,title="Letta",summary="Create LLM agents with long-term memory and custom tools 📚🦙",version="1.0.0", # TODO wire this up to the version in the package- debug=True,+ debug=debug_mode, # if True, the stack trace will be printed in the response)@app.exception_handler(Exception)- async def generic_error_handler(request, exc):+ async def generic_error_handler(request: Request, exc: Exception):# Log the actual error for debugginglog.error(f"Unhandled error: {exc}", exc_info=True)@@ -166,12 +167,16 @@ def create_application() -> "FastAPI":},)+ @app.exception_handler(ValueError)+ async def value_error_handler(request: Request, exc: ValueError):+ return JSONResponse(status_code=400, content={"detail": str(exc)})+@app.exception_handler(LettaAgentNotFoundError)- async def agent_not_found_handler(request, exc):+ async def agent_not_found_handler(request: Request, exc: LettaAgentNotFoundError):return JSONResponse(status_code=404, content={"detail": "Agent not found"})@app.exception_handler(LettaUserNotFoundError)- async def user_not_found_handler(request, exc):+ async def user_not_found_handler(request: Request, exc: LettaUserNotFoundError):return JSONResponse(status_code=404, content={"detail": "User not found"})settings.cors_origins.append("https://app.letta.com")diff --git a/letta/server/server.py b/letta/server/server.pyindex 609e8eab4..c60abe484 100644--- a/letta/server/server.py+++ b/letta/server/server.py@@ -826,6 +826,12 @@ class SyncServer(Server):if not user:raise ValueError(f"cannot find user with associated client id: {user_id}")+ if request.llm_config is None:+ raise ValueError("llm_config is required")++ if request.embedding_config is None:+ raise ValueError("embedding_config is required")+# created and persist the agent state in the DBagent_state = PersistedAgentState(name=request.name,