Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions config.yaml.full
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ volcengine:
access_key:
secret_key:

agentkit:
# [optional] default AgentKit tool id fallback for all sandbox tools
tool_id:
# [optional] dedicated tool id for `run_code`
tool_id_script:
# [optional] dedicated tool id for `execute_skills`
tool_id_skills:
# [optional] dedicated tool id for `coding`
tool_id_opencode:
# [optional] AgentKit endpoint configs
tool_host:
tool_service_code: agentkit
tool_region: cn-beijing
tool_scheme: https
top_scheme: https

tool:
# [optional] https://console.volcengine.com/ask-echo/my-agent
vesearch:
Expand Down
13 changes: 12 additions & 1 deletion docs/docs/tools/builtin.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ VeADK 集成了以下火山引擎工具:
| `image_edit` | [编辑图片](https://www.volcengine.com/docs/82379/1541523)(图生图)。 | `from veadk.tools.builtin_tools.image_edit import image_edit` |
| `video_generate` | 根据文本描述[生成视频](https.www.volcengine.com/docs/82379/1520757)。 | `from veadk.tools.builtin_tools.video_generate import video_generate` |
| `run_code` | 在 [AgentKit 沙箱](https://console.volcengine.com/agentkit-ppe/region:agentkit-ppe+cn-beijing/builtintools)中执行代码。 | `from veadk.tools.builtin_tools.run_code import run_code` |
| `execute_skills` | 在预制技能沙箱中远程执行 `agent.py` 工作流。 | `from veadk.tools.builtin_tools.execute_skills import execute_skills` |
| `coding` | 在预制 OpenCode 沙箱中执行代码生成工作流。 | `from veadk.tools.builtin_tools.coding import coding` |
| `run_sandbox_agent` | 指定任意 `tool_id` 在远端 AgentKit 沙箱中执行 `agent.py`。 | `from veadk.tools.builtin_tools.run_sandbox_agent import run_sandbox_agent` |
| `lark` | 集成[飞书开放能力](https://open.larkoffice.com/document/uAjLw4CM/ukTMukTMukTM/mcp_integration/mcp_installation),实现文档处理、会话管理等。 | `from veadk.tools.builtin_tools.lark import lark` |
| `las` | 基于[火山引擎 AI 多模态数据湖服务 LAS](https://www.volcengine.com/mcp-marketplace) 进行数据管理。 | `from veadk.tools.builtin_tools.las import las` |
| `mobile_run` | 手机指令执行 | `from veadk.tools.builtin_tools.mobile_run import create_mobile_use_tool` |
Expand Down Expand Up @@ -183,7 +186,10 @@ VeADK 集成了以下火山引擎工具:

以下是必须在环境变量里面的配置项:

- `AGENTKIT_TOOL_ID`:用于调用火山引擎AgentKit Tools的沙箱环境Id
- `AGENTKIT_TOOL_ID`:默认的 AgentKit 沙箱环境 Id,会作为所有沙箱工具的兜底配置
- `AGENTKIT_TOOL_ID_SCRIPT`:`run_code` 专用沙箱环境 Id,未配置时回退到 `AGENTKIT_TOOL_ID`
- `AGENTKIT_TOOL_ID_SKILLS`:`execute_skills` 专用沙箱环境 Id,未配置时回退到 `AGENTKIT_TOOL_ID`
- `AGENTKIT_TOOL_ID_OPENCODE`:`coding` 专用沙箱环境 Id,未配置时回退到 `AGENTKIT_TOOL_ID`
- `AGENTKIT_TOOL_HOST`:用于调用火山引擎AgentKit Tools的EndPoint
- `AGENTKIT_TOOL_SERVICE_CODE`:用于调用AgentKit Tools的ServiceCode
- `AGENTKIT_TOOL_SCHEME`:用于切换调用 AgentKit Tools 的协议,允许 `http`/`https`,默认 `https`
Expand All @@ -204,6 +210,11 @@ VeADK 集成了以下火山引擎工具:
name: doubao-seed-1-6-250615
api_base: https://ark.cn-beijing.volces.com/api/v3/
api_key: your-api-key-here
agentkit:
tool_id: your-default-tool-id
tool_id_script: your-script-tool-id
tool_id_skills: your-skills-tool-id
tool_id_opencode: your-opencode-tool-id
volcengine:
# [optional] for Viking DB and `web_search` tool
access_key: you-access-key-here
Expand Down
164 changes: 164 additions & 0 deletions tests/tools/builtin_tools/test_agentkit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import importlib.util
import os
import sys
import types
import unittest
from pathlib import Path
from unittest.mock import patch


def _load_agentkit_module():
module_path = (
Path(__file__).resolve().parents[3]
/ "veadk"
/ "tools"
/ "builtin_tools"
/ "_agentkit.py"
)

fake_veadk = types.ModuleType("veadk")
fake_veadk.__path__ = [] # type: ignore[attr-defined]
fake_auth = types.ModuleType("veadk.auth")
fake_auth.__path__ = [] # type: ignore[attr-defined]
fake_veauth = types.ModuleType("veadk.auth.veauth")
fake_veauth.__path__ = [] # type: ignore[attr-defined]
fake_veauth_utils = types.ModuleType("veadk.auth.veauth.utils")
fake_config = types.ModuleType("veadk.config")
fake_utils = types.ModuleType("veadk.utils")
fake_utils.__path__ = [] # type: ignore[attr-defined]
fake_logger = types.ModuleType("veadk.utils.logger")
fake_sign = types.ModuleType("veadk.utils.volcengine_sign")

def fake_getenv(env_name, default_value="", allow_false_values=False):
value = os.getenv(env_name, default_value)
if allow_false_values:
return value
if value:
return value
raise ValueError(
f"The environment variable `{env_name}` not exists. Please set this in your environment variable or config.yaml."
)

class _FakeCredential:
access_key_id = "ak"
secret_access_key = "sk"
session_token = "token"

class _FakeLogger:
def debug(self, *_args, **_kwargs):
return None

def warning(self, *_args, **_kwargs):
return None

def error(self, *_args, **_kwargs):
return None

fake_veauth_utils.get_credential_from_vefaas_iam = lambda: _FakeCredential()
fake_config.getenv = fake_getenv
fake_logger.get_logger = lambda _name: _FakeLogger()
fake_sign.ve_request = lambda **_kwargs: {"Result": {"AccountId": "test-account"}}

stub_modules = {
"veadk": fake_veadk,
"veadk.auth": fake_auth,
"veadk.auth.veauth": fake_veauth,
"veadk.auth.veauth.utils": fake_veauth_utils,
"veadk.config": fake_config,
"veadk.utils": fake_utils,
"veadk.utils.logger": fake_logger,
"veadk.utils.volcengine_sign": fake_sign,
}

with patch.dict(sys.modules, stub_modules):
spec = importlib.util.spec_from_file_location(
"test_agentkit_module", module_path
)
module = importlib.util.module_from_spec(spec)
assert spec is not None
assert spec.loader is not None
spec.loader.exec_module(module)
return module


class TestResolveAgentkitToolId(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.agentkit_module = _load_agentkit_module()

def setUp(self):
self.env_patcher = patch.dict(
os.environ,
{},
clear=False,
)
self.env_patcher.start()
for env_name in [
"AGENTKIT_TOOL_ID",
"AGENTKIT_TOOL_ID_SCRIPT",
"AGENTKIT_TOOL_ID_SKILLS",
"AGENTKIT_TOOL_ID_OPENCODE",
]:
os.environ.pop(env_name, None)

def tearDown(self):
self.env_patcher.stop()

def test_resolve_prefers_script_tool_id(self):
os.environ["AGENTKIT_TOOL_ID_SCRIPT"] = "script-tool"
os.environ["AGENTKIT_TOOL_ID"] = "default-tool"

tool_id = self.agentkit_module.resolve_agentkit_tool_id(
"AGENTKIT_TOOL_ID_SCRIPT"
)

self.assertEqual(tool_id, "script-tool")

def test_resolve_prefers_skills_tool_id(self):
os.environ["AGENTKIT_TOOL_ID_SKILLS"] = "skills-tool"
os.environ["AGENTKIT_TOOL_ID"] = "default-tool"

tool_id = self.agentkit_module.resolve_agentkit_tool_id(
"AGENTKIT_TOOL_ID_SKILLS"
)

self.assertEqual(tool_id, "skills-tool")

def test_resolve_prefers_opencode_tool_id(self):
os.environ["AGENTKIT_TOOL_ID_OPENCODE"] = "opencode-tool"
os.environ["AGENTKIT_TOOL_ID"] = "default-tool"

tool_id = self.agentkit_module.resolve_agentkit_tool_id(
"AGENTKIT_TOOL_ID_OPENCODE"
)

self.assertEqual(tool_id, "opencode-tool")

def test_resolve_falls_back_to_default_tool_id(self):
os.environ["AGENTKIT_TOOL_ID"] = "default-tool"

tool_id = self.agentkit_module.resolve_agentkit_tool_id()

self.assertEqual(tool_id, "default-tool")

def test_resolve_raises_when_all_tool_ids_missing(self):
with self.assertRaisesRegex(ValueError, "AGENTKIT_TOOL_ID"):
self.agentkit_module.resolve_agentkit_tool_id("AGENTKIT_TOOL_ID_SCRIPT")


if __name__ == "__main__":
unittest.main()
Loading
Loading