From c67ca5b299eb1c5fcf6c5fcd5313cf323b6bb859 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Wed, 6 May 2026 16:26:44 -0700 Subject: [PATCH] feat(proxy_server): wire /v2 standard error envelope handlers Registers register_v2_exception_handlers on the FastAPI app right after the v2 routers are mounted so HTTPException + ValidationError under /v2/* surface as {error: {code, message, status, details?}}. --- litellm/proxy/proxy_server.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index a962d90a038..a3991049cbd 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -14933,11 +14933,19 @@ if is_agent_jwt_secret_configured(): from litellm.proxy.agent_session_endpoints import ( session_router as agent_session_session_router, ) + from litellm.proxy.agent_session_endpoints.error_envelope import ( + register_v2_exception_handlers, + ) app.include_router(agent_session_agent_router) app.include_router(agent_session_session_router) app.include_router(agent_session_run_router) app.include_router(agent_session_internal_router) + # Wrap HTTPException + RequestValidationError under /v2/* in the + # standard {error: {code, message, status, details?}} envelope so + # SDK consumers have a single error contract. Non-/v2/ paths keep + # FastAPI defaults (handler short-circuits on path prefix). + register_v2_exception_handlers(app) else: verbose_proxy_logger.error( "agent_session_endpoints (/v2/agents, /v2/sessions) NOT mounted: "