From c3b09009d2aed3dc7a211a442876ac17db1e40a0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 22 Apr 2026 13:38:19 +0000 Subject: [PATCH 1/2] Initial plan From 54bea5039a473564203fa2e885cec5acd77ef8d6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 22 Apr 2026 13:43:36 +0000 Subject: [PATCH 2/2] fix: add ALIBABA_CLOUD_REGION_ID as fallback env var for region_id in Config Agent-Logs-Url: https://github.com/Serverless-Devs/agentrun-sdk-python/sessions/8ff9ee10-db3b-46f6-b71e-d98fea33a4f7 Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com> --- agentrun/utils/config.py | 4 +++- tests/unittests/utils/test_config_extended.py | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/agentrun/utils/config.py b/agentrun/utils/config.py index 47fb51d..59354a8 100644 --- a/agentrun/utils/config.py +++ b/agentrun/utils/config.py @@ -99,6 +99,8 @@ def __init__( Read from env vars if not provided: AGENTRUN_ACCOUNT_ID or FC_ACCOUNT_ID token: 自定义令牌,用于数据链路调用 / Custom token for data API calls region_id: 区域 ID,默认 cn-hangzhou / Region ID, defaults to cn-hangzhou + 未提供时从环境变量读取: AGENTRUN_REGION、FC_REGION 或 ALIBABA_CLOUD_REGION_ID + Read from env vars if not provided: AGENTRUN_REGION, FC_REGION or ALIBABA_CLOUD_REGION_ID timeout: 请求超时时间(秒),默认 600 / Request timeout in seconds, defaults to 600 read_timeout: 读取超时时间(秒),默认 100000 / Read timeout in seconds, defaults to 100000 control_endpoint: 自定义控制链路端点,可选 / Custom control endpoint, optional @@ -127,7 +129,7 @@ def __init__( ) if region_id is None: region_id = get_env_with_default( - "cn-hangzhou", "AGENTRUN_REGION", "FC_REGION" + "cn-hangzhou", "AGENTRUN_REGION", "FC_REGION", "ALIBABA_CLOUD_REGION_ID" ) if control_endpoint is None: control_endpoint = get_env_with_default( diff --git a/tests/unittests/utils/test_config_extended.py b/tests/unittests/utils/test_config_extended.py index ee30ef9..078b466 100644 --- a/tests/unittests/utils/test_config_extended.py +++ b/tests/unittests/utils/test_config_extended.py @@ -93,6 +93,29 @@ def test_init_from_env_alibaba_cloud_vars(self): assert config.get_account_id() == "fc_account" assert config.get_region_id() == "cn-beijing" + def test_init_from_env_alibaba_cloud_region_id(self): + """测试从 ALIBABA_CLOUD_REGION_ID 环境变量读取 region_id""" + with patch.dict( + os.environ, + {"ALIBABA_CLOUD_REGION_ID": "cn-shanghai"}, + clear=True, + ): + config = Config() + assert config.get_region_id() == "cn-shanghai" + + def test_region_id_env_priority_agentrun_over_alibaba(self): + """测试 AGENTRUN_REGION 优先于 ALIBABA_CLOUD_REGION_ID""" + with patch.dict( + os.environ, + { + "AGENTRUN_REGION": "cn-hangzhou", + "ALIBABA_CLOUD_REGION_ID": "cn-shanghai", + }, + clear=True, + ): + config = Config() + assert config.get_region_id() == "cn-hangzhou" + def test_with_configs_class_method(self): """测试 with_configs 类方法""" config1 = Config(access_key_id="id1", region_id="cn-hangzhou")