From d2d9221322b691b192816fce460a73f472779ebb Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Thu, 7 May 2026 13:28:43 -0700 Subject: [PATCH] feat(v2 managed agents): backstop UNIQUE(name, created_by) in migration SQL --- .../20260507120000_add_managed_agent_tables/migration.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20260507120000_add_managed_agent_tables/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260507120000_add_managed_agent_tables/migration.sql index 2e535797915..097c2ef495b 100644 --- a/litellm-proxy-extras/litellm_proxy_extras/migrations/20260507120000_add_managed_agent_tables/migration.sql +++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20260507120000_add_managed_agent_tables/migration.sql @@ -40,3 +40,9 @@ CREATE INDEX IF NOT EXISTS "LiteLLM_ManagedAgentSession_created_by_idx" ON "Lite -- CreateIndex CREATE INDEX IF NOT EXISTS "LiteLLM_ManagedAgentSession_status_idx" ON "LiteLLM_ManagedAgentSession"("status"); + +-- CreateIndex +-- Backstop for the application-level (name, created_by) duplicate check — +-- catches the read-then-write race when two concurrent POST /v2/agents +-- requests both pass the pre-query and try to insert at the same time. +CREATE UNIQUE INDEX IF NOT EXISTS "LiteLLM_ManagedAgent_name_created_by_key" ON "LiteLLM_ManagedAgent"("name", "created_by");