Skip to content

Claude/adoring sammet 04753f#94

Open
zoeshawwang wants to merge 2 commits intomainfrom
claude/adoring-sammet-04753f
Open

Claude/adoring sammet 04753f#94
zoeshawwang wants to merge 2 commits intomainfrom
claude/adoring-sammet-04753f

Conversation

@zoeshawwang
Copy link
Copy Markdown
Collaborator

Thank you for creating a pull request to contribute to Serverless Devs agentrun-sdk-python code! Before you open the request please answer the following questions to help it be more easily integrated. Please check the boxes "[ ]" with "[x]" when done too.
Please select one of the PR types below to complete


Fix bugs

Bug detail

The specific manifestation of the bug or the associated issue.

Pull request tasks

  • Add test cases for the changes
  • Passed the CI test

Update docs

Reason for update

Why do you need to update your documentation?

Pull request tasks

  • Update Chinese documentation
  • Update English documentation

Add contributor

Contributed content

  • Code
  • Document

Content detail

if content_type == 'code' || content_type == 'document':
    please tell us `PR url`,like: https://github.com/Serverless-Devs/agentrun-sdk-python/pull/1
else:
    please describe your contribution in detail

Others

Reason for update

Why do you need to update your documentation?

`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>
@zoeshawwang zoeshawwang requested review from OhYee, Sodawyx and Copilot and removed request for OhYee and Copilot April 29, 2026 05:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_id field presence and correct camelCase aliasing (workspaceId) across modules.
  • Add E2E tests (gated by AGENTRUN_TEST_WORKSPACE_ID) validating create/get/list round-trips for workspace_id, plus a more robust .env discovery 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.

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.

3 participants