Conversation
问题,但同模式在其他资源模块依然存在:调用方一路向下传递 config,但在 ResourceClass.__get_client() 这一层被静默丢弃,导致下层 Client / DataAPI 以空 config 构造 base URL,最终抛出 "account id is not set"。 本次扩展同样修复至 6 个资源模块和 endpoint 调用点: - agent_runtime/runtime: __get_client() 新增 config 形参并转发到 AgentRuntimeClient,14 处调用全部补齐 config 实参 - agent_runtime/endpoint: __get_client() 已接受 config 但 12 处调用未传, 逐一修正;同时修复实例方法 get_async 调用 get_by_id_async 时漏传 config 的同类问题 - credential/credential: 同 runtime 修复模式 - knowledgebase/knowledgebase: 同 runtime 修复模式 - memory_collection/memory_collection: 同 runtime 修复模式 - model/model_service: 同 runtime 修复模式 - model/model_proxy: 同 runtime 修复模式 实际改动只发生在 __*_async_template.py 源文件上,同步版本通过 make codegen 重新生成,确保与 #88 已修复的 sandbox 模块保持完全一致的写法。 收益:调用方在 ResourceClass.method(config=cfg) 处提供的 config 现在能 完整传到 base URL 构造、auth、headers 全链路,不再因 __get_client 层丢失 而触发 account_id 缺失或落到错误 endpoint 的问题。 Change-Id: Iff7177062d1ad574f9a65eb663aff70e670e7fcd Co-developed-by: Claude <noreply@anthropic.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: OhYee <oyohyee@oyohyee.com>
…) config forwarding Agent-Logs-Url: https://github.com/Serverless-Devs/agentrun-sdk-python/sessions/0e50b98f-f5e7-4961-a4fc-b9669d0ee8af Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com> Signed-off-by: OhYee <oyohyee@oyohyee.com>
问题,但同模式在其他资源模块依然存在:调用方一路向下传递 config,但在 ResourceClass.__get_client() 这一层被静默丢弃,导致下层 Client / DataAPI 以空 config 构造 base URL,最终抛出 "account id is not set"。 本次扩展同样修复至 6 个资源模块和 endpoint 调用点: - agent_runtime/runtime: __get_client() 新增 config 形参并转发到 AgentRuntimeClient,14 处调用全部补齐 config 实参 - agent_runtime/endpoint: __get_client() 已接受 config 但 12 处调用未传, 逐一修正;同时修复实例方法 get_async 调用 get_by_id_async 时漏传 config 的同类问题 - credential/credential: 同 runtime 修复模式 - knowledgebase/knowledgebase: 同 runtime 修复模式 - memory_collection/memory_collection: 同 runtime 修复模式 - model/model_service: 同 runtime 修复模式 - model/model_proxy: 同 runtime 修复模式 实际改动只发生在 __*_async_template.py 源文件上,同步版本通过 make codegen 重新生成,确保与 #88 已修复的 sandbox 模块保持完全一致的写法。 收益:调用方在 ResourceClass.method(config=cfg) 处提供的 config 现在能 完整传到 base URL 构造、auth、headers 全链路,不再因 __get_client 层丢失 而触发 account_id 缺失或落到错误 endpoint 的问题。 Change-Id: Iff7177062d1ad574f9a65eb663aff70e670e7fcd Co-developed-by: Claude <noreply@anthropic.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: OhYee <oyohyee@oyohyee.com>
__get_client(config=config) 链式调用超过行宽,需要折行。仅为格式调整, 不改变运行时行为。 Change-Id: Ie74ebdffd6f7f9dec413b60b195d3a019433e258 Co-developed-by: Claude <noreply@anthropic.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: OhYee <oyohyee@oyohyee.com>
a27ca65 to
e6d5dc9
Compare
|
@copilot 这个 PR 的核心修复方向正确( ❌ Blocker — MySQL embedder 维度回归
但 最小复现from unittest.mock import MagicMock, patch
from agentrun.memory_collection import MemoryCollection
from agentrun.memory_collection.model import (
VectorStoreConfig, VectorStoreConfigMysqlConfig,
EmbedderConfig, EmbedderConfigConfig,
)
@patch("agentrun.memory_collection.memory_collection.MemoryCollection._resolve_model_service_config")
@patch("agentrun.credential.Credential.get_by_name")
def test_mysql_embedder_dims(mock_cred, mock_resolve):
mock_cred.return_value = MagicMock(credential_secret="pw")
mock_resolve.return_value = ("https://api.example.com", "sk-fake")
mc = MemoryCollection(
memory_collection_name="t",
vector_store_config=VectorStoreConfig(
provider="alibabacloud_mysql",
mysql_config=VectorStoreConfigMysqlConfig(
host="h", port=3306, db_name="d", user="u",
collection_name="c", credential_name="cred",
vector_dimension=1024,
),
),
embedder_config=EmbedderConfig(
model_service_name="my-model-svc",
config=EmbedderConfigConfig(model="text-embedding-v3"),
),
)
cfg = MemoryCollection._build_mem0_config(mc, None, None)
print(cfg["embedder"]["config"].get("embedding_dims"))
# main 行为: 1024 ✅
# 本 PR 行为: None ❌ <-- regression修复建议(二选一)方案 A(推荐):撤回这段改动,保留原 方案 B:在 embedder 分支同时兼容 MySQL: vector_dimension = None
if memory_collection.vector_store_config:
vsc = memory_collection.vector_store_config
if vsc.config and vsc.config.vector_dimension:
vector_dimension = vsc.config.vector_dimension
elif vsc.mysql_config and vsc.mysql_config.vector_dimension:
vector_dimension = vsc.mysql_config.vector_dimension
if vector_dimension:
embedder_config_dict["embedding_dims"] = vector_dimension需要在 sync 和 async 两条路径都改。 💡 其他建议(非 Blocker)
修复 Blocker 后即可合入。整体方向正确,核心 config 透传 + invoke_openai_async 修复是必要的,只有 1 处变更需要回滚。 |
…em0_config Agent-Logs-Url: https://github.com/Serverless-Devs/agentrun-sdk-python/sessions/39e6e1c4-a68e-4386-ab8c-af3c068c7414 Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com>
Fixed in commit f35715f. The regression was in both vector_dimension: Optional[int] = None
if memory_collection.vector_store_config:
vsc = memory_collection.vector_store_config
if vsc.config and vsc.config.vector_dimension:
vector_dimension = vsc.config.vector_dimension
elif vsc.mysql_config and vsc.mysql_config.vector_dimension:
vector_dimension = vsc.mysql_config.vector_dimension
if vector_dimension:
embedder_config_dict["embedding_dims"] = vector_dimensionAlso added |
|
@copilot 感谢修复 MySQL regression(commit 1. 统一
|
… modules Agent-Logs-Url: https://github.com/Serverless-Devs/agentrun-sdk-python/sessions/6c1e8b76-7ece-4f18-927b-cc1da46732da Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com>
Done in commit a31ba3b. Item 1 — All 120 positional Item 2 — The Item 3 — Likewise, converting the PR from Draft to Ready for review requires a GitHub UI action that I cannot perform. |
When
config(carryingaccount_id, region, credentials, etc.) was passed only at call time (not at construction), it was silently ignored during data-plane base URL assembly, causingValueError: account id is not seteven though a valid config was provided.Three independent bugs:
DataAPIHTTP methods ignoredconfiginwith_path()—get,post,put,patch,delete(and their_asyncvariants), pluspost_file,get_file,get_videoall calledself.with_path(path, query=query)without forwardingconfig. Sincewith_path→get_base_url(config)usesConfig.with_configs(self.config, config), the call-site config never reached URL construction.Sandbox.__get_client()always returned a config-lessSandboxClient()— so even if every downstream method receivedconfig=config, theSandboxDataAPIinstance embedded in the client was initialized with an empty config. The same pattern was present in all other resource modules (AgentRuntime,Endpoint,Credential,KnowledgeBase,MemoryCollection,ModelService,ModelProxy,Tool,Toolset).invoke_openai_asynclazy-init condition bug inagentrun/agent_runtime/runtime.py— The async version checkedendpoint_name in self._data_api AND is None(an impossible state on first call), causingKeyErrorinstead of initializing the data API. Aligned with the correct sync version:not in self._data_api OR is None.Changes
agentrun/utils/data_api.py+__data_api_async_template.py: All 16 HTTP wrapper methods now passconfigtowith_path():agentrun/sandbox/sandbox.py+__sandbox_async_template.pyand all other resource modules (agent_runtime,credential,knowledgebase,memory_collection,model,tool,toolset):__get_client()now accepts and forwardsconfig:All ~120 call sites updated to use keyword form
__get_client(config=config)for consistency and refactor robustness.agentrun/agent_runtime/runtime.py+__runtime_async_template.py: Fixedinvoke_openai_asynclazy-init condition bug. The async version hadendpoint_name in self._data_api AND is None(impossible state on first call), causingKeyErrorinstead of initializing the data API. Aligned with the (correct) sync version:not in self._data_api OR is None.agentrun/memory_collection/memory_collection.py+__memory_collection_async_template.py: Restored two-branchvector_dimensionlookup so MySQL provider (mysql_config.vector_dimension) is handled alongside DashVector (config.vector_dimension) when populatingembedder_config["embedding_dims"]. Added regression tests for both sync and async paths.