Skip to content

feat(tool): 添加工具相关的新模块和API接口#74

Open
Sodawyx wants to merge 8 commits intomainfrom
implement-new-tools
Open

feat(tool): 添加工具相关的新模块和API接口#74
Sodawyx wants to merge 8 commits intomainfrom
implement-new-tools

Conversation

@Sodawyx
Copy link
Copy Markdown
Collaborator

@Sodawyx Sodawyx commented Mar 27, 2026

此提交添加了一系列新的工具相关的模块和API接口,包括客户端模板、模型定义以及各种控制和OpenAPI接口等组件。同时更新了依赖版本并完善了初始化配置。

Co-developed-by: Aone Copilot noreply@alibaba-inc.com

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?

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

该 PR 为 SDK 新增了完整的 Tool 相关模块与 API(管控链路 + 数据链路),并补齐了对应的单元测试,同时更新了底层依赖版本以支持新能力。

Changes:

  • 新增 agentrun.tool 模块:包含 Tool 资源类、客户端、模型定义,以及 Control/MCP/OpenAPI 三类 API 组件
  • 新增 Tool 模块的单元测试覆盖(model / mcp / openapi / tool & client)
  • 更新 alibabacloud-agentrun20250910 依赖版本要求

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pyproject.toml 升级底层 alibabacloud-agentrun20250910 版本以支持新 Tool 能力
agentrun/tool/__init__.py 聚合导出 tool 模块公共 API
agentrun/tool/model.py 新增 ToolType/McpConfig/ToolSchema/ToolInfo 等模型定义
agentrun/tool/api/__init__.py Tool API 子模块初始化
agentrun/tool/api/control.py 新增 Tool 管控链路 API(基于底层 SDK 获取 Tool 资源)
agentrun/tool/api/mcp.py 新增 MCP 数据链路会话封装(SSE/Streamable)
agentrun/tool/api/openapi.py 新增 FunctionCall(OpenAPI) 数据链路解析与 HTTP 调用客户端
agentrun/tool/client.py 新增 ToolClient(get/get_async)
agentrun/tool/tool.py 新增 Tool 资源类:支持 get、list_tools、call_tool(sync/async)
agentrun/tool/__client_async_template.py codegen 模板:ToolClient(async)
agentrun/tool/__tool_async_template.py codegen 模板:Tool 资源类(async)
agentrun/__init__.py 顶层导出 ToolResource/ToolResourceClient/ToolResourceControlAPI(避免与 server.Tool 冲突)
tests/unittests/tool/__init__.py Tool 测试包初始化
tests/unittests/tool/test_model.py Tool 模型单元测试
tests/unittests/tool/test_mcp.py MCP 会话单元测试
tests/unittests/tool/test_openapi.py OpenAPI 客户端单元测试
tests/unittests/tool/test_tool.py Tool 资源类与 ToolClient 单元测试

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sodawyx added 4 commits March 30, 2026 18:56
此提交添加了一系列新的工具相关的模块和API接口,包括客户端模板、模型定义以及各种控制和OpenAPI接口等组件。同时更新了依赖版本并完善了初始化配置。

Co-developed-by: Aone Copilot <noreply@alibaba-inc.com>
Signed-off-by: Sodawyx <sodawyx@126.com>
此提交添加了对SKILL类型工具的支持,包括获取下载URL和异步下载解压的功能。同时更新了相关单元测试。

Co-developed-by: Aone Copilot <noreply@alibaba-inc.com>
Signed-off-by: Sodawyx <sodawyx@126.com>
在多个集成模块中添加了 `tool_resource` 函数的支持,允许用户将 ToolResource 封装为不同 AI 框架所需的工具格式,包括 CrewAI、LangChain、PydanticAI、LangGraph 和 AgentScope。同时更新了相关初始化文件以导出新功能。

Co-developed-by: Aone Copilot <noreply@alibaba-inc.com>
Signed-off-by: Sodawyx <sodawyx@126.com>
在多个集成框架中添加了 `skill_tools` 函数,用于将 Skill 封装为不同 AI 框架的工具列表,包括 CrewAI、LangChain、PydanticAI、LangGraph、AgentScope 和 Google ADK。同时更新了相关的初始化文件和工具加载器。

Co-developed-by: Aone Copilot <noreply@alibaba-inc.com>
Signed-off-by: Sodawyx <sodawyx@126.com>
@Sodawyx Sodawyx force-pushed the implement-new-tools branch from 1ff2a13 to 2757f2f Compare March 30, 2026 10:56
Sodawyx added 4 commits March 31, 2026 11:19
添加了ToolCreateMethod枚举类,定义了多种工具创建和部署方式,并相应地更新了相关的导入和导出语句。同时增加了对异步事件循环处理的单元测试。

Co-developed-by: Aone Copilot <noreply@alibaba-inc.com>
Signed-off-by: Sodawyx <sodawyx@126.com>
本提交更新了 `Tool` 类中的配置访问方法,将直接属性访问改为调用统一的方法接口,并相应地增强了单元测试以更好地模拟各种边界情况下的行为。

Co-developed-by: Aone Copilot <noreply@alibaba-inc.com>
Signed-off-by: Sodawyx <sodawyx@126.com>
本次更新改进了skill_loader模块的功能,并添加了相应的单元测试以提高代码质量和稳定性。

Co-developed-by: Aone Copilot <noreply@alibaba-inc.com>
Signed-off-by: Sodawyx <sodawyx@126.com>
…rsing

This change updates the `_get_mcp_endpoint` method to return both the endpoint URL and session affinity as a tuple, and introduces a new method `_parse_protocol_spec_mcp_url` to handle parsing of MCP URLs from protocol specifications when using `MCP_REMOTE` without proxy enabled. This improves consistency across synchronous and asynchronous implementations of the tool class.

Co-developed-by: Aone Copilot <noreply@alibaba-inc.com>
Signed-off-by: Sodawyx <sodawyx@126.com>
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

Copilot reviewed 36 out of 36 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

with pytest.raises(ValueError, match="No server URL found"):
client.call_tool("testOp", {})

@patch("httpx.AsyncClient")
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

The patch decorator uses @patch("httpx.AsyncClient") but should use the full module path @patch("agentrun.tool.api.openapi.httpx.AsyncClient") to properly patch the httpx.AsyncClient imported in the openapi module. The other async test decorators correctly use the full path (see lines 359, 373, 579, 605). This inconsistency may cause the test to fail or not properly mock the AsyncClient.

Copilot uses AI. Check for mistakes.
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.

2 participants