Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/agentscope_runtime/tools/modelstudio_memory/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/agentscope_runtime/tools/modelstudio_memory/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
18 changes: 18 additions & 0 deletions tests/tools/test_modelstudio_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Comment on lines +307 to +312
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new test only validates that the Pydantic model accepts memory_library_id, but it does not assert that GetUserProfile actually includes/excludes memory_library_id in the request query params as described in the PR. Consider extending the test to monkeypatch/mock GetUserProfile._request (or the HTTP client) and assert the params dict contains only user_id when memory_library_id is None, and contains both keys when it is provided (or update the PR description if that coverage is out of scope).

Copilot uses AI. Check for mistakes.
)
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"
Loading