{"record":{"id":"a86f574baf6be7e8","repo":"BerriAI/litellm","slug":"agent-with-name-request-get-agent-name-alread","errorCode":null,"errorMessage":"Agent with name {request.get('agent_name')} already exists","messagePattern":"Agent with name (.+?) already exists","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/agent_endpoints/endpoints.py","lineNumber":421,"sourceCode":"    ```\n    \"\"\"\n    await check_feature_access_for_user(user_api_key_dict, \"agents\")\n\n    from litellm.proxy.proxy_server import prisma_client\n\n    _check_agent_management_permission(user_api_key_dict)\n\n    if prisma_client is None:\n        raise HTTPException(status_code=500, detail=\"Prisma client not initialized\")\n\n    try:\n        # Get the user ID from the API key auth\n        created_by: Final = user_api_key_dict.user_id or \"unknown\"\n\n        # check for naming conflicts\n        existing_agent: Final = AGENT_REGISTRY.get_agent_by_name(agent_name=request.get(\"agent_name\"))\n        if existing_agent is not None:\n            raise HTTPException(\n                status_code=400,\n                detail=f\"Agent with name {request.get('agent_name')} already exists\",\n            )\n\n        # Apply the LiteLLM-fronting merge only when the admin actually\n        # provided an agent card. Plain chat/LLM agents register without\n        # ``agent_card_params``, and synthesising a default A2A card for them\n        # would advertise capabilities (``supportedInterfaces``, security\n        # schemes, default skills) the agent doesn't actually expose.\n        upstream_card: Final = request.get(\"agent_card_params\")\n        agent_to_create: AgentConfig = request\n        new_agent_id: str | None = None\n        if upstream_card is not None:\n            # Pre-generate the agent_id so the merged card can reference it\n            # in ``supportedInterfaces`` before the DB row exists.\n            new_agent_id = str(uuid.uuid4())\n            merged_card: Final = _build_merged_agent_card(\n                upstream_card,","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/agent_endpoints/endpoints.py#L403-L439","documentation":"Agent creation checks the in-memory registry for a name conflict before inserting; duplicate agent_name would create ambiguous lookups (by-name resolution), so the create is rejected with the conflicting name.","triggerScenarios":"Thrown at litellm/proxy/agent_endpoints/endpoints.py:421 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a different agent_name; names must be unique."],"exampleFix":"agent_name='my-agent-2'","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}