Skip to content

Conversation

@penghuima
Copy link
Collaborator

… configuration

Change-Id: I715f9c34f82bd49bd56611ca16d21b9dd0eee953
Co-developed-by: Cursor noreply@cursor.com

Thank you for creating a pull request to contribute to Serverless Devs agentrun-sdk-python code! Before you open the request please answer the following questions to help it be more easily integrated. Please check the boxes "[ ]" with "[x]" when done too.
Please select one of the PR types below to complete


Fix bugs

Bug detail

The specific manifestation of the bug or the associated issue.

Pull request tasks

  • Add test cases for the changes
  • Passed the CI test

Update docs

Reason for update

Why do you need to update your documentation?

Pull request tasks

  • Update Chinese documentation
  • Update English documentation

Add contributor

Contributed content

  • Code
  • Document

Content detail

if content_type == 'code' || content_type == 'document':
    please tell us `PR url`,like: https://github.com/Serverless-Devs/agentrun-sdk-python/pull/1
else:
    please describe your contribution in detail

Others

Reason for update

Why do you need to update your documentation?

… configuration

Change-Id: I715f9c34f82bd49bd56611ca16d21b9dd0eee953
Co-developed-by: Cursor <noreply@cursor.com>
Signed-off-by: 久氢 <mapenghui.mph@alibaba-inc.com>
Copy link
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

This pull request adds support for AsyncMemory in the memory collection module and introduces vector dimension configuration for embedders. The changes enable asynchronous memory operations and proper configuration of embedding dimensions from vector store settings.

Changes:

  • Updated agentrun-mem0ai dependency from version 0.0.6 to 0.0.10
  • Added AsyncMemory support alongside existing Memory functionality with proper async/await patterns
  • Implemented automatic vector dimension propagation from vector store config to embedder config

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pyproject.toml Bumped agentrun-mem0ai dependency to 0.0.10
agentrun/memory_collection/memory_collection.py Auto-generated file with AsyncMemory support and vector dimension config
agentrun/memory_collection/__memory_collection_async_template.py Source template with AsyncMemory conversion and vector dimension extraction logic
codegen/codegen.py Added AsyncMemory -> Memory string replacement for sync code generation
examples/memory_collection_example.py Added async_mem0_memory_example function demonstrating AsyncMemory usage
tests/unittests/memory_collection/test_memory_collection.py Added test class for to_mem0_memory and to_mem0_memory_async methods

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mock_control_api_class.return_value = mock_control_api

# Mock import 失败
with patch("builtins.__import__", side_effect=ImportError("No module")):
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The test is using patch("builtins.__import__") to mock import failures, but the actual code uses a try-except block with from agentrun_mem0 import Memory. This approach won't work because the from X import Y statement is not the same as calling __import__. The test should instead patch the module agentrun_mem0.Memory or use patch.dict('sys.modules') to simulate the module not being available.

Copilot uses AI. Check for mistakes.
mock_control_api_class.return_value = mock_control_api

# Mock import 失败
with patch("builtins.__import__", side_effect=ImportError("No module")):
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The test is using patch("builtins.__import__") to mock import failures, but the actual code uses a try-except block with from agentrun_mem0 import AsyncMemory. This approach won't work because the from X import Y statement is not the same as calling __import__. The test should instead patch the module agentrun_mem0.AsyncMemory or use patch.dict('sys.modules') to simulate the module not being available.

Copilot uses AI. Check for mistakes.

if __name__ == "__main__":
asyncio.run(main())
import asyncio
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The module asyncio is already imported at the top of the file (line 8), so this re-import is redundant and should be removed.

Suggested change
import asyncio

Copilot uses AI. Check for mistakes.
Comment on lines +623 to +637
embedder_config_dict = {
"model": embedder_config.config.model,
"openai_base_url": base_url,
"api_key": api_key,
}

# 从 vector_store_config 中获取向量维度
if (
memory_collection.vector_store_config
and memory_collection.vector_store_config.config
and memory_collection.vector_store_config.config.vector_dimension
):
embedder_config_dict["embedding_dims"] = (
memory_collection.vector_store_config.config.vector_dimension
)
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The new vector dimension configuration logic (lines 623-637 and 747-761) that extracts vector_dimension from vector_store_config and adds it as embedding_dims to the embedder configuration is not covered by tests. Consider adding test cases to verify that this configuration is correctly passed to the mem0 config when vector_dimension is present.

Copilot uses AI. Check for mistakes.
@OhYee OhYee merged commit 111e9a8 into main Jan 20, 2026
8 checks passed
@OhYee OhYee deleted the dev-0120 branch January 20, 2026 08:25
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.

3 participants