From dc414cb5078326b8c582b3b9072cbda748766286 Mon Sep 17 00:00:00 2001 From: Shangjie Chen Date: Mon, 7 Jul 2025 02:13:24 -0700 Subject: [PATCH] chore: Add docstring to clarify that inmemory service are not suitable for production environment Resolves https://github.com/google/adk-python/issues/1569 PiperOrigin-RevId: 780013850 --- src/google/adk/artifacts/in_memory_artifact_service.py | 9 ++++++--- src/google/adk/memory/in_memory_memory_service.py | 5 +++-- src/google/adk/sessions/in_memory_session_service.py | 6 +++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/google/adk/artifacts/in_memory_artifact_service.py b/src/google/adk/artifacts/in_memory_artifact_service.py index 1dd724bb..e4837695 100644 --- a/src/google/adk/artifacts/in_memory_artifact_service.py +++ b/src/google/adk/artifacts/in_memory_artifact_service.py @@ -11,8 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - -"""An in-memory implementation of the artifact service.""" +from __future__ import annotations import logging from typing import Optional @@ -28,7 +27,11 @@ logger = logging.getLogger("google_adk." + __name__) class InMemoryArtifactService(BaseArtifactService, BaseModel): - """An in-memory implementation of the artifact service.""" + """An in-memory implementation of the artifact service. + + It is not suitable for multi-threaded production environments. Use it for + testing and development only. + """ artifacts: dict[str, list[types.Part]] = Field(default_factory=dict) diff --git a/src/google/adk/memory/in_memory_memory_service.py b/src/google/adk/memory/in_memory_memory_service.py index a49aca5b..129ba5bc 100644 --- a/src/google/adk/memory/in_memory_memory_service.py +++ b/src/google/adk/memory/in_memory_memory_service.py @@ -11,8 +11,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - - from __future__ import annotations import re @@ -43,6 +41,9 @@ class InMemoryMemoryService(BaseMemoryService): """An in-memory memory service for prototyping purpose only. Uses keyword matching instead of semantic search. + + It is not suitable for multi-threaded production environments. Use it for + testing and development only. """ def __init__(self): diff --git a/src/google/adk/sessions/in_memory_session_service.py b/src/google/adk/sessions/in_memory_session_service.py index b2a84eff..70e75411 100644 --- a/src/google/adk/sessions/in_memory_session_service.py +++ b/src/google/adk/sessions/in_memory_session_service.py @@ -33,7 +33,11 @@ logger = logging.getLogger('google_adk.' + __name__) class InMemorySessionService(BaseSessionService): - """An in-memory implementation of the session service.""" + """An in-memory implementation of the session service. + + It is not suitable for multi-threaded production environments. Use it for + testing and development only. + """ def __init__(self): # A map from app name to a map from user ID to a map from session ID to