BerriAI/litellm · error · Exception

Error adding agent to DB: {e}

Error message

Error adding agent to DB: {e}

What it means

Wrapper raised when the Prisma create for a new agent row fails for any reason (constraint, connection, serialization); the original exception is chained so the endpoint can surface a 500 with the DB cause.

Source

Thrown at litellm/proxy/agent_endpoints/agent_registry.py:355

                _val = agent.get(rate_field)
                if _val is not None:
                    create_data[rate_field] = _val

            # Create agent in DB
            created_agent: Final = await agents_table(prisma_client).create(
                data=create_data,
                include={"object_permission": True},
            )

            created_agent_dict: Final = created_agent.model_dump()
            if created_agent.object_permission is not None:
                try:
                    created_agent_dict["object_permission"] = created_agent.object_permission.model_dump()
                except Exception:
                    created_agent_dict["object_permission"] = created_agent.object_permission.dict()
            return AgentResponse(**created_agent_dict)
        except Exception as e:
            raise Exception(f"Error adding agent to DB: {e}")

    async def delete_agent_from_db(self, agent_id: str, prisma_client: PrismaClient) -> Mapping[str, object]:
        """
        Delete an agent from the database
        """
        try:
            deleted_agent: Final = await agents_table(prisma_client).delete(where={"agent_id": agent_id})
            return dict(deleted_agent)
        except Exception as e:
            raise Exception(f"Error deleting agent from DB: {e}")

    async def patch_agent_in_db(
        self,
        agent_id: str,
        agent: PatchAgentRequest,
        prisma_client: PrismaClient,
        updated_by: str,
    ) -> AgentResponse:

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Check the database error detail; verify DB connectivity and agent payload validity.

Example fix

Check proxy logs for the DB error.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/proxy/agent_endpoints/agent_registry.py:355 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/470daa7077580c0f. Report an issue: GitHub.