{"record":{"id":"ba69cea50e229dcf","repo":"oraios/serena","slug":"cannot-activate-project-project-project-name","errorCode":null,"errorMessage":"Cannot activate project '{project.project_name}': it requires the {project_backend.value} backend, but this session was initialized with {self._language_backend.value}. Workarounds: (1) Use project activation at startup via the --project flag, (2) Configure one MCP server per backend in your client.","messagePattern":"Cannot activate project '(.+?)': it requires the (.+?) backend, but this session was initialized with (.+?)\\. Workarounds: \\(1\\) Use project activation at startup via the --project flag, \\(2\\) Configure one MCP server per backend in your client\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/serena/agent.py","lineNumber":1226,"sourceCode":"        \"\"\"\n        return self._language_backend == LanguageBackend.LSP\n\n    def _activate_project(self, project: Project, update_active_modes: bool = True, update_active_tools: bool = True) -> bool:\n        \"\"\"\n        :return: True if the project was newly activated, False if it was already active\n        \"\"\"\n        # check if the project is already active\n        if self._active_project is not None and self._active_project.project_root == project.project_root:\n            return False\n\n        log.info(f\"Activating {project.project_name} at {project.project_root}\")\n\n        self._project_activation_error = None\n\n        # check if the project requires a different language backend than the one initialized at startup\n        project_backend = project.project_config.language_backend\n        if project_backend is not None and project_backend != self._language_backend:\n            raise ValueError(\n                f\"Cannot activate project '{project.project_name}': it requires the {project_backend.value} backend, \"\n                f\"but this session was initialized with {self._language_backend.value}. \"\n                f\"Workarounds: (1) Use project activation at startup via the --project flag, \"\n                f\"(2) Configure one MCP server per backend in your client.\"\n            )\n\n        # shut down the previously active project to release its language server processes\n        if self._active_project is not None:\n            log.info(f\"Shutting down previously active project '{self._active_project.project_name}' before switching\")\n            self._active_project.shutdown()\n\n        self._active_project = project\n        project.set_agent(self)\n\n        if update_active_modes:\n            active_mode_names_before = set(self._active_modes.get_mode_names())\n            self._update_active_modes()\n            newly_activated_mode_names = set(self._active_modes.get_mode_names()) - active_mode_names_before","sourceCodeStart":1208,"sourceCodeEnd":1244,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/agent.py#L1208-L1244","documentation":"_activate_project rejects projects whose serena.yml declares a language_backend (e.g. solid-lsp vs multilsp) that differs from the backend the current session was initialized with. Because the language server backend is fixed at process start, mid-session activation of a mismatched project would break symbol tooling, so Serena raises ValueError with two documented workarounds.","triggerScenarios":"Calling activate_project_from_path_or_name (or the activate_project tool) for a project whose project_config.language_backend is set and != self._language_backend of the running agent.","commonSituations":"One Serena MCP server instance shared across projects configured with different backends; a project.yml edited to pin a new backend after the session started; switching between single-language (solid-lsp) and multi-language server projects in one client session.","solutions":["Restart Serena with --project pointing at the target project so the session is initialized with the project's backend.","Configure one MCP server per backend in your MCP client (e.g. serena-backend-a, serena-backend-b) and connect to the matching one.","Change the project's language_backend in its .serena/project.yml to match the session backend, if the project supports it."],"exampleFix":"// before (client calls one shared server)\nagent.activate_project_from_path_or_name('other-project')\n// after: start server scoped to the project\n// serena start-mcp-server --project /path/to/other-project\n// then activate is consistent with session backend","handlingStrategy":"validation","validationCode":"def backend_compatible(agent, project) -> bool:\n    pb = project.project_config.language_backend\n    return pb is None or pb == agent._language_backend","typeGuard":"def is_compatible_project(project, session_backend) -> bool:\n    pb = getattr(getattr(project, 'project_config', None), 'language_backend', None)\n    return pb is None or pb == session_backend","tryCatchPattern":"try:\n    agent.activate_project_from_path_or_name(path)\nexcept ValueError as e:\n    if 'backend' in str(e):\n        log.error('Restart serena with --project %s (backend mismatch)', path)\n    raise","preventionTips":["Run one Serena MCP server per language backend in your client configuration.","Pin the project at startup with --project instead of switching projects mid-session across backends.","Keep language_backend consistent across your projects' .serena/project.yml files when sharing one server."],"tags":["configuration","language-backend","project-activation","mcp"],"backgroundTag":"backend-mismatch","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}