Conversation
`while folder != "/"` 比较 Path 与 str 永远为真,没有 .env 时会死循环卡住整个 E2E 启动。改为按 `folder.parent == folder` 判断到达根目录后退出。 Change-Id: Id62a2804abdffda4f399c5cbbb22a4c6ba41c4e6 Co-developed-by: Claude <noreply@anthropic.com>
需求:[Aone #80923442](https://project.aone.alibaba-inc.com/v2/project/2139638/req/80923442) 《【新版SDK】支持 Sandbox、知识库等创建过程使用 SDK 指定工作空间》 底层 SDK alibabacloud-agentrun20250910 (>=5.6.3) 已全面支持 workspace_id; 本次在 agentrun-sdk 这一层把字段暴露出来,让用户能在创建资源时指定工作空间, List 时按工作空间过滤,Get/Output 时回读工作空间。 涉及模块(在 ImmutableProps 中加入即同时流到 CreateInput 与 read 模型): - agent_runtime: AgentRuntimeImmutableProps + AgentRuntimeListInput - credential: CredentialImmutableProps + CredentialListInput + CredentialListOutput - knowledgebase: KnowledgeBaseImmutableProps + KnowledgeBaseListInput + KnowledgeBaseListOutput 注意:与 BailianProviderSettings.workspace_id(百炼侧)属于不同层级,注释里已澄清 - memory_collection: MemoryCollectionImmutableProps + MemoryCollectionListInput + MemoryCollectionListOutput - model: CommonModelImmutableProps(同时覆盖 ModelService/ModelProxy)+ 两个 ListInput - sandbox: TemplateInput + Template(输出,模板生成)+ PageableInput 字段统一为 `Optional[str] = None`,依赖 BaseModel 的 alias_generator 自动转 camelCase (workspace_id ↔ workspaceId)。所有改动向后兼容:不传该字段时行为不变。 测试: - 新增 28 个跨模块单元测试 (tests/unittests/test_workspace_id.py) - 新增 4 个 E2E 测试 (tests/e2e/test_workspace_id.py,async + sync × credential + template) 覆盖 create 带 workspace_id → get 回读 → list 按 workspace_id 过滤 - 运行 mypy --config-file mypy.ini . 通过(360 文件 0 报错) - 运行存量 E2E(credential / agent_runtime / model / sandbox template): 36 passed / 12 failed —— 12 个失败均为 pre-existing 问题,与本改动无关: * 2 个 agent_runtime: 服务端返回 artifactType="" 导致 enum 校验失败 * 8 个 ModelProxy: 服务端要求 executionRoleArn 必填,测试未传 * 2 个 sandbox network validation: 测试期望 client 端校验,SDK 未实现 不在范围(已说明原因): - Sandbox 实例 (SandboxInput): 底层不支持,沙箱继承 template 的 workspace - ToolSet / SuperAgent / ConversationService: 底层模型不同或无 workspace_id 概念 - Tool: agentrun SDK 当前未提供 CreateTool 入口 Change-Id: I008be98b0a5238c2f81a7c8584a6a11c56b6e471 Co-developed-by: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds first-class workspace_id support across multiple SDK resource modules (agent runtime, credential, knowledge base, memory collection, model, sandbox template) and introduces unit + E2E coverage to ensure workspace_id is exposed in Python as workspace_id and serialized/deserialized over the wire as workspaceId.
Changes:
- Add
workspace_id: Optional[str]to relevant Create/List/Output models so SDK users can set/filter workspace context. - Add unit tests validating
workspace_idfield presence and correct camelCase aliasing (workspaceId) across modules. - Add E2E tests (gated by
AGENTRUN_TEST_WORKSPACE_ID) validating create/get/list round-trips forworkspace_id, plus a more robust.envdiscovery loop for E2E runs.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unittests/test_workspace_id.py | New unit tests verifying cross-module workspace_id exposure and workspaceId alias behavior. |
| tests/e2e/test_workspace_id.py | New E2E coverage for workspace_id propagation across create/get/list for Credential and Sandbox Template. |
| tests/e2e/conftest.py | Fix .env auto-discovery to properly walk up directories to filesystem root. |
| tests/e2e/__test_workspace_id_async_template.py | New codegen template backing the generated workspace_id E2E test. |
| agentrun/sandbox/template.py | Add workspace_id to Template resource model; minor signature formatting changes. |
| agentrun/sandbox/model.py | Add workspace_id to TemplateInput and sandbox PageableInput for create/list filtering. |
| agentrun/sandbox/__template_async_template.py | Update codegen template so generated Template includes workspace_id. |
| agentrun/model/model.py | Add workspace_id to common model immutable props; add workspace filtering to list inputs. |
| agentrun/memory_collection/model.py | Add workspace_id to create/list models and list output. |
| agentrun/knowledgebase/model.py | Add AgentRun-level workspace_id to create/list models and list output; clarify distinction from Bailian workspace. |
| agentrun/credential/model.py | Add workspace_id to create/list models and list output. |
| agentrun/agent_runtime/model.py | Add workspace_id to create/list models (via immutable props + list filter). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot 检查下是否有问题, 是否存在不兼容变动(用户已有的代码未传入相关参数),是否和其他模块风格一致 |
经过逐一检查,没有发现问题: 兼容性(Backward Compatibility) 风格一致性
验证结果
|
Fix bugs
Bug detail
Pull request tasks
Update docs
Reason for update
Pull request tasks
Add contributor
Contributed content
Content detail
Others
Reason for update