{"record":{"id":"b7ad891fbd5fd9db","repo":"BerriAI/litellm","slug":"error-getting-agent-from-db-e","errorCode":null,"errorMessage":"Error getting agent from DB: {e}","messagePattern":"Error getting agent from DB: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/agent_endpoints/agent_registry.py","lineNumber":586,"sourceCode":"        \"\"\"\n        Get an agent by its ID from the database\n        \"\"\"\n        try:\n            for agent in self.agent_list:\n                if agent.agent_id == agent_id:\n                    return agent\n\n            translated_id: Final = self.config_agent_legacy_ids.get(agent_id)\n            if translated_id is None:\n                return None\n\n            for agent in self.agent_list:\n                if agent.agent_id == translated_id:\n                    return agent\n\n            return None\n        except Exception as e:\n            raise Exception(f\"Error getting agent from DB: {e}\")\n\n    def get_agent_by_name(self, agent_name: str) -> AgentResponse | None:\n        \"\"\"\n        Get an agent by its name from the database\n        \"\"\"\n        try:\n            for agent in self.agent_list:\n                if agent.agent_name == agent_name:\n                    return agent\n\n            return None\n        except Exception as e:\n            raise Exception(f\"Error getting agent from DB: {e}\")\n\n\nglobal_agent_registry: Final = AgentRegistry()\n","sourceCodeStart":568,"sourceCodeEnd":603,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/agent_endpoints/agent_registry.py#L568-L603","documentation":"Except-handler in get_agent: an unexpected error escaped while searching the in-memory list / legacy-id map; the message wraps the underlying exception, usually indicating a registry state bug rather than a missing agent.","triggerScenarios":"Thrown at litellm/proxy/agent_endpoints/agent_registry.py:586 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check database connectivity and that the agent exists."],"exampleFix":"Verify DATABASE_URL and agent ID.","handlingStrategy":"try-catch","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-14T00:17:10.932Z"}