{"record":{"id":"aab2e91539b8a4bb","repo":"langchain-ai/deepagents","slug":"notimplementederror-raised-by-abstract-write-ba","errorCode":null,"errorMessage":"NotImplementedError raised by abstract `write` (backend does not implement `write`)","messagePattern":"NotImplementedError raised by abstract `write` \\(backend does not implement `write`\\)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/backends/protocol.py","lineNumber":675,"sourceCode":"        return await asyncio.to_thread(self.glob, pattern, path)\n\n    def write(\n        self,\n        file_path: str,\n        content: str,\n    ) -> WriteResult:\n        \"\"\"Write content to a file, creating it or overwriting it if it already exists.\n\n        Args:\n            file_path: Absolute path where the file should be written.\n\n                Must start with '/'.\n            content: String content to write to the file.\n\n        Returns:\n            WriteResult\n        \"\"\"\n        raise NotImplementedError\n\n    async def awrite(\n        self,\n        file_path: str,\n        content: str,\n    ) -> WriteResult:\n        \"\"\"Async version of write.\"\"\"\n        return await asyncio.to_thread(self.write, file_path, content)\n\n    def edit(\n        self,\n        file_path: str,\n        old_string: str,\n        new_string: str,\n        replace_all: bool = False,  # noqa: FBT001, FBT002\n    ) -> EditResult:\n        \"\"\"Perform exact string replacements in an existing file.\n","sourceCodeStart":657,"sourceCodeEnd":693,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/backends/protocol.py#L657-L693","documentation":"The base Backend class defines `write` as an abstract method raising NotImplementedError; subclasses must implement file writing for the write tool and internal offloading. Internal callers include `_offload_tool_message_content`, `_offload_to_backend`, and `prepopulate_file` — so even read-oriented agents can trigger `write` when large tool outputs are offloaded to backend storage. Hitting this error means the configured backend cannot persist files.","triggerScenarios":"Agent write tool call routed to a read-only custom backend; large tool results auto-offloaded to a backend lacking write; direct call backend.write('/path', content) on the abstract base or partial subclass.","commonSituations":"Mounting a read-only or minimal backend on an agent whose tools include write; offload middleware kicking in during long-running sessions; forgetting the override during backend development.","solutions":["Implement `write(self, file_path, content) -> WriteResult` (paths must start with '/') in your backend subclass.","If the backend is intentionally read-only, use a writable backend (e.g. StateBackend or filesystem) for offloading, or disable the write tool and offloading.","Configure a composite backend: read-only source for reads plus a writable store for writes/offloads."],"exampleFix":"// before\nclass ReadOnlyGitBackend(Backend):\n    def read(self, file_path, offset=0, limit=2000): ...\n    # agent write tool -> NotImplementedError\n// after\nclass ReadOnlyGitBackend(Backend):\n    def read(self, file_path, offset=0, limit=2000): ...\n    def write(self, file_path, content):\n        return WriteResult(error='backend is read-only')  # graceful, or use a writable composite","handlingStrategy":"try-catch","validationCode":"if type(backend).write is Backend.write:\n    raise RuntimeError('backend is not writable; write tool and offloading will fail')","typeGuard":"def supports_write(backend) -> bool:\n    return type(backend).write is not Backend.write","tryCatchPattern":"try:\n    backend.write(file_path, content)\nexcept NotImplementedError:\n    fallback_backend.write(file_path, content)  # e.g. StateBackend for offloads","preventionTips":["Read-only backends must not be the sole backend for agents with the write tool enabled — use a composite.","Remember internal offloading calls write even if your agent never writes files, so read-only-only setups can still break.","Assert write paths start with '/' in your implementation to satisfy the protocol."],"tags":["not-implemented","abstract-method","backend-protocol"],"backgroundTag":"not-implemented","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}