From 38bd9a25ec2b1a130fab76e29bf74ae29236a119 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 01:53:09 +0000 Subject: [PATCH 1/4] Initial plan From f2e50700ff5b284bc9a1412f78b9bd0142a5cd96 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 01:56:28 +0000 Subject: [PATCH 2/4] Add auth() calls to post_file and get_file methods Co-authored-by: OhYee <13498329+OhYee@users.noreply.github.com> --- agentrun/utils/__data_api_async_template.py | 6 +++++ agentrun/utils/data_api.py | 28 ++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/agentrun/utils/__data_api_async_template.py b/agentrun/utils/__data_api_async_template.py index 95d104b..c664f7f 100644 --- a/agentrun/utils/__data_api_async_template.py +++ b/agentrun/utils/__data_api_async_template.py @@ -604,6 +604,9 @@ async def post_file_async( url = self.with_path(path, query=query) req_headers = self.config.get_headers() req_headers.update(headers or {}) + # Apply authentication (may modify URL, headers, and query) + cfg = Config.with_configs(self.config, config) + url, req_headers, query = self.auth(url, req_headers, query, config=cfg) try: with open(local_file_path, "rb") as f: @@ -654,6 +657,9 @@ async def get_file_async( url = self.with_path(path, query=query) req_headers = self.config.get_headers() req_headers.update(headers or {}) + # Apply authentication (may modify URL, headers, and query) + cfg = Config.with_configs(self.config, config) + url, req_headers, query = self.auth(url, req_headers, query, config=cfg) try: async with httpx.AsyncClient( diff --git a/agentrun/utils/data_api.py b/agentrun/utils/data_api.py index f3a3d05..1b6a872 100644 --- a/agentrun/utils/data_api.py +++ b/agentrun/utils/data_api.py @@ -447,7 +447,9 @@ def _make_request( ) try: - with httpx.Client(timeout=self.config.get_timeout()) as client: + with httpx.Client( + timeout=self.config.get_timeout() + ) as client: response = client.request( method, url, @@ -856,6 +858,9 @@ async def post_file_async( url = self.with_path(path, query=query) req_headers = self.config.get_headers() req_headers.update(headers or {}) + # Apply authentication (may modify URL, headers, and query) + cfg = Config.with_configs(self.config, config) + url, req_headers, query = self.auth(url, req_headers, query, config=cfg) try: with open(local_file_path, "rb") as f: @@ -915,6 +920,9 @@ def post_file( url = self.with_path(path, query=query) req_headers = self.config.get_headers() req_headers.update(headers or {}) + # Apply authentication (may modify URL, headers, and query) + cfg = Config.with_configs(self.config, config) + url, req_headers, query = self.auth(url, req_headers, query, config=cfg) try: with open(local_file_path, "rb") as f: @@ -923,7 +931,9 @@ def post_file( data = form_data or {} data["path"] = target_file_path - with httpx.Client(timeout=self.config.get_timeout()) as client: + with httpx.Client( + timeout=self.config.get_timeout() + ) as client: response = client.post( url, files=files, data=data, headers=req_headers ) @@ -963,6 +973,9 @@ async def get_file_async( url = self.with_path(path, query=query) req_headers = self.config.get_headers() req_headers.update(headers or {}) + # Apply authentication (may modify URL, headers, and query) + cfg = Config.with_configs(self.config, config) + url, req_headers, query = self.auth(url, req_headers, query, config=cfg) try: async with httpx.AsyncClient( @@ -1009,9 +1022,14 @@ def get_file( url = self.with_path(path, query=query) req_headers = self.config.get_headers() req_headers.update(headers or {}) + # Apply authentication (may modify URL, headers, and query) + cfg = Config.with_configs(self.config, config) + url, req_headers, query = self.auth(url, req_headers, query, config=cfg) try: - with httpx.Client(timeout=self.config.get_timeout()) as client: + with httpx.Client( + timeout=self.config.get_timeout() + ) as client: response = client.get(url, headers=req_headers) response.raise_for_status() @@ -1107,7 +1125,9 @@ def get_video( url, req_headers, query = self.auth(url, req_headers, query, config=cfg) try: - with httpx.Client(timeout=self.config.get_timeout()) as client: + with httpx.Client( + timeout=self.config.get_timeout() + ) as client: response = client.get(url, headers=req_headers) response.raise_for_status() From 0d77025a1047d6bdf92858960bcbd9fced50ce7e Mon Sep 17 00:00:00 2001 From: OhYee Date: Thu, 22 Jan 2026 14:03:37 +0800 Subject: [PATCH 3/4] refactor: fix synchronous method documentation and import statements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated documentation strings to correctly reflect synchronous operations instead of asynchronous ones across multiple modules. Also updated import statements to use the correct runtime options module. fix: 修复同步方法文档和导入语句 更新了多个模块中的文档字符串,正确反映同步操作而不是异步操作。 同时更新了导入语句以使用正确的运行时选项模块。 Change-Id: I38a1ea35939d81b9359634ad80a833bb65278a8e Signed-off-by: OhYee --- agentrun/agent_runtime/client.py | 22 ++++++++--------- agentrun/agent_runtime/endpoint.py | 16 ++++++------ agentrun/agent_runtime/runtime.py | 10 ++++---- agentrun/credential/client.py | 2 +- agentrun/knowledgebase/api/control.py | 2 +- agentrun/knowledgebase/client.py | 10 ++++---- agentrun/knowledgebase/knowledgebase.py | 26 ++++++++++---------- agentrun/memory_collection/api/control.py | 2 +- agentrun/sandbox/aio_sandbox.py | 2 +- agentrun/sandbox/browser_sandbox.py | 2 +- agentrun/sandbox/code_interpreter_sandbox.py | 2 +- agentrun/utils/data_api.py | 16 +++--------- codegen/codegen.py | 1 + 13 files changed, 53 insertions(+), 60 deletions(-) diff --git a/agentrun/agent_runtime/client.py b/agentrun/agent_runtime/client.py index 061cca6..826e047 100644 --- a/agentrun/agent_runtime/client.py +++ b/agentrun/agent_runtime/client.py @@ -111,7 +111,7 @@ async def create_async( def create( self, input: AgentRuntimeCreateInput, config: Optional[Config] = None ) -> AgentRuntime: - """同步创建 Agent Runtime / Create Agent Runtime asynchronously + """同步创建 Agent Runtime / Create Agent Runtime synchronously Args: input: Agent Runtime 创建配置 / Agent Runtime creation configuration @@ -176,7 +176,7 @@ async def delete_async( raise e.to_resource_error("AgentRuntime", id) from e def delete(self, id: str, config: Optional[Config] = None) -> AgentRuntime: - """同步删除 Agent Runtime / Delete Agent Runtime asynchronously + """同步删除 Agent Runtime / Delete Agent Runtime synchronously Args: id: Agent Runtime ID @@ -231,7 +231,7 @@ def update( input: AgentRuntimeUpdateInput, config: Optional[Config] = None, ) -> AgentRuntime: - """同步更新 Agent Runtime / Update Agent Runtime asynchronously + """同步更新 Agent Runtime / Update Agent Runtime synchronously Args: id: Agent Runtime ID @@ -286,7 +286,7 @@ def get( id: str, config: Optional[Config] = None, ) -> AgentRuntime: - """同步获取 Agent Runtime / Get Agent Runtime asynchronously + """同步获取 Agent Runtime / Get Agent Runtime synchronously Args: id: Agent Runtime ID @@ -343,7 +343,7 @@ def list( input: Optional[AgentRuntimeListInput] = None, config: Optional[Config] = None, ) -> List[AgentRuntime]: - """同步列出 Agent Runtimes / List Agent Runtimes asynchronously + """同步列出 Agent Runtimes / List Agent Runtimes synchronously Args: input: 列表查询配置,可选 / List query configuration, optional @@ -417,7 +417,7 @@ def create_endpoint( endpoint: AgentRuntimeEndpointCreateInput, config: Optional[Config] = None, ) -> AgentRuntimeEndpoint: - """同步创建 Agent Runtime 端点 / Create Agent Runtime Endpoint asynchronously + """同步创建 Agent Runtime 端点 / Create Agent Runtime Endpoint synchronously Args: agent_runtime_id: Agent Runtime ID @@ -496,7 +496,7 @@ def delete_endpoint( endpoint_id: str, config: Optional[Config] = None, ) -> AgentRuntimeEndpoint: - """同步删除 Agent Runtime 端点 / Delete Agent Runtime Endpoint asynchronously + """同步删除 Agent Runtime 端点 / Delete Agent Runtime Endpoint synchronously Args: agent_runtime_id: Agent Runtime ID @@ -578,7 +578,7 @@ def update_endpoint( endpoint: AgentRuntimeEndpointUpdateInput, config: Optional[Config] = None, ) -> AgentRuntimeEndpoint: - """同步更新 Agent Runtime 端点 / Update Agent Runtime Endpoint asynchronously + """同步更新 Agent Runtime 端点 / Update Agent Runtime Endpoint synchronously Args: agent_runtime_id: Agent Runtime ID @@ -656,7 +656,7 @@ def get_endpoint( endpoint_id: str, config: Optional[Config] = None, ) -> AgentRuntimeEndpoint: - """同步获取 Agent Runtime 端点 / Get Agent Runtime Endpoint asynchronously + """同步获取 Agent Runtime 端点 / Get Agent Runtime Endpoint synchronously Args: agent_runtime_id: Agent Runtime ID @@ -732,7 +732,7 @@ def list_endpoints( input: Optional[AgentRuntimeEndpointListInput] = None, config: Optional[Config] = None, ) -> List[AgentRuntimeEndpoint]: - """同步列出 Agent Runtime 端点 / List Agent Runtime Endpoints asynchronously + """同步列出 Agent Runtime 端点 / List Agent Runtime Endpoints synchronously Args: agent_runtime_id: Agent Runtime ID @@ -806,7 +806,7 @@ def list_versions( input: Optional[AgentRuntimeVersionListInput] = None, config: Optional[Config] = None, ) -> List[AgentRuntimeVersion]: - """同步列出 Agent Runtime 版本 / List Agent Runtime Versions asynchronously + """同步列出 Agent Runtime 版本 / List Agent Runtime Versions synchronously Args: agent_runtime_id: Agent Runtime ID diff --git a/agentrun/agent_runtime/endpoint.py b/agentrun/agent_runtime/endpoint.py index 88b4a7a..b75a637 100644 --- a/agentrun/agent_runtime/endpoint.py +++ b/agentrun/agent_runtime/endpoint.py @@ -91,7 +91,7 @@ def create_by_id( input: AgentRuntimeEndpointCreateInput, config: Optional[Config] = None, ): - """根据 ID 同步创建端点 / Create endpoint by ID asynchronously + """根据 ID 同步创建端点 / Create endpoint by ID synchronously Args: agent_runtime_id: Agent Runtime ID @@ -148,7 +148,7 @@ def delete_by_id( endpoint_id: str, config: Optional[Config] = None, ): - """根据 ID 同步删除端点 / Delete endpoint by ID asynchronously + """根据 ID 同步删除端点 / Delete endpoint by ID synchronously Args: agent_runtime_id: Agent Runtime ID @@ -208,7 +208,7 @@ def update_by_id( input: AgentRuntimeEndpointUpdateInput, config: Optional[Config] = None, ): - """根据 ID 同步更新端点 / Update endpoint by ID asynchronously + """根据 ID 同步更新端点 / Update endpoint by ID synchronously Args: agent_runtime_id: Agent Runtime ID @@ -266,7 +266,7 @@ def get_by_id( endpoint_id: str, config: Optional[Config] = None, ): - """根据 ID 同步获取端点 / Get endpoint by ID asynchronously + """根据 ID 同步获取端点 / Get endpoint by ID synchronously Args: agent_runtime_id: Agent Runtime ID @@ -414,7 +414,7 @@ async def list_by_id_async( @classmethod def list_by_id(cls, agent_runtime_id: str, config: Optional[Config] = None): - """根据 Agent Runtime ID 同步列出所有端点 / List all endpoints by Agent Runtime ID asynchronously + """根据 Agent Runtime ID 同步列出所有端点 / List all endpoints by Agent Runtime ID synchronously 此方法会自动分页获取所有端点并去重。 This method automatically paginates to get all endpoints and deduplicates them. @@ -489,7 +489,7 @@ async def delete_async( return self def delete(self, config: Optional[Config] = None) -> "AgentRuntimeEndpoint": - """同步删除当前端点 / Delete current endpoint asynchronously + """同步删除当前端点 / Delete current endpoint synchronously Args: config: 配置对象,可选 / Configuration object, optional @@ -559,7 +559,7 @@ def update( input: AgentRuntimeEndpointUpdateInput, config: Optional[Config] = None, ) -> Self: - """同步更新当前端点 / Update current endpoint asynchronously + """同步更新当前端点 / Update current endpoint synchronously Args: input: 端点更新配置 / Endpoint update configuration @@ -621,7 +621,7 @@ async def get_async(self, config: Optional[Config] = None): return self def get(self, config: Optional[Config] = None): - """同步获取当前端点信息 / Get current endpoint information asynchronously + """同步获取当前端点信息 / Get current endpoint information synchronously Args: config: 配置对象,可选 / Configuration object, optional diff --git a/agentrun/agent_runtime/runtime.py b/agentrun/agent_runtime/runtime.py index e2eae87..af2dde8 100644 --- a/agentrun/agent_runtime/runtime.py +++ b/agentrun/agent_runtime/runtime.py @@ -88,7 +88,7 @@ async def create_async( def create( cls, input: AgentRuntimeCreateInput, config: Optional[Config] = None ): - """同步创建 Agent Runtime / Create Agent Runtime asynchronously + """同步创建 Agent Runtime / Create Agent Runtime synchronously Args: input: Agent Runtime 创建配置 / Agent Runtime creation configuration @@ -142,7 +142,7 @@ async def delete_by_id_async(cls, id: str, config: Optional[Config] = None): @classmethod def delete_by_id(cls, id: str, config: Optional[Config] = None): - """根据 ID 同步删除 Agent Runtime / Delete Agent Runtime by ID asynchronously + """根据 ID 同步删除 Agent Runtime / Delete Agent Runtime by ID synchronously 此方法会先删除所有关联的端点,然后再删除 Agent Runtime。 This method will first delete all associated endpoints, then delete the Agent Runtime. @@ -205,7 +205,7 @@ def update_by_id( input: AgentRuntimeUpdateInput, config: Optional[Config] = None, ): - """根据 ID 同步更新 Agent Runtime / Update Agent Runtime by ID asynchronously + """根据 ID 同步更新 Agent Runtime / Update Agent Runtime by ID synchronously Args: id: Agent Runtime ID @@ -240,7 +240,7 @@ async def get_by_id_async(cls, id: str, config: Optional[Config] = None): @classmethod def get_by_id(cls, id: str, config: Optional[Config] = None): - """根据 ID 同步获取 Agent Runtime / Get Agent Runtime by ID asynchronously + """根据 ID 同步获取 Agent Runtime / Get Agent Runtime by ID synchronously Args: id: Agent Runtime ID @@ -359,7 +359,7 @@ async def list_async(cls, config: Optional[Config] = None): @classmethod def list(cls, config: Optional[Config] = None): - """同步列出所有 Agent Runtimes / List all Agent Runtimes asynchronously + """同步列出所有 Agent Runtimes / List all Agent Runtimes synchronously 此方法会自动分页获取所有 Agent Runtimes 并去重。 This method automatically paginates to get all Agent Runtimes and deduplicates them. diff --git a/agentrun/credential/client.py b/agentrun/credential/client.py index 3835cfb..f0d6343 100644 --- a/agentrun/credential/client.py +++ b/agentrun/credential/client.py @@ -84,7 +84,7 @@ async def create_async( def create( self, input: CredentialCreateInput, config: Optional[Config] = None ): - """创建凭证(同步) / Create credential asynchronously + """创建凭证(同步) / Create credential synchronously Args: input: 凭证输入参数 / Credential input parameters diff --git a/agentrun/knowledgebase/api/control.py b/agentrun/knowledgebase/api/control.py index cfa4304..9057654 100644 --- a/agentrun/knowledgebase/api/control.py +++ b/agentrun/knowledgebase/api/control.py @@ -25,7 +25,7 @@ ) from alibabacloud_tea_openapi.exceptions._client import ClientException from alibabacloud_tea_openapi.exceptions._server import ServerException -from alibabacloud_tea_util.models import RuntimeOptions +from darabonba.runtime import RuntimeOptions import pydash from agentrun.utils.config import Config diff --git a/agentrun/knowledgebase/client.py b/agentrun/knowledgebase/client.py index e8f6927..56c0da6 100644 --- a/agentrun/knowledgebase/client.py +++ b/agentrun/knowledgebase/client.py @@ -81,7 +81,7 @@ async def create_async( def create( self, input: KnowledgeBaseCreateInput, config: Optional[Config] = None ): - """创建知识库(同步) / Create knowledge base asynchronously + """创建知识库(同步) / Create knowledge base synchronously Args: input: 知识库输入参数 / KnowledgeBase input parameters @@ -131,7 +131,7 @@ async def delete_async( ) from e def delete(self, knowledge_base_name: str, config: Optional[Config] = None): - """删除知识库(同步)/ Delete knowledge base asynchronously + """删除知识库(同步)/ Delete knowledge base synchronously Args: knowledge_base_name: 知识库名称 / KnowledgeBase name @@ -190,7 +190,7 @@ def update( input: KnowledgeBaseUpdateInput, config: Optional[Config] = None, ): - """更新知识库(同步)/ Update knowledge base asynchronously + """更新知识库(同步)/ Update knowledge base synchronously Args: knowledge_base_name: 知识库名称 / KnowledgeBase name @@ -242,7 +242,7 @@ async def get_async( ) from e def get(self, knowledge_base_name: str, config: Optional[Config] = None): - """获取知识库(同步)/ Get knowledge base asynchronously + """获取知识库(同步)/ Get knowledge base synchronously Args: knowledge_base_name: 知识库名称 / KnowledgeBase name @@ -292,7 +292,7 @@ def list( input: Optional[KnowledgeBaseListInput] = None, config: Optional[Config] = None, ): - """列出知识库(同步)/ List knowledge bases asynchronously + """列出知识库(同步)/ List knowledge bases synchronously Args: input: 分页查询参数 / Pagination query parameters diff --git a/agentrun/knowledgebase/knowledgebase.py b/agentrun/knowledgebase/knowledgebase.py index cf4e210..2e453da 100644 --- a/agentrun/knowledgebase/knowledgebase.py +++ b/agentrun/knowledgebase/knowledgebase.py @@ -82,7 +82,7 @@ async def create_async( def create( cls, input: KnowledgeBaseCreateInput, config: Optional[Config] = None ): - """创建知识库(同步)/ Create knowledge base asynchronously + """创建知识库(同步)/ Create knowledge base synchronously Args: input: 知识库输入参数 / KnowledgeBase input parameters @@ -111,7 +111,7 @@ async def delete_by_name_async( def delete_by_name( cls, knowledge_base_name: str, config: Optional[Config] = None ): - """根据名称删除知识库(同步)/ Delete knowledge base by name asynchronously + """根据名称删除知识库(同步)/ Delete knowledge base by name synchronously Args: knowledge_base_name: 知识库名称 / KnowledgeBase name @@ -147,7 +147,7 @@ def update_by_name( input: KnowledgeBaseUpdateInput, config: Optional[Config] = None, ): - """根据名称更新知识库(同步)/ Update knowledge base by name asynchronously + """根据名称更新知识库(同步)/ Update knowledge base by name synchronously Args: knowledge_base_name: 知识库名称 / KnowledgeBase name @@ -182,7 +182,7 @@ async def get_by_name_async( def get_by_name( cls, knowledge_base_name: str, config: Optional[Config] = None ): - """根据名称获取知识库(同步)/ Get knowledge base by name asynchronously + """根据名称获取知识库(同步)/ Get knowledge base by name synchronously Args: knowledge_base_name: 知识库名称 / KnowledgeBase name @@ -246,7 +246,7 @@ def list_all( provider: Optional[str] = None, config: Optional[Config] = None, ) -> List[KnowledgeBaseListOutput]: - """列出所有知识库(同步)/ List all knowledge bases asynchronously + """列出所有知识库(同步)/ List all knowledge bases synchronously Args: provider: 提供商 / Provider @@ -288,7 +288,7 @@ async def update_async( def update( self, input: KnowledgeBaseUpdateInput, config: Optional[Config] = None ): - """更新知识库(同步)/ Update knowledge base asynchronously + """更新知识库(同步)/ Update knowledge base synchronously Args: input: 知识库更新输入参数 / KnowledgeBase update input parameters @@ -325,7 +325,7 @@ async def delete_async(self, config: Optional[Config] = None): ) def delete(self, config: Optional[Config] = None): - """删除知识库(同步)/ Delete knowledge base asynchronously + """删除知识库(同步)/ Delete knowledge base synchronously Args: config: 配置 / Configuration @@ -359,7 +359,7 @@ async def get_async(self, config: Optional[Config] = None): return self def get(self, config: Optional[Config] = None): - """刷新知识库信息(同步)/ Refresh knowledge base info asynchronously + """刷新知识库信息(同步)/ Refresh knowledge base info synchronously Args: config: 配置 / Configuration @@ -393,7 +393,7 @@ async def refresh_async(self, config: Optional[Config] = None): # ========================================================================= def refresh(self, config: Optional[Config] = None): - """刷新知识库信息(同步)/ Refresh knowledge base info asynchronously + """刷新知识库信息(同步)/ Refresh knowledge base info synchronously Args: config: 配置 / Configuration @@ -506,7 +506,7 @@ def retrieve( query: str, config: Optional[Config] = None, ) -> Dict[str, Any]: - """检索知识库(同步)/ Retrieve from knowledge base asynchronously + """检索知识库(同步)/ Retrieve from knowledge base synchronously 根据当前知识库的 provider 类型和配置执行检索。 Executes retrieval based on current knowledge base provider type and configuration. @@ -547,7 +547,7 @@ def _safe_get_kb( kb_name: str, config: Optional[Config] = None, ) -> Any: - """安全获取知识库(同步)/ Safely get knowledge base asynchronously + """安全获取知识库(同步)/ Safely get knowledge base synchronously Args: kb_name: 知识库名称 / Knowledge base name @@ -611,7 +611,7 @@ def _safe_retrieve_kb( query: str, config: Optional[Config] = None, ) -> Dict[str, Any]: - """安全执行知识库检索(同步)/ Safely retrieve from knowledge base asynchronously + """安全执行知识库检索(同步)/ Safely retrieve from knowledge base synchronously Args: kb_name: 知识库名称 / Knowledge base name @@ -704,7 +704,7 @@ def multi_retrieve( knowledge_base_names: List[str], config: Optional[Config] = None, ) -> Dict[str, Any]: - """多知识库检索(同步)/ Multi knowledge base retrieval asynchronously + """多知识库检索(同步)/ Multi knowledge base retrieval synchronously 根据知识库名称列表进行检索,自动获取各知识库的配置并执行检索。 如果某个知识库查询失败,不影响其他知识库的查询。 diff --git a/agentrun/memory_collection/api/control.py b/agentrun/memory_collection/api/control.py index 0bca849..6d03661 100644 --- a/agentrun/memory_collection/api/control.py +++ b/agentrun/memory_collection/api/control.py @@ -25,7 +25,7 @@ ) from alibabacloud_tea_openapi.exceptions._client import ClientException from alibabacloud_tea_openapi.exceptions._server import ServerException -from alibabacloud_tea_util.models import RuntimeOptions +from darabonba.runtime import RuntimeOptions import pydash from agentrun.utils.config import Config diff --git a/agentrun/sandbox/aio_sandbox.py b/agentrun/sandbox/aio_sandbox.py index d848021..e39211e 100644 --- a/agentrun/sandbox/aio_sandbox.py +++ b/agentrun/sandbox/aio_sandbox.py @@ -734,7 +734,7 @@ async def __aenter__(self): def __enter__(self): """Synchronous context manager entry.""" - # Poll health check asynchronously + # Poll health check synchronously max_retries = 60 # Maximum 60 seconds retry_count = 0 diff --git a/agentrun/sandbox/browser_sandbox.py b/agentrun/sandbox/browser_sandbox.py index 42b05f3..e43b801 100644 --- a/agentrun/sandbox/browser_sandbox.py +++ b/agentrun/sandbox/browser_sandbox.py @@ -68,7 +68,7 @@ async def __aenter__(self): ) def __enter__(self): - # Poll health check asynchronously + # Poll health check synchronously max_retries = 60 # Maximum 60 seconds retry_count = 0 diff --git a/agentrun/sandbox/code_interpreter_sandbox.py b/agentrun/sandbox/code_interpreter_sandbox.py index e2a009f..e57ad59 100644 --- a/agentrun/sandbox/code_interpreter_sandbox.py +++ b/agentrun/sandbox/code_interpreter_sandbox.py @@ -767,7 +767,7 @@ async def __aenter__(self): def __enter__(self): """Synchronous context manager entry.""" - # Poll health check asynchronously + # Poll health check synchronously max_retries = 60 # Maximum 60 seconds retry_count = 0 diff --git a/agentrun/utils/data_api.py b/agentrun/utils/data_api.py index 1b6a872..ba9b496 100644 --- a/agentrun/utils/data_api.py +++ b/agentrun/utils/data_api.py @@ -447,9 +447,7 @@ def _make_request( ) try: - with httpx.Client( - timeout=self.config.get_timeout() - ) as client: + with httpx.Client(timeout=self.config.get_timeout()) as client: response = client.request( method, url, @@ -931,9 +929,7 @@ def post_file( data = form_data or {} data["path"] = target_file_path - with httpx.Client( - timeout=self.config.get_timeout() - ) as client: + with httpx.Client(timeout=self.config.get_timeout()) as client: response = client.post( url, files=files, data=data, headers=req_headers ) @@ -1027,9 +1023,7 @@ def get_file( url, req_headers, query = self.auth(url, req_headers, query, config=cfg) try: - with httpx.Client( - timeout=self.config.get_timeout() - ) as client: + with httpx.Client(timeout=self.config.get_timeout()) as client: response = client.get(url, headers=req_headers) response.raise_for_status() @@ -1125,9 +1119,7 @@ def get_video( url, req_headers, query = self.auth(url, req_headers, query, config=cfg) try: - with httpx.Client( - timeout=self.config.get_timeout() - ) as client: + with httpx.Client(timeout=self.config.get_timeout()) as client: response = client.get(url, headers=req_headers) response.raise_for_status() diff --git a/codegen/codegen.py b/codegen/codegen.py index cf4ad29..c4ff00b 100644 --- a/codegen/codegen.py +++ b/codegen/codegen.py @@ -209,6 +209,7 @@ def _generate_sync_code_for_file(async_file): .replace("AsyncMemory", "Memory") .replace("async_playwright", "sync_playwright") .replace("asyncio.gather(*", "(") + .replace("asynchronously", "synchronously") .replace("_async", "") .replace("async def", "def") .replace("await ", "") From 4b4b97f7e389df19108488c52294c06b50c83bdc Mon Sep 17 00:00:00 2001 From: OhYee Date: Thu, 22 Jan 2026 14:47:30 +0800 Subject: [PATCH 4/4] feat(sandbox): add CustomSandbox to module exports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add CustomSandbox class to the sandbox module's exports to make it available for import and use in other parts of the application. This enables users to utilize the custom sandbox functionality that was previously not exposed through the main module interface. feat(sandbox): 添加 CustomSandbox 到模块导出 将 CustomSandbox 类添加到 sandbox 模块的导出中,使其可在应用程序的其他部分导入和使用。 这使用户能够利用以前未通过主模块接口公开的自定义沙箱功能。 Change-Id: Ida6b9787ae39f33e2e6902950c0d114d9508b84a --- agentrun/__init__.py | 4 ++++ agentrun/sandbox/__init__.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/agentrun/__init__.py b/agentrun/__init__.py index edc9604..6100934 100644 --- a/agentrun/__init__.py +++ b/agentrun/__init__.py @@ -100,8 +100,10 @@ ) # Sandbox from agentrun.sandbox import ( + AioSandbox, BrowserSandbox, CodeInterpreterSandbox, + CustomSandbox, SandboxClient, Template, ) @@ -239,6 +241,8 @@ "SandboxClient", "BrowserSandbox", "CodeInterpreterSandbox", + "AioSandbox", + "CustomSandbox", "Template", ######## ToolSet ######## "ToolSetClient", diff --git a/agentrun/sandbox/__init__.py b/agentrun/sandbox/__init__.py index b37d1ca..65aaa96 100644 --- a/agentrun/sandbox/__init__.py +++ b/agentrun/sandbox/__init__.py @@ -6,6 +6,7 @@ from .browser_sandbox import BrowserSandbox from .client import SandboxClient from .code_interpreter_sandbox import CodeInterpreterSandbox +from .custom_sandbox import CustomSandbox from .model import ( CodeLanguage, ListSandboxesInput, @@ -66,4 +67,5 @@ "OSSMountPoint", "PolarFsConfig", "PolarFsConfig", + "CustomSandbox", ]