Skip to content

Fix config not propagated to data-plane URL construction in DataAPI and Sandbox.__get_client()#88

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-sandbox-delete-config-issue
Draft

Fix config not propagated to data-plane URL construction in DataAPI and Sandbox.__get_client()#88
Copilot wants to merge 4 commits intomainfrom
copilot/fix-sandbox-delete-config-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

When config (carrying account_id, region, credentials, etc.) was passed only at call time (not at construction), it was silently ignored during data-plane base URL assembly, causing ValueError: account id is not set even though a valid config was provided.

Two independent bugs:

  1. DataAPI HTTP methods ignored config in with_path()get, post, put, patch, delete (and their _async variants), plus post_file, get_file, get_video all called self.with_path(path, query=query) without forwarding config. Since with_pathget_base_url(config) uses Config.with_configs(self.config, config), the call-site config never reached URL construction.

  2. Sandbox.__get_client() always returned a config-less SandboxClient() — so even if every downstream method received config=config, the SandboxDataAPI instance embedded in the client was initialized with an empty config.

Changes

  • agentrun/utils/data_api.py + __data_api_async_template.py: All 16 HTTP wrapper methods now pass config to with_path():

    # Before
    self.with_path(path, query=query)
    # After
    self.with_path(path, query=query, config=config)
  • agentrun/sandbox/sandbox.py + __sandbox_async_template.py: __get_client() now accepts and forwards config:

    # Before
    def __get_client(cls):
        return SandboxClient()
    
    # After
    def __get_client(cls, config: Optional[Config] = None):
        return SandboxClient(config=config)

    All ~20 call sites updated to pass config=config.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • astral.sh
    • Triggering command: /usr/bin/curl curl -LsSf REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix Sandbox.delete_by_id config merging issue Fix config not propagated to data-plane URL construction in DataAPI and Sandbox.__get_client() Apr 20, 2026
Copilot AI requested a review from OhYee April 20, 2026 16:14
OhYee added a commit that referenced this pull request Apr 25, 2026
问题,但同模式在其他资源模块依然存在:调用方一路向下传递 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>
Copilot AI and others added 4 commits April 25, 2026 16:32
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>
@OhYee OhYee force-pushed the copilot/fix-sandbox-delete-config-issue branch from a27ca65 to e6d5dc9 Compare April 25, 2026 08:32
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.

Sandbox.delete_by_id 与 DataAPI 在拼数据面 URL 时未合并调用方传入的 config;__get_client() 仍返回无参 SandboxClient

2 participants