diff --git a/src/agentscope_runtime/tools/modelstudio_memory/core.py b/src/agentscope_runtime/tools/modelstudio_memory/core.py index 93331a9f9..adc86b33c 100644 --- a/src/agentscope_runtime/tools/modelstudio_memory/core.py +++ b/src/agentscope_runtime/tools/modelstudio_memory/core.py @@ -553,11 +553,16 @@ async def _arun( # Build URL with path parameter url = self.config.get_user_profile_url(args.schema_id) + # Build query params, including optional memory_library_id + params: dict = {"user_id": args.user_id} + if args.memory_library_id is not None: + params["memory_library_id"] = args.memory_library_id + # Send request with user_id as query parameter result = await self._request( "GET", url, - params={"user_id": args.user_id}, + params=params, ) # Parse response - handle API's camelCase field names diff --git a/src/agentscope_runtime/tools/modelstudio_memory/schemas.py b/src/agentscope_runtime/tools/modelstudio_memory/schemas.py index 0e79b0509..40b19163b 100644 --- a/src/agentscope_runtime/tools/modelstudio_memory/schemas.py +++ b/src/agentscope_runtime/tools/modelstudio_memory/schemas.py @@ -241,6 +241,13 @@ class GetUserProfileInput(BaseModel): schema_id: str = Field(..., description="Profile schema id") user_id: str = Field(..., description="End user id") + memory_library_id: Optional[str] = Field( + None, + description="Optional Bailian memory library id", + ) + + class Config: + extra = "allow" # Allow extra fields class GetUserProfileOutput(BaseModel): diff --git a/tests/tools/test_modelstudio_memory.py b/tests/tools/test_modelstudio_memory.py index cf3455f47..8b59a9373 100644 --- a/tests/tools/test_modelstudio_memory.py +++ b/tests/tools/test_modelstudio_memory.py @@ -302,3 +302,21 @@ async def test_get_user_profile_success( assert isinstance(result, GetUserProfileOutput) if result.profile is not None: assert isinstance(result.profile.attributes, list) + + +def test_get_user_profile_input_memory_library_id(): + """Test that GetUserProfileInput accepts optional memory_library_id.""" + # Without memory_library_id + input_without = GetUserProfileInput( + schema_id="schema_123", + user_id="user_456", + ) + assert input_without.memory_library_id is None + + # With memory_library_id + input_with = GetUserProfileInput( + schema_id="schema_123", + user_id="user_456", + memory_library_id="lib_789", + ) + assert input_with.memory_library_id == "lib_789"