Skip to content

Fix #475: GetUserProfileInput 缺少 百炼记忆库ID(memory_library_id)/GetUserPr...#487

Open
JiwaniZakir wants to merge 1 commit intoagentscope-ai:mainfrom
JiwaniZakir:fix/475-getuserprofileinput-id-memory-library-id
Open

Fix #475: GetUserProfileInput 缺少 百炼记忆库ID(memory_library_id)/GetUserPr...#487
JiwaniZakir wants to merge 1 commit intoagentscope-ai:mainfrom
JiwaniZakir:fix/475-getuserprofileinput-id-memory-library-id

Conversation

@JiwaniZakir
Copy link
Copy Markdown

Closes #475

Description

Adds the optional memory_library_id field to GetUserProfileInput in schemas.py, and threads it through the GET request in core.py. Without this field, GetUserProfile always targets the default Bailian memory library; with it, callers can specify an alternate library — consistent with how other inputs in this module already handle memory_library_id.

Related Issue: Fixes #475

Security Considerations: N/A

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactoring

Component(s) Affected

  • Engine
  • Sandbox
  • Tools
  • Common
  • Documentation
  • Tests
  • CI/CD

Checklist

  • Pre-commit hooks pass
  • Tests pass locally
  • Documentation updated (if needed)
  • Ready for review

Testing

New unit test test_get_user_profile_input_memory_library_id in tests/tools/test_modelstudio_memory.py covers both cases:

  • GetUserProfileInput(schema_id="schema_123", user_id="user_456")memory_library_id is None, request params contain only user_id
  • GetUserProfileInput(schema_id="schema_123", user_id="user_456", memory_library_id="lib_789")memory_library_id == "lib_789", and core.py appends it to the query params dict before calling self._request

Run with:

pytest tests/tools/test_modelstudio_memory.py -v

Additional Notes

The Config inner class with extra = "allow" is added to GetUserProfileInput to stay consistent with sibling input models in the same file. The change in core.py (lines 556–561) builds the params dict conditionally so memory_library_id is only sent when explicitly provided, avoiding unintended overrides of the default library on the API side.


This PR was created with AI assistance (Claude). The changes were reviewed by quality gates and a critic model before submission.

@JiwaniZakir JiwaniZakir requested review from a team and Copilot April 15, 2026 16:03
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for selecting a non-default Bailian memory library when retrieving a user profile via the ModelStudio Memory tool, addressing issue #475.

Changes:

  • Add optional memory_library_id to GetUserProfileInput (schemas).
  • Include memory_library_id in GetUserProfile GET query params when provided (core).
  • Add a unit test asserting the new input field is accepted (tests).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/tools/test_modelstudio_memory.py Adds a test for the new GetUserProfileInput.memory_library_id field.
src/agentscope_runtime/tools/modelstudio_memory/schemas.py Extends GetUserProfileInput with optional memory_library_id and allows extra fields.
src/agentscope_runtime/tools/modelstudio_memory/core.py Conditionally appends memory_library_id to the GET request query params.

Comment on lines +307 to +312
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",
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GetUserProfileInput 缺少 百炼记忆库ID(memory_library_id)/GetUserProfileInput is missing the Bailian memory library ID (memory_library_id).

3 participants