Quick Initialization
Use the agentkit init command to generate a project template with one click, with multiple built-in app types (Basic App, Stream App, etc.)
diff --git a/.gitignore b/.gitignore deleted file mode 100644 index b1a7c14..0000000 --- a/.gitignore +++ /dev/null @@ -1,185 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -.idea/ - -# vscode -.vscode/ -# Windsurf -.windsurf - -# python package -uv.lock - -# VitePress related files (security concern - keep Markdown docs in repo) -docs/package.json -docs/package-lock.json -docs/node_modules/ - -# local test files -test-agents/* -tos_doc_example -agentkit*.yaml -Dockerfile -Dockerfile-base -local_build.py -local_docs/ -local_test/ - -# deprecated files -*deprecated* \ No newline at end of file diff --git a/.gitleaks.toml b/.gitleaks.toml deleted file mode 100644 index ff7c413..0000000 --- a/.gitleaks.toml +++ /dev/null @@ -1,76 +0,0 @@ -[extend] -useDefault = true - -[[rules]] -id = "aklt-key-pattern" -description = "AKLT key pattern" -regex = '''AKLT\w{40,70}''' - -[[rules]] -id = "akap-key-pattern" -description = "AKAP key pattern" -regex = '''AKAP\w{40,70}''' - -[[rules]] -id = "akip-key-pattern" -description = "AKIP key pattern" -regex = '''AKI\w{40,70}''' - -[[rules]] -id = "token-transformer-id-pattern" -description = "Tokenizer/Transformer/Token ID patterns" -regex = '''(tokenizer|transformer|token_id|tokenid|attention_head).{0,20}''' - -[[rules]] -id = "aws-style-key-pattern" -description = "AWS-style key pattern" -regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}''' - -[[rules]] -id = "alibaba-ltai-pattern" -description = "Alibaba LTAI key pattern" -regex = '''(LTAI)[a-z0-9]{20}''' - -[[rules]] -id = "aktp-key-pattern" -description = "AKTP key pattern" -regex = '''AKTP\w{40,70}''' - -[[rules]] -id = "app-id-pattern" -description = "App ID patterns" -regex = '''([^*<\s|:>]{0,7})(app_id|appid)([^]()!<>;/@&,]{0,10}[(=:]\s{0,6}["']{0,1}[0-9]{6,32}["']{0,1})''' - -[[rules]] -id = "byted-org-domains" -description = "byted.org domains" -regex = '''.{0,15}\.?byted.org.{0,20}''' - -[[rules]] -id = "bytedance-net-domains" -description = "bytedance.net domains" -regex = '''.{0,15}\.?bytedance.net.{0,20}''' - -[[rules]] -id = "feishu-cn-domains" -description = "bytedance.feishu.cn domains" -regex = '''.{0,20}.bytedance\.feishu\.cn.{0,50}''' - -[[rules]] -id = "larkoffice-com-domains" -description = "bytedance.larkoffice.com domains" -regex = '''.{0,20}.bytedance\.larkoffice\.com.{0,50}''' - -[[rules]] -id = "private-ip-10-range" -description = "Private IP address pattern (10.x.x.x)" -regex = '''(10\.\d{1,3}\.\d{1,3}\.\d{1,3})''' - - -[[rules]] -id = "empty-env-key-pattern" -description = "Empty environment variables with KEY pattern" -regex = '''os\.environ\[".*?KEY"\]\s*=\s*".+"''' - -[allowlist] -paths = ["requirements.txt"] \ No newline at end of file diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 44d1a3d..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,16 +0,0 @@ -repos: -- repo: https://github.com/astral-sh/ruff-pre-commit - # Ruff version. - rev: v0.11.12 - hooks: - # Run the linter. - - id: ruff-check - types_or: [ python, pyi ] - args: [ --fix ] - # Run the formatter. - - id: ruff-format - types_or: [ python, pyi ] -- repo: https://github.com/gitleaks/gitleaks - rev: v8.24.2 - hooks: - - id: gitleaks \ No newline at end of file diff --git a/.python-version b/.python-version deleted file mode 100644 index e4fba21..0000000 --- a/.python-version +++ /dev/null @@ -1 +0,0 @@ -3.12 diff --git a/404.html b/404.html new file mode 100644 index 0000000..6b8a569 --- /dev/null +++ b/404.html @@ -0,0 +1,23 @@ + + +
+ + +本目录包含 AgentKit SDK 和 CLI 的完整文档。
npm installnpm run docs:dev访问 http://localhost:5173 查看文档站点。
npm run docs:build构建结果位于 .vitepress/dist 目录。
npm run docs:previewdocs/
+├── .vitepress/ # VitePress 配置
+│ └── config.js # 站点配置文件
+├── content/ # 文档内容
+│ ├── 1.introduction/ # 入门指南
+│ ├── 2.agentkit-sdk/ # SDK 文档
+│ └── 3.agentkit-cli/ # CLI 文档
+├── public/ # 静态资源
+│ └── images/ # 图片文件
+├── index.md # 首页
+└── package.json # 项目配置public/images/ 目录AgentKit 是火山引擎推出的企业级 AI Agent 开发平台,为开发者提供完整的 Agent 构建、部署和运维解决方案。平台通过标准化的开发工具链和云原生基础设施,显著降低复杂智能体应用的开发部署门槛。
agentkit CLI 工具链。AgentKit 的核心设计理念是将 Agent App 的定义与执行分离。
agentkit.yaml 文件声明式地定义应用的元数据、依赖、运行时环境和所需使用的平台服务(如知识库、记忆模块等)。agentkit CLI 和 AgentKit Platform 负责解析定义文件,并自动完成环境准备、代码打包、镜像构建、持续集成和云端部署等一系列繁琐工作。这种分离的设计使得开发者可以专注于业务逻辑的实现,而将复杂的工程化问题交给 AgentKit 来处理,敏捷构建,快速生产级落地。
本指南将引导您完成 AgentKit 的安装和基本配置。
uv 或 pip我们强烈建议在 Python 虚拟环境 中安装 AgentKit,以避免与系统包产生冲突。
适用于生产环境部署:
pip install agentkit-sdk-python包含最新功能和修复:
pip install --pre agentkit-sdk-python安装特定版本:
pip install agentkit-sdk-python==0.1.7我们推荐使用 uv 来管理虚拟环境和依赖。
# install uv
+curl -LsSf https://astral.sh/uv/install.sh | sh
+
+# Initialize uv environment
+uv init --no-workspace
+
+# Specify Python version for the environment
+uv venv --python 3.12
+
+# Activate the virtual environment
+source .venv/bin/activate
+
+# Install AgentKit using uv
+uv pip install agentkit-sdk-python
+
+# Install veadk (recommended for local debugging)
+uv pip install veadk-python适用于开发者和需要定制化场景:
# clone repo
+git clone git@github.com:volcengine/agentkit-sdk-python.git
+
+cd agentkit-sdk-python
+
+# we use uv to build this project
+uv venv --python 3.12
+
+# Activate the virtual environment
+source .venv/bin/activate
+
+# only install necessary requirements
+uv sync
+
+# install agentkit-sdk-python with editable mode
+uv pip install -e .如果您习惯使用 pip 和 venv,也可以执行以下命令:
# Create virtual environment
+python3 -m venv .venv
+
+# Activate virtual environment
+source .venv/bin/activate
+
+# Install AgentKit
+pip install agentkit-sdk-python安装完成后,执行以下命令验证 agentkit CLI 是否可用:
agentkit --version如果成功输出版本号,则说明 AgentKit 已成功安装。
在使用 agentkit CLI 与 AgentKit Platform 交互之前,您需要配置访问凭证(AK/SK)。
使用 AgentKit 的全局配置功能来安全地存储您的凭证:
# 初始化全局配置
+agentkit config --global --init
+
+# 设置您的访问凭证
+agentkit config --global --set volcengine.access_key="YOUR_ACCESS_KEY"
+agentkit config --global --set volcengine.secret_key="YOUR_SECRET_KEY"
+
+# 验证配置
+agentkit config --global --show这种方式将凭证安全地存储在 ~/.agentkit/config.yaml 文件中,避免在 shell 历史记录中暴露敏感信息。
对于临时开发调试,您可以设置环境变量:
export VOLCENGINE_ACCESS_KEY="YOUR_ACCESS_KEY"
+export VOLCENGINE_SECRET_KEY="YOUR_SECRET_KEY"⚠️ 注意:出于安全考虑,不建议将包含敏感信息的 export 命令添加到 shell 配置文件(如 ~/.bashrc 或 ~/.zshrc)中,因为这可能导致凭证泄露。
现在您已经成功安装并配置了 AgentKit,可以开始构建您的第一个 Agent 了。
`,42)])])}const g=i(l,[["render",e]]);export{c as __pageData,g as default}; diff --git a/assets/content_1.introduction_2.installation.md.B_uDtPtx.lean.js b/assets/content_1.introduction_2.installation.md.B_uDtPtx.lean.js new file mode 100644 index 0000000..454b030 --- /dev/null +++ b/assets/content_1.introduction_2.installation.md.B_uDtPtx.lean.js @@ -0,0 +1 @@ +import{_ as i,c as a,o as n,ag as t}from"./chunks/framework.CA4hJK0u.js";const c=JSON.parse('{"title":"安装 AgentKit","description":"","frontmatter":{},"headers":[],"relativePath":"content/1.introduction/2.installation.md","filePath":"content/1.introduction/2.installation.md","lastUpdated":1766137123000}'),l={name:"content/1.introduction/2.installation.md"};function e(h,s,p,k,d,r){return n(),a("div",null,[...s[0]||(s[0]=[t("",42)])])}const g=i(l,[["render",e]]);export{c as __pageData,g as default}; diff --git a/assets/content_1.introduction_3.quickstart.md.D8kgkZZU.js b/assets/content_1.introduction_3.quickstart.md.D8kgkZZU.js new file mode 100644 index 0000000..157abf4 --- /dev/null +++ b/assets/content_1.introduction_3.quickstart.md.D8kgkZZU.js @@ -0,0 +1,30 @@ +import{_ as e,a as l}from"./chunks/model_apikey.BbUdt8Yv.js";import{_ as p,c as h,o as k,ag as n,j as i,a,t as o}from"./chunks/framework.CA4hJK0u.js";const E=JSON.parse('{"title":"快速入门","description":"","frontmatter":{},"headers":[],"relativePath":"content/1.introduction/3.quickstart.md","filePath":"content/1.introduction/3.quickstart.md","lastUpdated":1766137123000}'),r={name:"content/1.introduction/3.quickstart.md"};function g(t,s,d,c,F,y){return k(),h("div",null,[s[5]||(s[5]=n(`本指南将引导您使用 “Basic Agent App” 模板开发一个简单的 Agent,快速体验 AgentKit 从开发、部署到测试的全流程。AgentKit 提供多种模板,包括基础应用、流式输出、A2A 协议等,支持 Python 和 Golang 开发。
首先,您需要一个火山引擎账号并开通 AgentKit 服务。请访问 火山引擎控制台 完成注册和开通。
然后,在 访问控制 页面创建并获取访问密钥 (AK/SK)。
获取后,请将其设置为环境变量:
export VOLCENGINE_ACCESS_KEY=<your_access_key>
+export VOLCENGINE_SECRET_KEY=<your_secret_key>您的 Agent 通常需要调用大语言模型 (LLM) 来提供核心智能。AgentKit Platform 支持火山方舟的多种模型。请确保您已开通 火山方舟 服务,并获取模型推理的 Endpoint 和 API Key。
获取推理接入点 (Endpoint): 在方舟平台的「在线推理」页面,您可以选择预置的推理接入点,或创建自定义推理接入点。
获取 API Key: 在「API Key 管理」页面,选择或创建一个新的 API Key。
请记录下您的 Endpoint ID 如ep-20250520174054-xxxxx(也可以是模型ID如 deepseek-v3-1-terminus)和 API Key,后续将通过环境变量MODEL_AGENT_NAME和MODEL_AGENT_API_KEY配置给 Agent
如果您不提供这些信息,AgentKit Platform 将在云端部署时自动为您注入一个内置的
doubao-seed-1-6模型。
如果您计划在本地 (Local 模式) 运行和调试 Agent,由于本地环境无法自动注入云端凭证,您必须手动配置访问凭证,否则 Agent 将无法调用大模型。
您可以通过以下两种方式之一配置凭证:
方式一:配置方舟模型凭证
直接指定要使用的模型接入点和 API Key:
# 在 config 时通过 --runtime_envs (-e) 设置
+agentkit config -e MODEL_AGENT_NAME=<your_endpoint_id> -e MODEL_AGENT_API_KEY=<your_api_key>方式二:配置火山引擎访问密钥
如果配置了火山引擎的 AK/SK,veADK 会尝试自动获取您的模型访问权限:
# 在 config 时通过 --runtime_envs (-e) 设置
+agentkit config -e VOLCENGINE_ACCESS_KEY=<your_access_key> -e VOLCENGINE_SECRET_KEY=<your_secret_key>注意:
- 在 Local 模式下,直接在宿主机 shell 中
export环境变量对容器内无效,必须使用agentkit config -e将其写入agentkit.yaml的runtime_envs中。- 在 Cloud 模式下,Runtime 会自动注入相关凭证,通常无需手动配置上述环境变量。
在开始之前,请确保您已遵循 安装 AgentKit 指南完成 agentkit CLI 的安装和环境配置。
创建一个项目目录,并使用 agentkit init 命令初始化您的 Agent 应用:
mkdir simple-agent && cd simple-agent
+agentkit init执行后会显示可用模板列表,选择模板 1 (Basic Agent App)。您也可以使用 --template 参数直接指定模板:
# 使用基础模板
+agentkit init --template basic
+
+# 使用流式输出模板
+agentkit init --template basic_stream
+
+# 查看所有可用模板
+agentkit init --list-templates命令执行后,将在当前目录生成模板代码和配置文件:
.
+├── agentkit.yaml # **Agent** 的核心配置文件。
+├── requirements.txt # 项目的 Python 依赖。
+└── simple_agent.py # **Agent** 应用的入口文件。您可以使用 agentkit launch 命令一键完成应用的构建和云端部署。该命令会使用 agentkit.yaml 文件中的配置。
如果需要自定义配置(例如,指定部署区域、镜像仓库或传入模型密钥),可以手动编辑 agentkit.yaml,或运行 agentkit config 命令,通过交互式向导生成配置。
agentkit config配置向导会引导您完成以下设置:
通用配置(按 回车 使用默认值):
simple_agent,可直接按回车使用默认值)simple_agent.py)requirements.txt 或 go.modMODEL_AGENT_NAME:方舟模型接入点 ID(可选)MODEL_AGENT_API_KEY:方舟模型 API Key(可选)cloud(云端构建和部署)云端部署配置:
`,41)),i("ul",null,[s[3]||(s[3]=i("li",null,[i("strong",null,"1.服务区域"),a(":默认 "),i("code",null,"cn-beijing")],-1)),i("li",null,[s[0]||(s[0]=i("strong",null,"2.镜像标签",-1)),s[1]||(s[1]=a(":默认 ",-1)),i("code",null,o(t.timestamp),1),s[2]||(s[2]=a(", 会自动渲染为时间戳,格式如20251218154940",-1))]),s[4]||(s[4]=i("li",null,[i("strong",null,"3.CR 镜像仓库"),a(":CLI 会自动生成CR实例名称、CR命名空间和CR仓库名,用户也可手动指定(建议自动即可)")],-1))]),s[6]||(s[6]=n(`完成配置后,执行 launch 命令即可一键部署:
agentkit launch该命令会自动完成以下步骤:
部署成功会显示:
✅ 创建Runtime成功: r-ye9j62wydcn****nhsoa, request_id: 20251120***************5344
+等待Runtime状态为Ready...
+💡 提示:Runtime初始化中,请耐心等待,不要中断进程
+✅ Runtime状态为Ready
+ Runtime状态: Releasing ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:23
+Endpoint: https://sd4fe31poh486****.apigateway-cn-beijing.volceapi.com
+100% ▶ 部署完成
+✅ Successfully launched agent: https://sd4fe31poh486npgcaqq0.apigateway-cn-beijing.volceapi.com
+Built image: agentkit-cli-21076x****-cn-beijing.cr.volces.com/agentkit/myapp:2025112017****
+Endpoint: https://sd4fe31poh486****.apigateway-cn-beijing.volceapi.com提示:首次部署大约需要 2-3 分钟,请耐心等待。
使用 invoke 命令测试 Agent:
agentkit invoke "你好"如果看到类似下面的输出,恭喜您,第一个 Agent 已成功运行!
(agentkit) test@localhost:~/workspace/simple-agent$ agentkit invoke "你好"
+Invoking agent...
+Using default headers: {'user_id': 'agentkit_user', 'session_id': 'agentkit_sample_session'}
+✅ Invocation successful
+📝 Response:
+你好!我是由****团队开发的AI助手,擅长数据科学(信息收集、数据分析等)、文档编写(撰写多章节文章、深度研究报告)以及软件开发(创建网站/应用、解决代码问题等)
+。有什么具体需求,我很乐意为你提供帮助!恭喜您完成了第一个 Agent 的开发和部署!
接下来您可以:
agentkit memory、agentkit knowledge、agentkit tools 等命令管理平台服务本指南旨在帮助您诊断和解决在使用 AgentKit 过程中可能遇到的常见问题。如果您在此处未找到解决方案,请随时通过 GitHub Issues 与我们联系。
agentkit 命令未找到 agentkit 命令时,系统提示 command not found。pip 安装的可执行文件路径未被添加到系统的 PATH 环境变量中。pip show agentkit-sdk-python 或 uv pip show agentkit-sdk-python,找到 Location 字段指示的安装路径。bin 目录中(例如 .../site-packages/bin),应该能找到 agentkit 可执行文件。bin 目录的绝对路径添加到您的 ~/.bashrc、~/.zshrc 或其他 Shell 配置文件中。export PATH="/path/to/your/python/bin:$PATH"source ~/.bashrc 或重启终端以使更改生效。agentkit-sdk-python 时,pip 报告依赖版本冲突。uv 或 venv 创建一个干净的虚拟环境,以避免与系统级的 Python 包产生冲突。uv venv
+source .venv/bin/activate
+uv pip install agentkit-sdk-pythonpip uninstall agentkit-sdk-python
+pip install agentkit-sdk-pythonecho $VOLCENGINE_ACCESS_KEY
+echo $VOLCENGINE_SECRET_KEYagentkit launch 时提示配置文件解析失败。agentkit.yaml 格式是否正确(注意缩进)agentkit config 生成配置CreateRegistry: QuotaExceeded.Registry The quota of Registry is exceeded.agentkit config 中配置为已有的 CR 实例名称requirements.txt 中的依赖是否正确Releasing 状态。agentkit status 检查状态agentkit destroy 后重新部署Failed 或 Error。agentkit destroy 清理后重新部署agentkit invoke 时提示连接失败或超时。agentkit status 确认 Runtime 状态为 ReadyInvalidAccessKeyId 或 SignatureDoesNotMatch。AccessDenied 或权限不足。如果以上方案无法解决您的问题,请:
查看日志:
联系支持:
查阅文档:
AgentKit CLI 是一个为开发者设计的强大命令行工具,旨在简化和加速 Agent 应用的开发、部署和管理全生命周期。无论您是进行本地快速原型验证,还是在生产环境中进行规模化部署,agentkit 命令都能提供一致且高效的开发体验。
agentkit.yaml 文件管理,清晰、可移植且易于版本控制。agentkit launch 等高级命令,将构建、部署等多个步骤合而为一,极大提升效率。agentkit config 等交互式向导,引导您完成配置,降低学习成本。agentkit CLI 提供了一系列直观的命令来管理您的 Agent 应用:
| 命令 | 功能描述 |
|---|---|
agentkit init | 初始化一个新的 Agent 项目,可选择不同的模板。 |
agentkit config | 通过交互式向导配置 agentkit.yaml 文件。 |
agentkit build | 将您的 Agent 应用构建为 Docker 镜像。 |
agentkit deploy | 将已构建的镜像部署到指定环境 (本地或云端)。 |
agentkit launch | 一键完成构建和部署,是开发中最常用的命令。 |
agentkit invoke | 与已部署的 Agent 进行交互,用于快速测试。 |
agentkit status | 查看 Agent 的运行状态和 Endpoint。 |
agentkit destroy | 停止并销毁 Agent 实例,释放相关资源。 |
| 命令 | 功能描述 |
|---|---|
agentkit memory | 管理 AgentKit Memory 记忆集合。 |
agentkit knowledge | 管理 AgentKit Knowledge 知识库。 |
agentkit tools | 管理 AgentKit Tools 工具和 Sessions 会话。 |
agentkit runtime | 管理 AgentKit Runtime 运行时实例。 |
想要了解每个命令的详细用法?请查阅 命令详解。
AgentKit CLI 的核心特性之一是其灵活的部署模型,旨在适应从开发到生产的不同阶段。
local) 在您的本地机器上完成构建和部署,非常适合快速开发和调试。
源代码 → 本地 Docker 构建 → 本地容器运行cloud) 将代码的构建和部署完全托管在 AgentKit Platform 上,是生产环境的最佳实践。
源代码 → 云端自动构建 → 云端镜像仓库 → 生产级 Runtimehybrid) 在本地构建镜像,然后将其推送到云端 AgentKit Platform 进行部署。这种模式结合了本地控制和云端能力的优点。
源代码 → 本地 Docker 构建 → 上传至云端镜像仓库 → 生产级 Runtimeagentkit.yaml) agentkit.yaml 是 AgentKit 项目的核心,它以声明式的方式定义了应用的所有配置。我们强烈建议使用 agentkit config 命令来管理此文件。
# 通用配置
+common:
+ agent_name: my-agent
+ entry_point: app.py
+ python_version: '3.12'
+ launch_type: cloud # 定义默认的部署模式
+
+# 不同部署模式的特定配置
+launch_types:
+ cloud:
+ region: cn-beijing
+ image_tag: latest
+ runtime_envs:
+ MODEL_API_KEY: "your-api-key"想要了解所有配置项的详细说明?请查阅 配置详解。
只需几分钟,即可完成您的第一个 Agent 的部署。
# 1. 初始化项目 (选择 Basic App 模板)
+mkdir my-first-agent && cd my-first-agent
+agentkit init my-first-agent
+
+# 或者指定特定模板
+agentkit init my-first-agent --template basic_stream # 流式输出模板
+agentkit init my-first-agent --template a2a # A2A 协议模板
+
+# 2. 配置应用 (通过交互式向导)
+agentkit config
+
+# 3. 一键部署到云端
+agentkit launch
+
+# 4. 测试您的 Agent
+agentkit invoke "你好!"
+
+# 5. 查看运行状态
+agentkit status
+
+# 6. 清理资源(可选)
+agentkit destroy# 查看可用模板
+agentkit init --list-templates
+
+# 管理平台服务
+agentkit memory list # 查看记忆集合
+agentkit knowledge list # 查看知识库
+agentkit tools list # 查看工具列表
+agentkit runtime list # 查看运行时实例requirements.txt 管理依赖go.mod 管理依赖# 初始化全局配置
+agentkit config --global --init
+
+# 设置访问凭证
+agentkit config --global --set volcengine.access_key="your_access_key"
+agentkit config --global --set volcengine.secret_key="your_secret_key"
+
+# (Byteplus 可选)设置默认云服务为 BytePlus
+agentkit config --global --set defaults.cloud_provider=byteplus
+
+# (Byteplus 可选)设置Byteplus访问凭证
+agentkit config --global --set byteplus.access_key="your_byteplus_access_key"
+agentkit config --global --set byteplus.secret_key="your_byteplus_secret_key"AgentKit CLI 是您与 AgentKit Platform 交互的核心工具,提供了一套完整的命令集,旨在简化和自动化 Agent 开发、部署和管理的整个生命周期。无论您是初始化新项目、配置云端资源,还是测试和迭代您的 Agent,AgentKit CLI 都能提供强大支持。
本篇文档将详细介绍每个命令的功能、参数选项和最佳实践,帮助您高效利用 AgentKit CLI 构建卓越的 Agent 应用。
AgentKit CLI 遵循标准的 agentkit <command> [arguments] [options] 格式。
| 命令 | 功能描述 | 核心应用场景 |
|---|---|---|
init | 初始化项目:创建全新的 Agent 项目或包装现有代码。 | 启动新 Agent 开发、快速部署已有代码。 |
config | 配置应用:以交互或非交互方式管理项目配置。 | 设置部署模式、环境变量、镜像标签等。 |
build | 构建镜像:将您的 Agent 代码打包成可移植的 Docker 镜像。 | 准备部署、CI/CD 集成。 |
deploy | 部署应用:将已构建的镜像发布到目标运行环境。 | 上线或更新 Agent 服务。 |
launch | 一键启动:自动完成构建和部署两个步骤。 | 快速迭代、简化上线流程。 |
invoke | 测试调用:在本地或云端直接调用 Agent,进行功能验证。 | 调试 Agent 逻辑、验证端到端功能。 |
status | 查看状态:获取已部署 Agent 的运行状态和端点信息。 | 监控服务健康状况、获取访问地址。 |
destroy | 清理资源:停止并删除已部署的 Agent 实例及相关资源。 | 下线服务、释放云资源。 |
agentkit init agentkit init 命令用于引导一个新的 Agent 项目,支持从零开始和基于现有代码两种模式,极大提升了项目启动效率。
veadk Agent 定义文件快速包装成可部署的 AgentKit 项目,实现代码复用。# 模板模式:从预设模板创建
+agentkit init [project_name] [options]
+
+# 包装模式:包装现有的 Agent 定义文件
+agentkit init [project_name] --from-agent <path_to_agent_file> [options]project_name (可选): smart-faq-agent。simple_agent;包装模式下根据源文件名自动生成 (例如 agentkit-my_agent)。_) 和中划线 (-)。| 选项 | 描述 | 示例 |
|---|---|---|
--template, -t | 选择项目模板,如 basic、basic_stream、a2a。 | --template basic |
--agent-name | 设置 Agent 的显示名称。 | --agent-name "智能客服" |
--description | Agent 的功能描述,在多 Agent 协作场景中尤为重要。 | --description "处理常见的用户问题" |
--system-prompt | 定义 Agent 的系统提示词,塑造其角色和行为。 | --system-prompt "你是一个专业的客服..." |
--model-name | 指定火山引擎方舟平台上的模型名称。 | --model-name "doubao-pro-32k" |
--tools | 以逗号分隔的工具列表,如 web_search,run_code。 | --tools "web_search" |
| 选项 | 描述 | 示例 |
|---|---|---|
--from-agent, -f | (必需) 指定包含 veadk.Agent 定义的现有 Python 文件路径。 | --from-agent ./my_existing_agent.py |
--agent-var | 当自动检测失败时,手动指定 Agent 对象在文件中的变量名。 | --agent-var "custom_agent_instance" |
--wrapper-type | 生成的包装器类型,basic (标准) 或 stream (流式)。 | --wrapper-type stream |
| 选项 | 描述 | 默认值 |
|---|---|---|
--directory | 指定创建项目的目标目录。 | 当前目录 (.) |
# 示例 1: 交互式创建,引导您选择模板
+agentkit init my-first-agent
+
+# 示例 2: 直接使用 'basic' 模板创建
+agentkit init weather-report-agent --template basic
+
+# 示例 3:在指定目录创建
+agentkit init my_agent --template basic_stream --directory ./my_agents
+
+# 示例 4:使用简写
+agentkit init weather -t basic
+
+# 示例 5: 自定义 Agent 属性
+agentkit init custom-agent \\
+ --template basic \\
+ --agent-name "高级助理" \\
+ --description "一个具备联网和代码执行能力的 Agent" \\
+ --tools "web_search,run_code"
+
+# 示例 6:创建流式输出的 Agent
+agentkit init stream_agent \\
+ --template basic_stream \\
+ --agent-name "流式对话助手" \\
+ --model-name "doubao-seed-1-6-250615"# 示例 7:包装现有 Agent 文件(自动检测 Agent 变量)
+agentkit init --from-agent ./my_agent.py
+
+# 示例 8:包装并指定项目名称
+agentkit init weather_bot --from-agent ./weather_agent.py
+
+# 示例 9:使用简写和指定 Agent 变量名
+agentkit init -f ./my_agent.py --agent-var my_custom_agent
+
+# 示例 10:生成流式输出包装器
+agentkit init chat_bot \\
+ --from-agent ./chat_agent.py \\
+ --wrapper-type stream
+
+# 示例 11:在指定目录包装
+agentkit init deployed_agent \\
+ --from-agent ../agents/production_agent.py \\
+ --agent-var prod_agent \\
+ --wrapper-type basic \\
+ --directory ./deployment
+
+# 示例 12:完整的包装命令
+agentkit init my_deployed_bot \\
+ -f ~/projects/agents/my_bot.py \\
+ --agent-var bot \\
+ --wrapper-type stream \\
+ --directory ./deploy最佳实践
basic 模板开始,它提供了简洁的项目结构。veadk Agent 逻辑时,使用包装模式可以避免重写代码,专注于快速部署。当你运行模板模式命令后,会看到类似这样的输出:
✨ Build AI Agents with Ease ✨
+
+Available Templates
+┌────┬──────────────────────────┬──────────┬──────────────────────────────────┐
+│ ID │ Name │ Type │ Description │
+├────┼──────────────────────────┼──────────┼──────────────────────────────────┤
+│ 1 │ Basic Agent App │ Basic App│ 基础Agent应用,适合快速入门 │
+│ 2 │ Basic Stream Agent App │ Stream App│ 支持流式输出的Agent应用 │
+│ 3 │ A2A Agent App │ A2A App │ 支持A2A协议的多智能体应用 │
+│ 4 │ Eino A2A Agent App │ A2A App │ 基于Eino框架的A2A应用(Golang) │
+└────┴──────────────────────────┴──────────┴──────────────────────────────────┘
+
+Please select a template by entering the ID (1-2):
+Template ID: 1
+Selected: Basic Agent App
+
+Creating project: my_weather_agent
+Using template: Basic Agent App
+
+✨ Project initialized successfully!
+Template: Basic Agent App
+Entry point: my_weather_agent.py
+Language: Python 3.12
+
+Created files:
+ ✓ my_weather_agent.py
+ ✓ requirements.txt
+ ✓ agentkit.yaml
+ ✓ .dockerignore
+
+Next steps:
+ 1. Review and modify the generated files
+ 2. Use agentkit config to configure your agent
+ 3. Use agentkit launch to build and deploy当你运行包装模式命令后,会看到类似这样的输出:
✨ Build AI Agents with Ease ✨
+
+🔄 Wrapping existing Agent file
+
+Project name: agentkit-my_agent
+Agent file: ./my_agent.py
+Wrapper type: basic
+
+✨ Project initialized successfully!
+Template: Agent Wrapper (Basic)
+Entry point: agentkit-my_agent.py
+Language: Python 3.12
+Agent file: my_agent.py
+Agent variable: agent
+
+Created files:
+ ✓ my_agent.py
+ ✓ agentkit-my_agent.py
+ ✓ requirements.txt
+ ✓ agentkit.yaml
+ ✓ .dockerignore
+
+Next steps:
+ 1. Review and modify the generated files
+ 2. Use agentkit config to configure your agent
+ 3. Use agentkit launch to build and deploy包装模式是一个强大的功能,让你能够快速将已有的 Agent 定义文件部署到 AgentKit 平台,无需重写代码。
agentkit.yaml 和其他必要的部署文件生成的包装器文件负责:
@app.entrypoint 和 @app.ping 接口你的 Agent 文件需要满足以下条件:
基本要求:
# 必须是 Python 文件 (.py)
+# 必须包含 Agent 对象定义
+
+from veadk import Agent
+
+# Agent 定义 - 变量名可以是 agent、my_agent 等
+agent = Agent(
+ model="doubao-seed-1-6-250615",
+ description="我的 Agent"
+)支持的 Agent 变量名:
agent, main_agent, my_agent 等--agent-var 参数指定不支持的情况:
Agent(...) 定义| 特性 | Basic 包装器 | Stream 包装器 |
|---|---|---|
| 响应方式 | 一次性返回完整结果 | 流式返回(SSE) |
| 适用场景 | 标准对话、短响应 | 长文本生成、实时输出 |
| 依赖包 | veadk-python | veadk-python + google-adk |
| 配置要求 | 无特殊要求 | Agent 需要支持流式输出 |
| 客户端体验 | 等待后一次性显示 | 逐字显示,更好的交互体验 |
适合使用包装模式的场景:
适合使用模板模式的场景:
my_project/
+├── my_agent.py # 你的原始 Agent 定义
+├── agentkit-my_agent.py # AgentKit 生成的包装器(入口文件)
+├── requirements.txt # 依赖列表(含使用提示)
+├── agentkit.yaml # 部署配置(entry_point 指向包装器)
+└── .dockerignore # Docker 构建忽略规则包装器文件示例 (basic 类型):
# 导入你的 Agent
+from my_agent import agent
+
+from veadk import Runner
+from agentkit.apps import AgentkitSimpleApp
+
+app = AgentkitSimpleApp()
+runner = Runner(agent=agent)
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ prompt = payload["prompt"]
+ user_id = headers["user_id"]
+ session_id = headers["session_id"]
+
+ response = await runner.run(
+ messages=prompt,
+ user_id=user_id,
+ session_id=session_id
+ )
+ return response
+
+@app.ping
+def ping() -> str:
+ return "pong!"
+
+if __name__ == "__main__":
+ app.run(host="0.0.0.0", port=8000)Q: 找不到 Agent 定义怎么办?
A: 使用 --agent-var 参数明确指定 Agent 变量名:
agentkit init -f ./my_agent.py --agent-var my_custom_agent_nameQ: 可以修改生成的包装器吗?
A: 可以!包装器是标准的 Python 代码,你可以根据需要自由修改。但要注意保持 @app.entrypoint 和 @app.ping 接口不变。
Q: 原始 Agent 文件会被修改吗?
A: 不会!系统只会复制你的文件到目标目录,不会修改原文件。
Q: 如何在包装器中添加额外的依赖?
A: 编辑生成的 requirements.txt 文件,添加你需要的依赖包。文件中已经包含了使用提示。
配置 Agent 应用的参数。支持三种模式:交互式(友好引导)、非交互式(快速更新)和混合模式(灵活组合)。
🆕 全局配置支持:新增全局配置功能(~/.agentkit/config.yaml),可跨项目共享配置。
# 项目配置
+agentkit config [参数] [选项]
+
+# 项目级:设置云平台(volcengine/byteplus)
+agentkit config --cloud_provider byteplus
+
+# 全局配置 🆕
+agentkit config --global [选项]无参数运行,系统会一步步引导你填写各项参数:
agentkit config交互流程示例:
[1/7] 🤖 Agent 名称: my_agent
+[2/7] 📝 入口文件: my_agent.py
+[3/7] 📄 应用描述: 我的天气查询 Agent
+[4/7] 🐍 Python 版本: 3.12
+[5/7] 📦 依赖文件: requirements.txt
+[6/7] 🚀 部署模式(选一个):
+ 1. local - 本地构建和运行
+ 2. hybrid - 本地构建,云端运行
+ 3. cloud - 云端构建和运行(推荐)
+[7/7] 🔐 应用级环境变量(所有模式共享):
+ 变量: MODEL_API_KEY=xxxxx通过命令行参数直接配置,无需手动输入:
# 完整配置示例
+agentkit config \\
+ --agent_name myAgent \\
+ --entry_point agent.py \\
+ --launch_type cloud \\
+ --cloud_provider byteplus \\
+ --image_tag v1.0.0 \\
+ --runtime_envs API_KEY=xxxxx# 增量更新(只修改部分配置)
+agentkit config --entry_point new_agent.py
+agentkit config --image_tag v1.0.1部分参数通过命令行指定,其他参数交互式输入:
agentkit config --agent_name myAgent --interactive| 参数 | 说明 | 示例 |
|---|---|---|
--agent_name | Agent应用名称 | my_weather_bot |
--entry_point | 入口文件(必须 .py) | agent.py |
--description | 应用描述 | "天气查询助手" |
--python_version | Python版本 | 3.12 |
--dependencies_file | 依赖文件 | requirements.txt |
--launch_type | 部署模式 | local, hybrid, cloud |
--cloud_provider / --cloud-provider | 云平台 | volcengine, byteplus |
AgentKit 支持两级环境变量配置:
| 参数 | 级别 | 说明 | 使用场景 |
|---|---|---|---|
--runtime_envs / -e | 应用级 | 所有部署模式共享 | API密钥、模型端点等跨环境配置 |
--workflow-runtime-envs | Workflow级 | 仅当前部署模式使用 | 调试标志、特定环境配置 |
使用示例:
# 应用级(所有模式共享)
+agentkit config \\
+ -e API_KEY=shared-key \\
+ -e MODEL_ENDPOINT=https://api.example.com
+
+# Workflow级(仅当前模式)
+agentkit config \\
+ --workflow-runtime-envs DEBUG=true \\
+ --workflow-runtime-envs LOCAL_CACHE=/tmp
+
+# 混合使用
+agentkit config \\
+ -e API_KEY=shared \\
+ --workflow-runtime-envs DEBUG=true配置合并规则:
| 参数 | 说明 | 示例 |
|---|---|---|
--region | 火山引擎区域 | cn-beijing |
--tos_bucket | TOS存储桶 | agentkit-bucket |
--image_tag | 镜像标签 | v1.0.0, latest |
--cr_instance_name | CR实例名称 | my-cr-instance |
--cr_namespace_name | CR命名空间 | agentkit |
--cr_repo_name | CR仓库名称 | my-agent |
💡 提示:
--cr_*参数也支持旧的--ve_cr_*别名,保持向后兼容。
你可以通过 agentkit config 把 Runtime 与资源组件进行关联(或解绑),在 agentkit launch/deploy 创建/更新 Runtime 时自动透传到 Runtime API。
支持的关联字段:
memory_id:关联 Memoryknowledge_id:关联 Knowledgetool_id:关联 Toolmcp_toolset_id:关联 MCP Toolset命令行配置示例:
# 绑定资源
+agentkit config \\
+ --memory_id mem-xxx \\
+ --knowledge_id kb-xxx \\
+ --tool_id tool-xxx \\
+ --mcp_toolset_id mcp-ts-xxx
+
+# 解绑(设置为空字符串)
+agentkit config --memory_id ""YAML 落盘位置(agentkit.yaml):
launch_types:
+ cloud: # 或 hybrid
+ runtime_bindings:
+ memory_id: mem-xxx
+ knowledge_id: kb-xxx
+ tool_id: tool-xxx
+ mcp_toolset_id: mcp-ts-xxx💡 解绑语义说明:
- 配置里 不写某个 key:表示不变更该绑定
- 配置为
""或null:表示清空/解绑(会在更新 Runtime 时下发清空)
你可以通过 agentkit config 为 Runtime 设置网络(VPC/私网、公网或双栈)。该配置会在 首次创建 Runtime(CreateRuntime) 时生效。
⚠️ 限制:Runtime 已存在时,
agentkit launch/deploy会走 UpdateRuntime, 而 UpdateRuntime 不支持修改network_configuration,所以该配置不会影响已有 Runtime 的网络。 如果你需要变更网络,请销毁并重新创建 Runtime。
命令行配置示例(私网):
agentkit config \\
+ --runtime-network-mode private \\
+ --runtime-vpc-id vpc-xxxxxxxx \\
+ --runtime-subnet-id subnet-aaaaaaaa \\
+ --runtime-enable-shared-internet-accessYAML 配置格式(agentkit.yaml):
launch_types:
+ cloud: # 或 hybrid
+ runtime_network:
+ mode: private # public | private | both
+ vpc_id: vpc-xxxxxxxx # private/both 必填
+ enable_shared_internet_access: true # 仅对 private/both 生效
+ subnet_ids:
+ - subnet-aaaaaaaamode 取值说明:
public:仅公网访问private:仅私网访问(需要 vpc_id)both:同时开启公网与私网(需要 vpc_id)enable_shared_internet_access 说明:
mode 为 private 或 both 时生效;开启后 Runtime 将使用平台提供的共享公网出口访问公网mode=public 且开启该开关,AgentKit 会报错以避免“看似配置但实际不生效”的误用| 选项 | 说明 |
|---|---|
--config, -c | 指定配置文件路径(默认 agentkit.yaml) |
--interactive, -i | 强制使用交互式模式 |
--dry-run | 预览模式,显示变更但不保存 |
--show, -s | 显示当前配置 |
AgentKit 支持全局配置文件(~/.agentkit/config.yaml),用于跨项目共享配置。
| 选项 | 说明 |
|---|---|
--global, -g | 操作全局配置而非项目配置 |
--init | 初始化全局配置文件(创建模板) |
--set | 设置全局配置字段(格式:key=value) |
支持的全局配置字段:
| 字段 | 说明 | 示例 |
|---|---|---|
volcengine.access_key | 火山引擎 Access Key | AK*** |
volcengine.secret_key | 火山引擎 Secret Key | SK*** |
volcengine.region | 默认区域 | cn-beijing |
cr.instance_name | CR 实例名称 | team-cr-instance |
cr.namespace_name | CR 命名空间 | agentkit-team |
tos.bucket | TOS Bucket 名称 | team-agentkit-builds |
tos.prefix | TOS 对象前缀 | agentkit-builds |
tos.region | TOS 区域 | cn-beijing |
配置优先级:
环境变量 > 项目配置(agentkit.yaml) > 全局配置 > 默认值agentkit config# 更新入口文件
+agentkit config --entry_point new_agent.py
+
+# 更新镜像标签
+agentkit config --image_tag v1.0.1
+
+# 添加环境变量
+agentkit config -e NEW_KEY=new_valueagentkit config \\
+ --agent_name weather-bot \\
+ --entry_point agent.py \\
+ --description "天气查询助手" \\
+ --launch_type cloud \\
+ --image_tag v1.0.0 \\
+ --region cn-beijing \\
+ -e API_KEY=xxxxx \\
+ -e MODEL_ENDPOINT=https://api.example.com# 查看配置变更但不保存
+agentkit config --entry_point agent.py --image_tag v2.0 --dry-run输出示例:
通用配置 - 变更项:
+┌───────────────┬──────────────┬──────────────┐
+│ 配置项 │ 原值 │ 新值 │
+├───────────────┼──────────────┼──────────────┤
+│ entry_point │ old_agent.py │ agent.py │
+│ image_tag │ v1.0 │ v2.0 │
+└───────────────┴──────────────┴──────────────┘
+
+🔍 预览模式:未保存任何更改agentkit config --show初始化全局配置:
# 创建全局配置模板
+agentkit config --global --init输出:
✅ 全局配置文件已创建: ~/.agentkit/config.yaml
+
+📝 配置模板已生成,包含以下配置项:
+
+🔐 Volcengine 凭证
+ access_key: ''
+ secret_key: ''
+ region: cn-beijing
+
+📦 CR 配置
+ instance_name: ''
+ namespace_name: ''
+
+🗂️ TOS 配置
+ bucket: ''
+ prefix: agentkit-builds
+ region: cn-beijing查看全局配置:
agentkit config --global --show设置全局配置:
# 设置单个字段
+agentkit config --global --set cr.instance_name=team-cr-instance
+agentkit config --global --set tos.bucket=team-bucket
+
+# 设置凭证
+agentkit config --global --set volcengine.access_key=AK***
+agentkit config --global --set volcengine.secret_key=SK***团队协作场景:
# 1. 团队管理员创建并分享全局配置
+agentkit config --global --init
+vim ~/.agentkit/config.yaml # 填入团队共享的配置
+
+# 2. 团队成员初始化项目时自动使用全局配置
+agentkit init my-agent
+# agentkit.yaml 中相关字段自动留空,运行时使用全局配置
+
+# 3. 特殊项目可以在 agentkit.yaml 中覆盖全局配置
+agentkit config --cr_instance_name special-cr # 覆盖全局配置# 在CI/CD流水线中使用
+agentkit config \\
+ --agent_name \${CI_PROJECT_NAME} \\
+ --entry_point agent.py \\
+ --launch_type cloud \\
+ --image_tag \${CI_COMMIT_TAG} \\
+ -e DEPLOY_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
+
+agentkit launch在交互式模式中,环境变量配置支持便捷命令:
🔐 应用级环境变量(输入 KEY=VALUE,空行结束)
+
+ 可用命令:
+ - 输入 KEY=VALUE 添加变量
+ - 输入 'list' 查看已有变量
+ - 输入 'del KEY' 删除某个变量
+ - 输入 'clear' 清空所有
+ - 直接按回车结束输入
+
+变量: MODEL_API_KEY=xxxxx
+✅ 已添加: MODEL_API_KEY
+
+变量: list
+当前变量:
+ MODEL_API_KEY=xxxxx
+
+变量: [回车结束]
+📋 共配置 1 个变量所有配置都会自动验证:
.py 结尾local、hybrid 或 cloud验证失败会显示详细错误信息并退出。
首次配置用交互式:更友好的引导体验
agentkit config日常修改用非交互式:快速高效
agentkit config --entry_point new_agent.pyCI/CD用非交互式:完全自动化
agentkit config --agent_name $PROJECT --image_tag $TAG修改前先预览:避免错误
agentkit config --entry_point agent.py --dry-run环境变量分级管理:
团队协作使用全局配置 🆕:
# 团队管理员设置
+agentkit config --global --init
+agentkit config --global --set cr.instance_name=team-cr
+agentkit config --global --set tos.bucket=team-bucket
+
+# 团队成员直接使用
+agentkit init my-agent # 自动使用全局配置
+agentkit launch # 运行时自动使用全局配置配置优先级理解:
环境变量 > 项目配置 > 全局配置 > 默认值将你的 Agent 代码打包成 Docker 镜像,为部署做准备。
agentkit build [选项]--config-file 配置文件路径
agentkit.yaml--platform 构建平台
auto(自动识别)--regenerate-dockerfile 强制重新生成 Dockerfile
FalseAgentKit 支持通过 docker_build 配置段自定义 Docker 镜像构建过程。在 agentkit.yaml 中添加以下配置:
base_image - 自定义基础镜像
Python 项目(字符串格式):
docker_build:
+ base_image: "python:3.12-slim"
+ # 或使用 Alpine 镜像
+ base_image: "python:3.12-alpine"build_script - 自定义构建脚本
docker_build:
+ build_script: "scripts/setup.sh"Python 项目示例:
agent_name: my-agent
+entry_point: agent.py
+language: Python
+language_version: "3.12"
+dependencies_file: requirements.txt
+launch_type: local
+
+# Docker 构建自定义配置
+docker_build:
+ base_image: "python:3.12-alpine"
+ build_script: "scripts/setup.sh"构建脚本示例 (scripts/setup.sh):
#!/bin/bash
+# 安装系统依赖
+apt-get update && apt-get install -y gcc g++ libpq-dev
+# 或 Alpine 系统使用:apk add --no-cache gcc musl-dev postgresql-dev
+
+echo "Custom build script completed"| 场景 | 配置方式 | 示例 |
|---|---|---|
| 使用轻量级镜像 | 指定 Alpine 基础镜像 | base_image: "python:3.12-alpine" |
| 安装系统依赖 | 编写构建脚本 | build_script: "scripts/install_deps.sh" |
| 编译 C 扩展 | 安装编译工具 | 在脚本中安装 gcc、g++ 等 |
| 配置证书 | 更新 CA 证书 | 在脚本中运行 update-ca-certificates |
| 多阶段构建 | 分别指定 builder 和 runtime | 仅 Golang 项目支持 |
.agentkit/dockerfile_backups/)--regenerate-dockerfile 强制重新生成元数据头示例:
# ============================================================================
+# AUTO-GENERATED by AgentKit v1.x.x
+# ============================================================================
+# Source: agentkit.yaml
+# Checksum: sha256:...
+# Generated: 2025-01-17T10:30:00
+#
+# This file is automatically generated and managed by AgentKit:
+# - It will be auto-updated when agentkit.yaml config changes
+# - To fully customize, remove this header comment
+# ============================================================================根据配置的 launch_type 自动选择构建方式:
在你的电脑上用 Docker 构建:
🔨 开始构建本地镜像...
+[1/3] 生成 Dockerfile...
+[2/3] Docker 构建镜像...
+[3/3] 验证镜像可用性...
+✅ 构建成功: my-agent:latest预计耗时:1-3 分钟
在火山引擎上自动构建:
🔨 开始云端构建...
+[1/6] 生成 Dockerfile...
+[2/6] 打包项目代码...
+[3/6] 上传到对象存储...
+[4/6] 准备镜像仓库...
+[5/6] 创建构建流水线...
+[6/6] 执行构建任务...
+✅ 构建成功: xxx.cr.volces.com/agentkit/my-agent:latest预计耗时:3-5 分钟
{agent_name}:{image_tag}# 示例 1:使用默认配置
+agentkit build
+
+# 示例 2:指定配置文件
+agentkit build --config-file ./prod.yaml
+
+# 示例 3:强制重新生成 Dockerfile
+agentkit build --regenerate-dockerfile
+
+# 示例 4:配置更新后强制刷新
+agentkit build --config-file ./prod.yaml --regenerate-dockerfile示例 5:使用 Alpine 基础镜像
agentkit.yaml:docker_build:
+ base_image: "python:3.12-alpine"
+ build_script: "scripts/alpine-setup.sh"scripts/alpine-setup.sh:#!/bin/sh
+apk add --no-cache gcc musl-dev postgresql-devagentkit build示例 6:安装系统依赖(C 扩展)
agentkit.yaml:docker_build:
+ build_script: "scripts/install-deps.sh"scripts/install-deps.sh:#!/bin/bash
+apt-get update && apt-get install -y \\
+ gcc g++ \\
+ libpq-dev \\
+ libxml2-dev \\
+ libxslt1-devagentkit build示例 7:Golang 多阶段构建
修改 agentkit.yaml:
docker_build:
+ base_image:
+ builder: "golang:1.24-alpine"
+ runtime: "alpine:3.19"
+ build_script: "scripts/install-certs.sh"构建:
agentkit buildLocal 模式前提:
Cloud 模式前提:
Docker 构建自定义:
.agentkit/dockerfile_backups/提示:构建信息会自动更新到配置文件,供 deploy 命令使用
将构建好的镜像启动运行,让 Agent 对外提供服务。
agentkit deploy [选项]--config-file 配置文件路径
agentkit.yaml根据配置的 launch_type 自动选择部署目标:
在你的电脑上启动容器:
🚀 开始部署到本地 Docker...
+[1/3] 停止旧版本容器...
+[2/3] 启动新容器...
+[3/3] 验证容器状态...
+✅ 部署成功!容器正在运行
+🌐 访问地址: http://localhost:8000预计耗时:10-30 秒
在火山引擎上创建 Runtime:
🚀 开始部署到云端平台...
+✅ 生成 Runtime 名称: my-agent-20250120-abc123
+✅ 创建 Runtime: r-xxxxxx
+⏳ 等待 Runtime 就绪...
+✅ Runtime 已就绪!
+🌐 访问地址: http://xxx.apigateway-cn-beijing.volceapi.com预计耗时:1-2 分钟
# 示例 1:部署到默认环境
+agentkit deploy
+
+# 示例 2:部署到生产环境
+agentkit deploy --config-file ./prod.yamlLocal 模式:
localhost:端口 访问Cloud 模式:
构建 + 部署,一步完成!相当于自动执行 build 再执行 deploy。
agentkit launch [选项]--config-file 配置文件路径
agentkit.yaml🚀 开始启动 Agent...
+
+━━━ 第一步:构建镜像 ━━━
+🔨 读取配置: agentkit.yaml
+🔨 开始构建...
+✅ 构建完成
+
+━━━ 第二步:部署应用 ━━━
+🚀 开始部署...
+✅ 部署完成
+
+✨ Agent 已成功启动!# 示例 1:一键启动
+agentkit launch
+
+# 示例 2:启动到生产环境
+agentkit launch --config-file ./prod.yaml向已部署的 Agent 发送测试请求,验证功能是否正常。
agentkit invoke [消息内容] [选项]⚠️ 重要:必须提供消息内容或 --payload 选项之一,两者不能同时使用
消息内容
{"prompt": "你的消息"}--payload 同时使用agentkit invoke "你好" 或 agentkit invoke "今天天气怎么样?"选项
--payload, -p 自定义请求数据
--payload '{"prompt": "你好", "context": "greeting"}'--headers, -h 自定义请求头
user_id 和 session_id--headers '{"user_id": "test123"}'--raw 输出原始响应(调试用)
agentkit invoke "你好" --raw--show-reasoning 输出推理内容(LangChain 调试用)
additional_kwargs.reasoning_content 时,增量打印该字段agentkit invoke "1+1=?" --show-reasoning--apikey, -ak API 密钥
--config-file 配置文件路径
agentkit.yamlagentkit invoke "今天杭州天气如何?"等同于发送以下 JSON:
{
+ "prompt": "今天杭州天气如何?"
+}agentkit invoke --payload '{"prompt": "杭州天气?", "user_location": "杭州"}'agentkit invoke \\
+ --payload '{"prompt": "杭州天气?"}' \\
+ --headers '{"user_id": "user123", "session_id": "sess456"}'agentkit invoke "你好" --apikey your_api_key_here💬 正在调用 Agent...
+✅ Runtime ID: r-xxxxxx
+🌐 调用地址: http://xxx.apigateway-cn-beijing.volceapi.com
+✅ 调用成功!
+
+📡 Agent 响应:
+杭州今天天气晴,温度 22°C,适合出行。--payload 只能选一个agentkit status 检查)查看 Agent 的运行状态,包括是否在线、访问地址等信息。
agentkit status [选项]--config-file 配置文件路径
agentkit.yaml✅ 容器名称: my-agent
+✅ 运行状态: running
+🌐 访问地址: http://localhost:8000
+
+详细信息:
+{
+ "container_id": "abc123...",
+ "status": "running",
+ "ports": ["8000:8000"],
+ "created": "2025-01-20 10:00:00",
+ "health": "healthy"
+}✅ Runtime ID: r-xxxxxx
+✅ 运行状态: Ready
+🌐 访问地址: http://xxx.apigateway-cn-beijing.volceapi.com
+
+详细信息:
+{
+ "runtime_id": "r-xxxxxx",
+ "runtime_name": "my-agent-20250120-abc123",
+ "status": "Ready",
+ "endpoint": "http://xxx.apigateway-cn-beijing.volceapi.com",
+ "image": "xxx.cr.volces.com/agentkit/my-agent:latest",
+ "created_at": "2025-01-20 10:00:00"
+}Local 模式状态:
running - 正常运行中stopped - 已停止restarting - 重启中error - 出现错误Cloud 模式状态:
Ready - 就绪,可接收请求Releasing - 正在部署Error - 运行错误Failed - 部署失败# 示例 1:查看当前状态
+agentkit status
+
+# 示例 2:查看生产环境状态
+agentkit status --config-file ./prod.yaml停止并删除 Agent 实例,释放资源。⚠️ 这是不可逆操作!
agentkit destroy [选项]--force 强制删除
--config-file 配置文件路径
agentkit.yaml默认会要求你确认操作:
🗑️ 准备销毁运行中的 Agent...
+⚠️ 此操作不可恢复!
+确定要继续吗?[y/N]: y跳过确认(不推荐):
agentkit destroy --force🗑️ 开始销毁 Agent 资源...
+✅ 停止 Runtime: r-xxxxxx
+✅ 删除 Runtime 成功
+✅ 资源已清理完成
+
+提示:配置文件和镜像已保留,可随时重新部署。# 示例 1:安全删除(推荐)
+agentkit destroy
+
+# 示例 2:强制删除
+agentkit destroy --force
+
+# 示例 3:删除指定环境
+agentkit destroy --config-file ./dev.yamlagentkit.yaml 文件不会被删除agentkit deploy 重新部署所有命令都支持这些选项:
查看任何命令的详细说明和参数:
# 查看某个命令的帮助
+agentkit invoke --help
+agentkit build --help
+
+# 查看所有命令列表
+agentkit --help显示 CLI 版本信息:
agentkit --version
+# 或
+agentkit -vAgentKit CLI 提供了丰富的平台服务管理命令,用于管理 Memory、Knowledge、Tools 和 Runtime 等资源。
agentkit memory 管理 AgentKit Memory 记忆集合,支持创建、查看、更新和删除记忆集合。
# 创建记忆集合 (默认 provider-type: MEM0)
+agentkit memory create --name my-memory --description "我的记忆集合"
+
+# 添加外部记忆集合
+agentkit memory add --provider-collection-id <id> --provider-type VIKINGDB_MEMORY --name my-external-memory
+
+# 列出所有记忆集合 (支持分页和过滤)
+agentkit memory list
+agentkit memory list --name-contains "my" --limit 10
+
+# 查看记忆集合详情
+agentkit memory show -m <id>
+
+# 更新记忆集合
+agentkit memory update -m <id> --description "更新后的描述"
+
+# 删除记忆集合
+agentkit memory delete -m <id>
+
+# 获取连接信息
+agentkit memory conn -m <id>
+
+# 查看支持的 Provider 类型
+agentkit memory provider-typesagentkit knowledge 管理 AgentKit Knowledge 知识库,支持知识库的增删改查操作。
# 添加知识库 (连接外部知识库)
+agentkit knowledge add --name my-kb --provider-knowledge-id <id> --provider-type VIKINGDB_KNOWLEDGE
+
+# 列出所有知识库 (支持分页和过滤)
+agentkit knowledge list
+agentkit knowledge list --status Ready
+
+# 查看知识库详情
+agentkit knowledge show -k <id>
+
+# 更新知识库
+agentkit knowledge update -k <id> --description "更新后的描述"
+
+# 删除知识库
+agentkit knowledge delete -k <id>
+
+# 获取连接信息
+agentkit knowledge conn -k <id>
+
+# 查看支持的 Provider 类型
+agentkit knowledge provider-typesagentkit tools 管理 AgentKit Tools 工具和 Sessions 会话,包括工具的生命周期管理和会话操作。
# 工具管理
+# 创建工具 (需要指定 tool-type)
+agentkit tools create --name my-tool --tool-type <type> --description "我的工具"
+# 列出工具 (支持分页和过滤)
+agentkit tools list
+# 查看工具详情
+agentkit tools show -t <id>
+# 更新工具
+agentkit tools update -t <id> --description "新描述"
+# 删除工具
+agentkit tools delete -t <id>
+
+# 会话管理
+# 创建会话
+agentkit tools session create -t <id> --name my-session --ttl 30 --ttl-unit minute
+# 列出会话
+agentkit tools session list -t <id>
+# 查看会话详情
+agentkit tools session show -t <id> -s <session_id>
+# 获取会话日志
+agentkit tools session logs -t <id> -s <session_id>
+# 设置会话 TTL
+agentkit tools session set-ttl -t <id> -s <session_id> --ttl 60 --ttl-unit minute
+# 删除会话
+agentkit tools session delete -t <id> -s <session_id>agentkit runtime 管理 AgentKit Runtime 运行时实例,支持运行时的创建、更新、删除和版本管理。
# 创建运行时 (需要指定 artifact 信息)
+agentkit runtime create \\
+ --name my-runtime \\
+ --role-name <role> \\
+ --artifact-type DockerImage \\
+ --artifact-url <url> \\
+ --description "我的运行时"
+
+# 创建运行时并关联资源
+agentkit runtime create \\
+ --name my-runtime \\
+ --role-name <role> \\
+ --artifact-type DockerImage \\
+ --artifact-url <url> \\
+ --memory-id mem-xxx \\
+ --knowledge-id kb-xxx \\
+ --tool-id tool-xxx \\
+ --mcp-toolset-id mcp-ts-xxx
+
+# 创建运行时并开启私网访问(VPC)
+agentkit runtime create \\
+ --name my-runtime \\
+ --role-name <role> \\
+ --artifact-type DockerImage \\
+ --artifact-url <url> \\
+ --vpc-id vpc-xxxxxxxx \\
+ --subnet-ids subnet-aaaaaaaa \\
+ --enable-private-network \\
+ --enable-public-network false
+
+# 列出所有运行时 (支持分页和过滤)
+agentkit runtime list
+
+# 查看运行时详情
+agentkit runtime get -r <id>
+
+# 更新运行时
+agentkit runtime update -r <id> --description "新描述"
+
+> 💡 提示:\`agentkit runtime update\` 目前仅支持更新 artifact/description/env/tags 以及资源绑定字段(\`memory-id/knowledge-id/tool-id/mcp-toolset-id\`),不支持修改网络配置。
+
+# 删除运行时
+agentkit runtime delete -r <id>
+
+# 发布新版本
+agentkit runtime release -r <id> --version-number <version>
+
+# 查看特定版本详情
+agentkit runtime version -r <id> --version-number <version>
+
+# 列出所有版本
+agentkit runtime versions -r <id>从零开始到上线的完整步骤:
# 1️⃣ 创建项目
+agentkit init weather_agent --template basic
+cd weather_agent
+
+# 2️⃣ 配置应用
+agentkit config
+
+# 3️⃣ 一键部署
+agentkit launch
+
+# 4️⃣ 测试功能
+agentkit invoke "杭州天气怎么样?"
+
+# 5️⃣ 查看状态
+agentkit status将现有的 Agent 快速部署上线:
# 1️⃣ 包装现有 Agent 文件
+agentkit init --from-agent ~/my_projects/weather_agent.py
+
+# 2️⃣ 进入项目目录
+cd agentkit-weather_agent
+
+# 3️⃣ (可选)配置应用
+agentkit config
+
+# 4️⃣ 一键部署
+agentkit launch
+
+# 5️⃣ 测试功能
+agentkit invoke "今天天气如何?"
+
+# 6️⃣ 查看状态
+agentkit status修改代码后的更新流程:
# 方式 1:分步执行(推荐调试时使用)
+agentkit build # 重新构建
+agentkit deploy # 重新部署
+agentkit invoke "测试" # 测试验证
+
+# 方式 2:一键更新(推荐日常开发)
+agentkit launch # 自动构建+部署
+agentkit invoke "测试" # 测试验证在开发、测试、生产环境间切换:
# 开发环境
+agentkit launch --config-file agentkit.dev.yaml
+agentkit invoke "测试" --config-file agentkit.dev.yaml
+
+# 生产环境
+agentkit launch --config-file agentkit.prod.yaml
+agentkit invoke "测试" --config-file agentkit.prod.yaml遇到错误不要慌,这里有解决方案!
Error: Configuration file not found: agentkit.yaml原因:当前目录没有配置文件
解决:
# 如果是新项目
+agentkit init my_agent
+
+# 如果已有项目
+agentkit configError: Docker daemon not running原因:Docker 服务未启动
解决:
sudo systemctl start dockerError: VOLC_ACCESSKEY or VOLC_SECRETKEY not set原因:没有设置火山引擎 AK/SK
解决:
# 推荐:使用安全的全局配置
+agentkit config --global --init
+agentkit config --global --set volcengine.access_key="你的AccessKey"
+agentkit config --global --set volcengine.secret_key="你的SecretKey"
+
+# 或者:临时环境变量(开发调试用)
+export VOLC_ACCESSKEY="你的AccessKey"
+export VOLC_SECRETKEY="你的SecretKey"❌ 构建失败: ...可能原因和解决方案:
requirements.txt 是否正确1. 查看详细日志
# 设置详细日志级别
+export LOG_LEVEL=DEBUG
+agentkit build2. 验证配置文件
# 检查配置是否正确
+cat agentkit.yaml3. 分步执行
# 分开执行,更容易定位问题
+agentkit build # 先构建
+agentkit deploy # 再部署
+# 而不是直接用 launch4. 检查运行状态
# 查看 Agent 是否正常运行
+agentkit statusagentkit.yaml 是配置 Agent 的核心文件,包含了所有运行参数。本文档帮你理解每个配置项的作用。
AgentKit 采用两级配置架构:
| 配置文件 | 位置 | 作用 |
|---|---|---|
| 项目配置 | ./agentkit.yaml | 项目级配置,每个 Agent 项目独立 |
| 全局配置 | ~/.agentkit/config.yaml | 用户级配置,跨项目共享(如火山引擎凭证) |
配置优先级:
环境变量 > 项目配置 > 全局配置 > 默认值项目配置文件由三部分组成:
common:
+ # 基础配置(所有模式通用)
+ agent_name: my_agent
+ entry_point: my_agent.py
+ language: Python
+ launch_type: cloud
+ runtime_envs: {} # 应用级环境变量
+
+launch_types:
+ local:
+ # Local 模式的专属配置
+ hybrid:
+ # Hybrid 模式的专属配置
+ cloud:
+ # Cloud 模式的专属配置
+
+docker_build:
+ # Docker 构建配置(可选)
+ base_image: python:3.12-slim
+ build_script: scripts/setup.sh三个部分:
所有部署模式都需要的基础配置。
common:
+ agent_name: my_weather_agent # Agent 名称(必填)
+ entry_point: my_weather_agent.py # 入口文件(必填)
+ description: 天气查询 Agent # 描述(可选)
+ language: Python # 编程语言
+ language_version: '3.12' # 语言版本
+ dependencies_file: requirements.txt # 依赖文件
+ launch_type: cloud # 部署模式
+ runtime_envs: # 应用级环境变量(所有模式共享)
+ LOG_LEVEL: infoAgent 的名字
_ 和 -示例:
agent_name: weather_agent # 推荐:简单清晰
+agent_name: financial-analyzer-v2 # 可以:带版本号
+agent_name: customer_support_bot # 可以:描述性强Agent 代码的入口文件
.py、.go 或 .sh 结尾示例:
# Python 项目
+entry_point: app.py
+entry_point: server.py
+
+# Go 项目
+entry_point: main.go
+entry_point: cmd/server/main.go
+
+# 自定义启动脚本
+entry_point: start.shAgent 的描述信息
示例:
description: "天气查询 Agent,支持全国主要城市"
+description: "客服助手,处理常见问题"编程语言
Python、GolangPython示例:
language: Python # Python 项目
+language: Golang # Go 项目语言运行版本
3.10、3.11、3.12、3.131.243.12,Golang 1.24示例:
# Python 项目
+language: Python
+language_version: '3.12'
+
+# Go 项目
+language: Golang
+language_version: '1.24'⚠️ 注意:
python_version已废弃,请使用language_version
依赖包列表文件
requirements.txt,Go 项目为 go.mod示例:
# Python 项目
+dependencies_file: requirements.txt
+dependencies_file: requirements/prod.txt
+
+# Go 项目
+dependencies_file: go.mod部署和运行模式
local、hybrid、cloud| 模式 | 适合场景 | 构建位置 | 运行位置 |
|---|---|---|---|
local | 本地开发调试 | 本地电脑 | 本地电脑 |
hybrid | 过渡阶段 | 本地电脑 | 云端平台 |
cloud | 生产环境 | 云端平台 | 云端平台 |
示例:
launch_type: local # 本地开发
+launch_type: hybrid # 本地构建 + 云端部署
+launch_type: cloud # 生产环境(推荐)云厂商(平台服务提供方)
volcengine、byteplusvolcenginedocker_build.base_image 时)优先级(从高到低):
环境变量 > 项目配置(agentkit.yaml) > 全局配置(~/.agentkit/config.yaml) > 默认值配置方式:
# 1) 项目配置(推荐:写进 agentkit.yaml)
+common:
+ cloud_provider: byteplus# 1.1) 项目配置(非交互命令写入 agentkit.yaml)
+agentkit config --cloud_provider byteplus# 2) 全局配置(跨项目生效)
+defaults:
+ cloud_provider: byteplus# 3) 环境变量(临时覆盖)
+export CLOUD_PROVIDER=byteplus应用级环境变量
runtime_envs 会覆盖应用级同名变量示例:
common:
+ runtime_envs:
+ LOG_LEVEL: info
+ APP_ENV: production在本地 Docker 上构建和运行,适合开发调试。
launch_types:
+ local:
+ image_tag: latest # 镜像标签
+ invoke_port: 8000 # 应用端口
+ container_name: my_agent # 容器名称(可选)
+ runtime_envs: # 策略级环境变量
+ MODEL_AGENT_API_KEY: xxx
+ ports: # 端口映射
+ - "8000:8000"
+ restart_policy: unless-stopped # 重启策略
+ memory_limit: 1g # 内存限制
+ cpu_limit: '1' # CPU 限制镜像版本标签
latestlatest、v1.0、devAgent 监听的端口
8000Docker 容器名称
agent_name策略级运行时环境变量
传递给容器的环境变量,如 API Key、配置参数等。会与 common.runtime_envs 合并,同名变量会覆盖。
runtime_envs:
+ MODEL_AGENT_API_KEY: your_api_key # 模型 API Key
+ DEBUG: 'true' # 开启调试
+ LOG_LEVEL: debug # 覆盖 common 中的日志级别端口映射
将容器内部端口映射到主机端口,格式:主机端口:容器端口
ports:
+ - "8080:8000" # 主机 8080 映射到容器 8000
+ - "9090:9090" # 监控端口卷挂载
将主机目录挂载到容器内,格式:主机路径:容器路径
volumes:
+ - "./data:/app/data" # 数据目录
+ - "./logs:/app/logs" # 日志目录容器重启策略
unless-stoppedno - 不重启on-failure - 失败时重启always - 总是重启unless-stopped - 除非手动停止,否则重启资源限制
限制容器使用的资源,防止占用过多。
memory_limit: 2g # 限制 2GB 内存
+cpu_limit: '1' # 限制 1 个 CPU 核以下字段由 CLI 自动生成和管理,不需要手动配置:
| 字段 | 说明 |
|---|---|
container_id | 部署后的容器 ID |
image_id | 构建后的镜像 ID |
build_timestamp | 构建时间 |
deploy_timestamp | 部署时间 |
full_image_name | 完整镜像名(如 my-agent:latest) |
在火山引擎上构建和运行,适合生产环境。
launch_types:
+ cloud:
+ region: cn-beijing # 区域
+ image_tag: "{{timestamp}}" # 镜像标签(支持模板变量)
+
+ # TOS 对象存储配置
+ tos_bucket: Auto # 自动创建存储桶
+
+ # Container Registry 配置
+ cr_instance_name: Auto # CR 实例名(Auto = 自动创建)
+ cr_namespace_name: agentkit # CR 命名空间
+ cr_repo_name: "" # CR 仓库名(空 = 使用 agent_name)
+
+ # Runtime 配置
+ runtime_name: Auto # Runtime 名称
+ runtime_role_name: Auto # 授权角色名
+ runtime_apikey_name: Auto # API Key 密钥名
+
+ # 环境变量
+ runtime_envs:
+ MODEL_AGENT_API_KEY: xxx # 模型 API Key
+ MODEL_AGENT_NAME: ep-xxx # 模型接入点Cloud 模式支持模板变量,在构建/部署时自动渲染:
`,114)),s("table",d,[i[4]||(i[4]=s("thead",null,[s("tr",null,[s("th",null,"变量"),s("th",null,"说明"),s("th",null,"示例值")])],-1)),s("tbody",null,[s("tr",null,[s("td",null,[s("code",null,n(a.timestamp),1)]),i[0]||(i[0]=s("td",null,"当前时间戳(YYYYMMDDHHmmss)",-1)),i[1]||(i[1]=s("td",null,[s("code",null,"20251128153042")],-1))]),s("tr",null,[s("td",null,[s("code",null,n(a.account_id),1)]),i[2]||(i[2]=s("td",null,"火山引擎账号 ID",-1)),i[3]||(i[3]=s("td",null,[s("code",null,"2100123456")],-1))])])]),i[38]||(i[38]=l(`使用示例:
image_tag: "{{timestamp}}" # 每次构建唯一 tag
+cr_instance_name: "agentkit-platform-{{account_id}}" # 账号隔离的 CR 实例
+tos_bucket: "agentkit-platform-{{account_id}}" # 账号隔离的存储桶当配置值为 Auto 时,CLI 会自动创建或管理对应资源:
火山引擎区域
cn-beijingcn-beijing(目前仅支持北京区域)💡 建议:选择离用户最近的区域,降低延迟
镜像版本标签
',7)),s("ul",null,[s("li",null,[i[13]||(i[13]=t("默认:",-1)),s("code",null,n(a.timestamp),1),i[14]||(i[14]=t("(每次构建生成唯一标签)",-1))]),i[20]||(i[20]=s("li",null,"作用:区分不同版本",-1)),s("li",null,[i[15]||(i[15]=t("示例:",-1)),s("code",null,n(a.timestamp),1),i[16]||(i[16]=t("、",-1)),i[17]||(i[17]=s("code",null,"latest",-1)),i[18]||(i[18]=t("、",-1)),i[19]||(i[19]=s("code",null,"v1.0.0",-1))])]),i[40]||(i[40]=l(`# 方式 1:使用时间戳(推荐,确保每次构建唯一)
+image_tag: "{{timestamp}}"
+
+# 方式 2:固定版本
+image_tag: v1.0.0
+
+# 方式 3:使用 latest(不推荐用于生产)
+image_tag: latest对象存储桶
Auto(自动创建)tos_bucket 必须为当前账号名下的桶;如果填写了他人(例如公共读写)桶名,工具会阻止上传并提示更换# 自动创建(推荐)
+tos_bucket: Auto
+
+# 使用已有存储桶
+tos_bucket: my-existing-bucketContainer Registry 实例名
Auto(自动创建)# 自动创建
+cr_instance_name: Auto
+
+# 使用已有实例
+cr_instance_name: my-existing-crCR 命名空间
agentkitCR 仓库名称
agent_name)Runtime 相关配置
Auto(自动创建)runtime_name: Auto # Runtime 名称
+runtime_role_name: Auto # IAM 授权角色
+runtime_apikey_name: Auto # API Key 密钥名策略级运行时环境变量
Agent 运行时需要的配置,最重要的是模型 API 凭证。会与 common.runtime_envs 合并。
必须配置:
runtime_envs:
+ MODEL_AGENT_API_KEY: xxx # 火山方舟 API Key
+ MODEL_AGENT_NAME: ep-xxx # 火山方舟接入点 ID可选配置(增强功能):
runtime_envs:
+ # 基础配置
+ MODEL_AGENT_API_KEY: xxx
+ MODEL_AGENT_NAME: ep-xxx
+
+ # 可观测性(日志、监控、链路追踪)
+ OBSERVABILITY_OPENTELEMETRY_APMPLUS_API_KEY: xxx
+ OBSERVABILITY_OPENTELEMETRY_APMPLUS_ENDPOINT: http://apmplus-cn-beijing.volces.com:4317
+ OBSERVABILITY_OPENTELEMETRY_APMPLUS_SERVICE_NAME: my_agent
+
+ # 其他配置
+ DEBUG: 'true' # 开启调试模式
+ LOG_LEVEL: info # 设置日志级别构建超时时间
3600(秒)以下字段由 CLI 自动生成和管理,不需要手动配置:
TOS 存储相关
| 字段 | 说明 |
|---|---|
tos_prefix | 对象存储前缀(默认 agentkit-builds) |
tos_region | TOS 服务区域 |
tos_object_key | 代码包的存储路径 |
tos_object_url | 代码包的访问地址 |
Code Pipeline 构建相关
| 字段 | 说明 |
|---|---|
cp_workspace_name | 构建工作区名称 |
cp_pipeline_name | 构建流水线名称 |
cp_pipeline_id | 流水线 ID |
镜像相关
| 字段 | 说明 |
|---|---|
cr_region | 镜像仓库区域 |
cr_image_full_url | 完整的镜像 URL |
Runtime 运行时相关
| 字段 | 说明 |
|---|---|
runtime_id | Runtime 实例 ID |
runtime_endpoint | 应用访问地址 |
runtime_apikey | Runtime API 密钥 |
build_timestamp | 构建时间 |
deploy_timestamp | 部署时间 |
本地构建,云端运行。适合开发调试阶段,本地快速构建镜像后推送到云端运行。
launch_types:
+ hybrid:
+ region: cn-beijing # 云端区域
+ image_tag: "{{timestamp}}" # 镜像标签(支持模板变量)
+
+ # Container Registry 配置
+ cr_instance_name: Auto # CR 实例名
+ cr_namespace_name: agentkit # CR 命名空间
+ cr_repo_name: "" # CR 仓库名
+
+ # Runtime 配置
+ runtime_name: Auto # Runtime 名称
+ runtime_role_name: Auto # 授权角色名
+ runtime_apikey_name: Auto # API Key 密钥名
+
+ # 环境变量
+ runtime_envs:
+ MODEL_AGENT_API_KEY: xxx # 模型 API Key
+ MODEL_AGENT_NAME: ep-xxx # 模型接入点| 对比项 | Hybrid 模式 | Cloud 模式 |
|---|---|---|
| 构建位置 | 本地 Docker | 云端 Code Pipeline |
| TOS 配置 | 不需要 | 需要(存储代码包) |
| 构建速度 | 快(本地) | 较慢(上传+云端构建) |
| 适用场景 | 开发调试 | 生产环境 |
Hybrid 模式的配置项与 Cloud 模式基本一致,但不需要 TOS 相关配置(因为本地构建不需要上传代码包)。
火山引擎区域
cn-beijing镜像版本标签
`,53)),s("ul",null,[s("li",null,[i[21]||(i[21]=t("默认:",-1)),s("code",null,n(a.timestamp),1)]),i[22]||(i[22]=s("li",null,"作用:区分不同版本的镜像",-1)),i[23]||(i[23]=s("li",null,"支持模板变量",-1))]),i[41]||(i[41]=l(`Container Registry 配置
与 Cloud 模式相同,用于存储本地构建的镜像。
cr_instance_name: Auto # 自动创建 CR 实例
+cr_namespace_name: agentkit # 命名空间
+cr_repo_name: "" # 仓库名(空 = 使用 agent_name)Runtime 配置
与 Cloud 模式相同,管理云端运行时实例。
策略级运行时环境变量
与 Cloud 模式相同,传递给云端运行时的环境变量。
以下字段由 CLI 自动生成和管理,不需要手动配置:
| 字段 | 说明 |
|---|---|
image_id | 本地构建的镜像 ID |
build_timestamp | 构建时间 |
full_image_name | 完整镜像名 |
cr_image_full_url | CR 中的完整镜像 URL |
runtime_id | Runtime 实例 ID |
runtime_endpoint | 应用访问地址 |
runtime_apikey | Runtime API 密钥 |
自定义 Docker 构建过程,支持自定义基础镜像、构建脚本等。
docker_build:
+ # Python 项目 - 字符串格式
+ base_image: "python:3.12-slim"
+
+ # 自定义构建脚本
+ build_script: "scripts/setup.sh"
+
+ # 强制重新生成 Dockerfile
+ regenerate_dockerfile: false
+
+ # 目标平台(跨平台构建)
+ platform: "linux/amd64"Go 项目多阶段构建:
docker_build:
+ base_image:
+ builder: "golang:1.24-alpine" # 构建阶段镜像
+ runtime: "alpine:latest" # 运行时镜像
+ build_script: "scripts/install_certs.sh"自定义基础镜像
common.cloud_provider 自动切换 agentkit-prod-public-cn-beijing.cr.volces.com/base/py-simple:python<version>-bookworm-slim-latestagentkit-prod-public-ap-southeast-1.cr.bytepluses.com/base/py-simple:python<version>-bookworm-slim-latestagentkit-cn-beijing.cr.volces.com/base/compile_basego:1.24(构建)+ agentkit-cn-beijing.cr.volces.com/base/runtime_basego:latest(运行)# Python 项目 - 字符串
+base_image: "python:3.12-alpine"
+
+# Go 项目 - 字典(多阶段构建)
+base_image:
+ builder: "golang:1.24-alpine"
+ runtime: "alpine:latest"自定义构建脚本
使用场景:
build_script: "scripts/setup.sh"
+build_script: "docker/install_deps.sh"强制重新生成 Dockerfile
false--regenerate-dockerfile目标 CPU 架构
--platformplatform: "linux/amd64" # x86_64 架构
+platform: "linux/arm64" # ARM 架构(如 Apple Silicon)全局配置存储在 ~/.agentkit/config.yaml,跨项目共享。
~/.agentkit/config.yaml# 火山引擎凭证
+volcengine:
+ access_key: "AKLTxxxxxxxx"
+ secret_key: "xxxxxxxx"
+ region: "cn-beijing"
+
+# Container Registry 默认配置
+cr:
+ instance_name: "my-team-cr-instance"
+ namespace_name: "my-team"
+
+# TOS 默认配置
+tos:
+ bucket: "my-team-bucket"
+ prefix: "agentkit-builds"
+ region: "cn-beijing"当项目配置为空或 Auto 时,会自动使用全局配置:
1. 项目配置明确设置的值(最高优先级)
+2. 全局配置 (~/.agentkit/config.yaml)
+3. 默认值(最低优先级)团队共享配置:
团队成员可以共享相同的 CR 实例和 TOS 存储桶:
# ~/.agentkit/config.yaml
+cr:
+ instance_name: "team-shared-cr"
+ namespace_name: "team-agents"
+
+tos:
+ bucket: "team-shared-bucket"项目配置只需设置 Auto,即可自动使用团队配置:
# agentkit.yaml
+launch_types:
+ cloud:
+ cr_instance_name: Auto # 使用全局配置中的 team-shared-cr
+ tos_bucket: Auto # 使用全局配置中的 team-shared-bucket为不同环境创建独立配置文件:
agentkit.dev.yaml # 开发环境(local 模式)
+agentkit.test.yaml # 测试环境(hybrid 模式)
+agentkit.prod.yaml # 生产环境(cloud 模式)使用方式:
# 开发
+agentkit launch --config-file agentkit.dev.yaml
+
+# 生产
+agentkit launch --config-file agentkit.prod.yaml❌ 错误做法(硬编码):
runtime_envs:
+ MODEL_AGENT_API_KEY: c05d49af-1234-5678-abcd-xxxx # 不要这样!✅ 正确做法:
方案 1:交互式配置
agentkit config # 运行时输入敏感信息方案 2:使用 .gitignore
# .gitignore 文件
+agentkit.local.yaml # 本地配置不提交
+agentkit.prod.yaml # 生产配置不提交
+*.secret.yaml # 所有包含密钥的配置方案 3:创建配置模板
# agentkit.yaml.template (提交到 Git)
+runtime_envs:
+ MODEL_AGENT_API_KEY: <请填写你的 API Key>
+ MODEL_AGENT_NAME: <请填写接入点 ID>让团队成员更容易理解配置:
common:
+ agent_name: weather_agent
+ entry_point: app.py
+ launch_type: cloud # 生产环境使用云端部署
+
+launch_types:
+ cloud:
+ region: cn-beijing # 北京区域,离用户最近
+ runtime_envs:
+ # 火山方舟的模型访问凭证
+ MODEL_AGENT_API_KEY: xxx
+ MODEL_AGENT_NAME: ep-xxx确保配置文件始终有效:
# 方式 1:运行配置命令检查
+agentkit config
+
+# 方式 2:查看配置内容
+cat agentkit.yaml
+
+# 方式 3:尝试构建(不部署)
+agentkit build适合快速开发和调试:
common:
+ agent_name: dev_weather_agent
+ entry_point: app.py
+ description: 开发环境的天气查询 Agent
+ language: Python
+ language_version: '3.12'
+ launch_type: local
+ runtime_envs:
+ APP_ENV: development
+
+launch_types:
+ local:
+ image_tag: dev
+ invoke_port: 8000
+ runtime_envs:
+ MODEL_AGENT_API_KEY: xxx
+ DEBUG: 'true' # 开启调试
+ LOG_LEVEL: debug # 详细日志
+ ports:
+ - "8000:8000"
+ memory_limit: 512m # 开发环境资源限制小一些
+ cpu_limit: '0.5'Go 语言 Agent 的配置示例:
common:
+ agent_name: go_agent
+ entry_point: main.go
+ description: Go 语言 Agent
+ language: Golang
+ language_version: '1.24'
+ dependencies_file: go.mod
+ launch_type: hybrid
+
+launch_types:
+ hybrid:
+ region: cn-beijing
+ image_tag: "{{timestamp}}"
+ cr_instance_name: Auto
+ cr_namespace_name: agentkit
+ runtime_envs:
+ MODEL_AGENT_API_KEY: xxx
+
+docker_build:
+ base_image:
+ builder: "golang:1.24-alpine"
+ runtime: "alpine:latest"适合正式上线:
common:
+ agent_name: prod_weather_agent
+ entry_point: server.py
+ description: 生产环境的天气查询 Agent
+ language: Python
+ language_version: '3.12'
+ launch_type: cloud
+ runtime_envs:
+ APP_ENV: production
+ LOG_LEVEL: info
+
+launch_types:
+ cloud:
+ region: cn-beijing
+ image_tag: "{{timestamp}}" # 使用时间戳确保唯一
+
+ # CR 配置
+ cr_instance_name: Auto
+ cr_namespace_name: production
+ cr_repo_name: weather_agent
+
+ # TOS 配置
+ tos_bucket: Auto
+
+ # Runtime 配置
+ runtime_name: Auto
+ runtime_role_name: Auto
+ runtime_apikey_name: Auto
+
+ runtime_envs:
+ # 基础配置
+ MODEL_AGENT_API_KEY: xxx
+ MODEL_AGENT_NAME: ep-xxx
+
+ # 可观测性(生产环境推荐开启)
+ OBSERVABILITY_OPENTELEMETRY_APMPLUS_API_KEY: xxx
+ OBSERVABILITY_OPENTELEMETRY_APMPLUS_ENDPOINT: http://apmplus-cn-beijing.volces.com:4317
+ OBSERVABILITY_OPENTELEMETRY_APMPLUS_SERVICE_NAME: prod_weather_agent
+
+docker_build:
+ base_image: "python:3.12-slim"Local 模式(最简配置):
common:
+ agent_name: simple-agent
+ entry_point: agent.py
+ launch_type: localCloud 模式(最简配置):
common:
+ agent_name: cloud-agent
+ entry_point: main.py
+ launch_type: cloud
+
+launch_types:
+ cloud:
+ region: cn-beijing
+ runtime_envs:
+ MODEL_AGENT_API_KEY: xxxError: Configuration file not found解决:
agentkit init my_agent # 创建新项目
+# 或
+agentkit config # 创建配置Error: Invalid YAML format检查清单:
`,102)),s("ul",null,[i[25]||(i[25]=s("li",null,"✅ 使用空格缩进(不要用 Tab)",-1)),i[26]||(i[26]=s("li",null,"✅ 检查冒号后面有空格",-1)),i[27]||(i[27]=s("li",null,"✅ 字符串包含特殊字符要加引号",-1)),s("li",null,[i[24]||(i[24]=t("✅ 模板变量用引号包裹:",-1)),s("code",null,'"'+n(a.timestamp)+'"',1)])]),i[42]||(i[42]=l(`Error: agent_name is required解决:
agentkit config # 重新配置,填写必填项Error: Config field 'cr_instance_name' template variables were not fully rendered可能原因:
解决方法:
# 检查环境变量
+echo $VOLC_ACCESSKEY
+echo $VOLC_SECRETKEY
+
+# 或检查全局配置
+cat ~/.agentkit/config.yaml可能原因:
common.runtime_envs 和策略级 runtime_envs 混淆解决方法:
# 1. 检查配置
+cat agentkit.yaml
+
+# 2. 确认环境变量位置正确
+# common.runtime_envs - 所有模式共享
+# launch_types.<mode>.runtime_envs - 该模式专用
+
+# 3. 重新部署
+agentkit deploy如果你的配置文件使用旧版字段名(如 ve_cr_instance_name、python_version),请更新为新名称:
| 旧字段名 | 新字段名 |
|---|---|
python_version | language_version |
ve_cr_instance_name | cr_instance_name |
ve_cr_namespace_name | cr_namespace_name |
ve_cr_repo_name | cr_repo_name |
ve_runtime_id | runtime_id |
ve_runtime_name | runtime_name |
ve_runtime_endpoint | runtime_endpoint |
💡 提示:CLI 仍然支持旧字段名(通过 aliases),但建议迁移到新名称。
| 字段 | 必填 | 默认值 | 说明 |
|---|---|---|---|
agent_name | ✅ | - | Agent 名称 |
entry_point | ✅ | - | 入口文件 |
description | ❌ | 空 | 描述信息 |
language | ❌ | Python | 编程语言 |
language_version | ❌ | 3.12/1.24 | 语言版本 |
dependencies_file | ❌ | 自动检测 | 依赖文件 |
launch_type | ❌ | local | 部署模式 |
runtime_envs | ❌ | {} | 应用级环境变量 |
| 字段 | 默认值 | 说明 |
|---|---|---|
base_image | 自动选择 | 基础镜像 |
build_script | 无 | 构建脚本 |
regenerate_dockerfile | false | 强制重新生成 |
platform | 当前架构 | 目标平台 |
AgentKit CLI 内置了灵活的日志系统,帮助你了解命令执行过程、调试问题和追踪运行状态。
AgentKit 默认配置如下:
# 默认情况下,命令运行时无任何日志输出
+agentkit status
+
+# 如需日志,请通过环境变量开启(见下文)日志示例:
[2025-11-20 14:56:09] [INFO] [agentkit.toolkit.executors] Loading configuration...
+[2025-11-20 14:56:09] [INFO] [agentkit.toolkit.executors] Using launch_type: cloud
+[2025-11-20 14:56:09] [INFO] [agentkit.toolkit.executors] Querying status with cloud strategy...
+[2025-11-20 14:56:09] [INFO] [agentkit.toolkit.executors] Status query completed: running如果需要将日志保存到文件:
# 开启文件日志(默认 INFO 级别)
+export AGENTKIT_FILE_ENABLED=true
+
+# 运行命令
+agentkit deploy
+
+# 查看生成的日志文件
+cat .agentkit/logs/agentkit-$(date +%Y%m%d).log如果你想在控制台实时查看日志:
# 开启控制台日志
+export AGENTKIT_LOG_CONSOLE=true
+
+# 运行命令,现在可以在控制台看到日志了
+agentkit status# 同时开启控制台和文件日志
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_FILE_ENABLED=true
+
+# 运行命令
+agentkit build遇到问题需要详细日志时:
# 开启 DEBUG 级别日志(自动开启控制台和文件输出)
+export AGENTKIT_LOG_LEVEL=DEBUG
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_FILE_ENABLED=true
+
+# 运行命令,查看详细的调试信息
+agentkit build通过环境变量,你可以完全自定义日志行为。
| 环境变量 | 说明 | 默认值 | 示例 |
|---|---|---|---|
AGENTKIT_LOG_CONSOLE | 是否在控制台显示日志 | false | true / false |
AGENTKIT_FILE_ENABLED | 是否保存日志到文件 | false | true / false |
AGENTKIT_LOG_LEVEL | 日志级别(控制台和文件) | INFO | DEBUG / INFO / WARNING / ERROR |
AGENTKIT_LOG_FILE | 日志文件路径(开启文件日志时生效) | .agentkit/logs/agentkit-YYYYMMDD.log | /tmp/my-agent.log |
分别控制控制台和文件的日志级别:
| 环境变量 | 说明 | 默认值 |
|---|---|---|
AGENTKIT_CONSOLE_LOG_LEVEL | 控制台日志级别 | INFO |
AGENTKIT_FILE_LOG_LEVEL | 文件日志级别 | INFO |
使用示例:
# 控制台只看重要的错误,文件记录所有信息
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_CONSOLE_LOG_LEVEL=ERROR
+export AGENTKIT_FILE_LOG_LEVEL=DEBUG
+
+agentkit launchAgentKit 支持 5 种日志级别,级别越高,信息越少:
| 级别 | 说明 | 适用场景 |
|---|---|---|
DEBUG | 详细的调试信息 | 问题排查、开发调试 |
INFO | 常规操作信息(默认) | 了解命令执行过程 |
WARNING | 警告信息 | 关注潜在问题 |
ERROR | 错误信息 | 只看失败的操作 |
CRITICAL | 严重错误 | 只看致命错误 |
适合日常使用,无日志输出,保护信息安全。
# 无需任何配置,直接使用
+agentkit status
+agentkit deploy效果:
开启文件日志,便于追溯操作历史:
# 开启文件日志
+export AGENTKIT_FILE_ENABLED=true
+
+# 运行命令
+agentkit deploy效果:
.agentkit/logs/,默认 INFO 级别遇到错误或异常行为时,开启详细日志:
# 开启控制台和文件的 DEBUG 日志
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_FILE_ENABLED=true
+export AGENTKIT_LOG_LEVEL=DEBUG
+
+# 运行命令
+agentkit build效果:
在持续集成环境中,需要在控制台看到日志,同时保存完整记录:
# 在 CI 配置文件中设置
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_FILE_ENABLED=true
+export AGENTKIT_CONSOLE_LOG_LEVEL=INFO
+export AGENTKIT_FILE_LOG_LEVEL=DEBUG
+export AGENTKIT_LOG_FILE=/var/log/agentkit/build-\${BUILD_ID}.log
+
+# 运行构建
+agentkit launch效果:
生产环境只记录警告和错误到文件:
export AGENTKIT_FILE_ENABLED=true
+export AGENTKIT_FILE_LOG_LEVEL=WARNING
+export AGENTKIT_LOG_FILE=/var/log/agentkit/production.log
+
+# 运行命令
+agentkit deploy效果:
不需要任何日志时(默认行为):
# 默认配置即为完全静默,无需设置环境变量
+agentkit status
+
+# 或者显式设置(确保之前的环境变量不影响)
+unset AGENTKIT_LOG_CONSOLE
+unset AGENTKIT_FILE_ENABLED效果:
当开启文件日志后(AGENTKIT_FILE_ENABLED=true),日志保存在项目根目录的 .agentkit/logs/ 文件夹中:
your-project/
+├── .agentkit/
+│ └── logs/
+│ ├── agentkit-20251120.log # 今天的日志
+│ ├── agentkit-20251119.log # 昨天的日志
+│ └── agentkit-20251118.log # 前天的日志
+├── agentkit.yaml
+└── my_agent.py日志文件会随时间增多,建议定期清理:
# 删除 7 天前的日志
+find .agentkit/logs -name "agentkit-*.log" -mtime +7 -delete
+
+# 或者手动删除
+rm .agentkit/logs/agentkit-20251101.log# 保存到指定位置
+export AGENTKIT_LOG_FILE=/tmp/my-custom-agent.log
+
+# 或保存到用户目录
+export AGENTKIT_LOG_FILE=$HOME/.agentkit-logs/agent.log
+
+agentkit deploy当多种配置方式同时存在时,优先级如下(从高到低):
AGENTKIT_CONSOLE_LOG_LEVELAGENTKIT_LOG_LEVELINFO示例:
# 设置通用级别为 INFO
+export AGENTKIT_LOG_LEVEL=INFO
+
+# 设置控制台专用级别为 WARNING(优先级更高)
+export AGENTKIT_CONSOLE_LOG_LEVEL=WARNING
+
+# 结果:控制台显示 WARNING,文件记录 INFO
+agentkit status可能原因:
解决方法:
# 1. 检查是否禁用了文件日志
+echo $AGENTKIT_FILE_ENABLED # 应该是 true 或为空
+
+# 2. 检查目录权限
+ls -la .agentkit/logs/
+
+# 3. 手动创建目录
+mkdir -p .agentkit/logs
+
+# 4. 确保环境变量正确
+unset AGENTKIT_FILE_ENABLED # 重置为默认值可能原因:
解决方法:
# 1. 开启控制台日志
+export AGENTKIT_LOG_CONSOLE=true
+
+# 2. 设置合适的日志级别
+export AGENTKIT_CONSOLE_LOG_LEVEL=INFO
+
+# 3. 运行命令
+agentkit status调整日志级别:
# 日志太多 - 只看重要信息
+export AGENTKIT_LOG_LEVEL=WARNING
+
+# 日志太少 - 查看详细信息
+export AGENTKIT_LOG_LEVEL=DEBUG在你的 .bashrc 或 .zshrc 中添加(可选):
# AgentKit 开发环境配置(根据需要选择)
+# 选项1:只开启控制台日志
+export AGENTKIT_LOG_CONSOLE=true
+
+# 选项2:同时开启控制台和文件日志
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_FILE_ENABLED=true
+export AGENTKIT_CONSOLE_LOG_LEVEL=INFO
+export AGENTKIT_FILE_LOG_LEVEL=DEBUG推荐:
在项目根目录创建 .env.example 文件:
# AgentKit 日志配置示例
+# 根据需要复制到 .env 并修改
+
+# === 开发环境建议配置 ===
+# 开启控制台日志(便于实时查看)
+AGENTKIT_LOG_CONSOLE=true
+
+# 开启文件日志(便于问题追溯,可选)
+# AGENTKIT_FILE_ENABLED=true
+
+# 设置日志级别
+AGENTKIT_LOG_LEVEL=INFO
+
+# 自定义日志路径(可选)
+# AGENTKIT_LOG_FILE=./logs/my-agent.log提醒:
.env 文件应该在 .gitignore 中,避免提交个人配置# 生产环境配置
+export AGENTKIT_LOG_CONSOLE=false # 关闭控制台
+export AGENTKIT_FILE_ENABLED=true # 开启文件日志
+export AGENTKIT_FILE_LOG_LEVEL=WARNING # 只记录警告和错误
+export AGENTKIT_LOG_FILE=/var/log/agentkit/prod.log # 统一路径优点:
AgentKit 的日志系统设计原则:
快速参考:
# 1. 开启文件日志
+export AGENTKIT_FILE_ENABLED=true
+
+# 2. 开启控制台调试
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_FILE_ENABLED=true
+export AGENTKIT_LOG_LEVEL=DEBUG
+
+# 3. 查看日志文件(需要先开启文件日志)
+cat .agentkit/logs/agentkit-$(date +%Y%m%d).log
+
+# 4. 控制台和文件使用不同级别
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_FILE_ENABLED=true
+export AGENTKIT_CONSOLE_LOG_LEVEL=ERROR
+export AGENTKIT_FILE_LOG_LEVEL=DEBUG如有问题,请参考 故障排查 章节或联系技术支持。
`,130)])])}const o=i(l,[["render",h]]);export{g as __pageData,o as default}; diff --git a/assets/content_2.agentkit-cli_4.logging.md.BmTvgFmd.lean.js b/assets/content_2.agentkit-cli_4.logging.md.BmTvgFmd.lean.js new file mode 100644 index 0000000..34e2a6a --- /dev/null +++ b/assets/content_2.agentkit-cli_4.logging.md.BmTvgFmd.lean.js @@ -0,0 +1 @@ +import{_ as i,c as a,o as n,ag as t}from"./chunks/framework.CA4hJK0u.js";const g=JSON.parse('{"title":"日志系统","description":"","frontmatter":{},"headers":[],"relativePath":"content/2.agentkit-cli/4.logging.md","filePath":"content/2.agentkit-cli/4.logging.md","lastUpdated":1764227036000}'),l={name:"content/2.agentkit-cli/4.logging.md"};function h(p,s,e,k,d,r){return n(),a("div",null,[...s[0]||(s[0]=[t("",130)])])}const o=i(l,[["render",h]]);export{g as __pageData,o as default}; diff --git a/assets/content_3.agentkit-sdk_1.overview.md.D47HXcGC.js b/assets/content_3.agentkit-sdk_1.overview.md.D47HXcGC.js new file mode 100644 index 0000000..a145db4 --- /dev/null +++ b/assets/content_3.agentkit-sdk_1.overview.md.D47HXcGC.js @@ -0,0 +1,67 @@ +import{_ as i,c as a,o as n,ag as t}from"./chunks/framework.CA4hJK0u.js";const g=JSON.parse('{"title":"AgentKit SDK 概览","description":"","frontmatter":{},"headers":[],"relativePath":"content/3.agentkit-sdk/1.overview.md","filePath":"content/3.agentkit-sdk/1.overview.md","lastUpdated":1764210317000}'),l={name:"content/3.agentkit-sdk/1.overview.md"};function e(p,s,h,k,r,o){return n(),a("div",null,[...s[0]||(s[0]=[t(`AgentKit SDK 是一个 Python 开发工具包,用于快速构建符合 AgentKit Platform 标准的 Agent 应用。SDK 提供了一套简洁的装饰器和客户端接口,帮助开发者专注于 Agent 业务逻辑的实现。
AgentKit SDK 采用模块化设计,主要包含以下模块:
提供多种应用模式,将用户代码封装为符合 Platform 标准的 HTTP 服务:
最常用的应用框架,适用于标准的 Agent 应用。
核心装饰器:
@app.entrypoint - 定义 Agent 的主入口函数@app.ping - 定义健康检查函数@app.async_task - 定义异步任务(规划中)标准路由:
/invoke - Agent 调用端点/ping - 健康检查/health、/readiness、/liveness - Kubernetes 就绪探针基于 MCP (Model Context Protocol) 协议的应用框架,用于将工具封装为 MCP 服务。
核心装饰器:
@app.tool - 将函数注册为 MCP 工具@app.agent_as_a_tool - 将 Agent 封装为 MCP 工具基于 A2A (Agent-to-Agent) 协议的应用框架,用于构建可互相通信的 Agent。
核心装饰器:
@app.agent_executor - 注册 Agent 执行器@app.task_store - 注册任务存储(可选)提供便捷的客户端接口,用于访问 AgentKit Platform 的各项服务。
记忆服务客户端,管理 Agent 的长期和短期记忆。
主要功能:
create_memory_collection() - 创建记忆库list_memory_collections() - 列举记忆库get_memory_collection() - 获取记忆库详情update_memory_collection() - 更新记忆库配置delete_memory_collection() - 删除记忆库get_memory_connection_info() - 获取连接信息设计理念:控制面和数据面解耦
知识库服务客户端,管理 Agent 的向量化知识库。
主要功能:
list_knowledge_bases() - 列举知识库add_knowledge_base() - 添加知识库get_knowledge_connection_info() - 获取知识库连接信息delete_knowledge_base() - 删除知识库使用场景:
MCP Gateway 客户端,用于管理和路由大量 MCP 工具。
主要功能:
Runtime 管理客户端,用于管理 Agent 的运行时环境。
主要功能:
所有客户端的基类,提供统一的配置和 HTTP 请求能力。
配置项:
使用 contextvars 管理每个请求的上下文信息,包括:
AgentKit SDK
+│
+├── Runtime Apps (应用框架层)
+│ ├── AgentkitSimpleApp
+│ ├── AgentkitMCPApp
+│ ├── AgentkitA2aApp
+│ └── AgentkitAgentServerApp
+│
+├── Platform Clients (服务客户端层)
+│ ├── AgentkitMemory
+│ ├── AgentkitKnowledge
+│ ├── AgentkitMCP
+│ └── AgentkitRuntime
+│
+└── Infrastructure (基础设施层)
+ ├── BaseAgentkitClient
+ ├── Context
+ └── Telemetry (可观测性)使用 Python 装饰器简化应用开发,开发者只需关注业务逻辑:
from agentkit.apps import AgentkitSimpleApp
+
+app = AgentkitSimpleApp()
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ # 业务逻辑
+ return responseSDK 不限制使用特定的 Agent 框架,支持:
内置 OpenTelemetry 支持,自动收集:
提供完整的生产环境支持:
完整的 Python 类型注解,提供:
pip install agentkit-sdk-pythonfrom agentkit.apps import AgentkitSimpleApp
+from veadk import Agent, Runner
+from veadk.tools.demo_tools import get_city_weather
+
+app = AgentkitSimpleApp()
+agent = Agent(tools=[get_city_weather])
+runner = Runner(agent=agent)
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ prompt = payload["prompt"]
+ user_id = headers["user_id"]
+ session_id = headers["session_id"]
+
+ response = await runner.run(
+ messages=prompt,
+ user_id=user_id,
+ session_id=session_id
+ )
+ return response
+
+@app.ping
+def ping() -> str:
+ return "pong!"
+
+if __name__ == "__main__":
+ app.run(host="0.0.0.0", port=8000)from agentkit.sdk.memory import AgentkitMemory
+from agentkit.base_client import ApiConfig
+
+# 初始化客户端
+config = ApiConfig(
+ access_key="your_ak",
+ secret_key="your_sk"
+)
+memory_client = AgentkitMemory(config)
+
+# 创建记忆库
+response = memory_client.create_memory_collection(
+ name="my-memory",
+ short_term_configuration={...},
+ long_term_configuration={...}
+)
+print(f"Memory ID: {response.id}")samples/ 目录下的完整示例AgentKit SDK 提供了一套简洁的装饰器(注解),用于快速构建不同类型的 Agent 应用。本文档详细介绍各种注解的使用方法和最佳实践。
AgentkitSimpleApp 是最常用的应用框架,提供标准的 HTTP 服务端点。
定义 Agent 的主入口函数,处理来自 Platform 的调用请求。
@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ passpayload (dict): 请求体,包含用户输入和配置
prompt (str): 用户输入的提示词headers (dict): 请求头,包含上下文信息
user_id (str): 用户 IDsession_id (str): 会话 IDrequest_id (str): 请求追踪 ID返回值 (str): Agent 的响应结果
from agentkit.apps import AgentkitSimpleApp
+from veadk import Agent, Runner
+from veadk.tools.demo_tools import get_city_weather
+
+app = AgentkitSimpleApp()
+agent = Agent(tools=[get_city_weather])
+runner = Runner(agent=agent)
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ """Agent 主入口函数"""
+ # 1. 提取输入参数
+ prompt = payload.get("prompt", "")
+ user_id = headers.get("user_id", "anonymous")
+ session_id = headers.get("session_id", "default")
+
+ # 2. 调用 Agent 运行
+ response = await runner.run(
+ messages=prompt,
+ user_id=user_id,
+ session_id=session_id
+ )
+
+ # 3. 返回结果
+ return responseasync def 定义import logging
+
+logger = logging.getLogger(__name__)
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ try:
+ prompt = payload["prompt"]
+ response = await runner.run(messages=prompt)
+ return response
+ except KeyError as e:
+ logger.error(f"Missing required field: {e}")
+ return f"Error: Missing required field {e}"
+ except Exception as e:
+ logger.error(f"Agent execution failed: {e}")
+ return f"Error: {str(e)}"定义健康检查函数,用于 Platform 和 Kubernetes 的健康探测。
@app.ping
+def ping() -> str:
+ pass@app.ping
+def ping() -> str:
+ """健康检查"""
+ return "pong!"import redis
+from sqlalchemy import create_engine
+
+# 初始化依赖
+redis_client = redis.Redis(host='localhost', port=6379)
+db_engine = create_engine('postgresql://...')
+
+@app.ping
+def ping() -> str:
+ """健康检查,包含依赖服务检测"""
+ try:
+ # 检查 Redis 连接
+ redis_client.ping()
+
+ # 检查数据库连接
+ with db_engine.connect() as conn:
+ conn.execute("SELECT 1")
+
+ return "ok - all services healthy"
+ except Exception as e:
+ logger.error(f"Health check failed: {e}")
+ return f"degraded - {str(e)}"def ping() -> str:def 而非 async def健康检查函数会自动注册到以下端点:
GET /ping - 基础健康检查GET /health - 健康状态GET /readiness - Kubernetes 就绪探针GET /liveness - Kubernetes 存活探针用于定义异步任务,支持长时间运行的操作。
@app.async_task
+async def process_long_task(task_id: str, data: dict) -> dict:
+ """处理长时间运行的任务"""
+ # 长时间运行的逻辑
+ result = await heavy_computation(data)
+ return result注意:此功能正在规划中,暂未实现。
AgentkitMCPApp 用于构建 MCP (Model Context Protocol) 服务,将函数封装为标准的 MCP 工具。
将函数注册为 MCP 工具,供 LLM 调用。
@app.tool
+def tool_name(param1: str, param2: int) -> dict:
+ passfrom agentkit.apps import AgentkitMCPApp
+
+mcp_app = AgentkitMCPApp()
+
+@mcp_app.tool
+def get_city_weather(city: str) -> dict[str, str]:
+ """获取城市天气信息
+
+ Args:
+ city: 城市名称(必须为英文)
+
+ Returns:
+ 包含天气状况和温度的字典
+ """
+ weather_data = {
+ "beijing": {"condition": "Sunny", "temperature": 25},
+ "shanghai": {"condition": "Cloudy", "temperature": 22},
+ }
+
+ city = city.lower().strip()
+ if city in weather_data:
+ info = weather_data[city]
+ return {"result": f"{info['condition']}, {info['temperature']}°C"}
+ else:
+ return {"result": f"Weather information not found for {city}"}import aiohttp
+
+@mcp_app.tool
+async def fetch_web_content(url: str) -> dict:
+ """获取网页内容
+
+ Args:
+ url: 网页 URL
+
+ Returns:
+ 包含网页内容的字典
+ """
+ async with aiohttp.ClientSession() as session:
+ async with session.get(url) as response:
+ content = await response.text()
+ return {
+ "status": response.status,
+ "content": content[:1000] # 截取前 1000 字符
+ }def 和 async deffrom typing import List, Optional
+from pydantic import BaseModel
+
+class SearchQuery(BaseModel):
+ keywords: List[str]
+ max_results: int = 10
+ filters: Optional[dict] = None
+
+@mcp_app.tool
+def search_documents(query: SearchQuery) -> dict:
+ """搜索文档
+
+ Args:
+ query: 搜索查询对象,包含关键词、结果数量和过滤条件
+
+ Returns:
+ 搜索结果列表
+ """
+ # 实现搜索逻辑
+ results = perform_search(
+ keywords=query.keywords,
+ max_results=query.max_results,
+ filters=query.filters
+ )
+ return {"results": results, "count": len(results)}将整个 Agent 封装为 MCP 工具,实现 Agent 的组合和协作。
@app.agent_as_a_tool
+async def agent_tool(prompt: str) -> str:
+ passfrom veadk import Agent, Runner
+from veadk.tools.demo_tools import get_city_weather
+
+# 创建一个专门的天气 Agent
+weather_agent = Agent(tools=[get_city_weather])
+weather_runner = Runner(agent=weather_agent)
+
+mcp_app = AgentkitMCPApp()
+
+@mcp_app.agent_as_a_tool
+async def weather_assistant(prompt: str) -> str:
+ """天气助手 Agent
+
+ 专门处理天气相关查询的 Agent,可以查询全球城市的天气信息。
+
+ Args:
+ prompt: 用户的天气查询
+
+ Returns:
+ 天气查询结果
+ """
+ response = await weather_runner.run(messages=prompt)
+ return response# 创建多个专门的 Agent
+weather_agent = Agent(tools=[get_city_weather])
+news_agent = Agent(tools=[get_latest_news])
+calendar_agent = Agent(tools=[check_schedule])
+
+@mcp_app.agent_as_a_tool
+async def weather_assistant(query: str) -> str:
+ """天气助手"""
+ return await Runner(agent=weather_agent).run(messages=query)
+
+@mcp_app.agent_as_a_tool
+async def news_assistant(query: str) -> str:
+ """新闻助手"""
+ return await Runner(agent=news_agent).run(messages=query)
+
+@mcp_app.agent_as_a_tool
+async def calendar_assistant(query: str) -> str:
+ """日程助手"""
+ return await Runner(agent=calendar_agent).run(messages=query)AgentkitA2aApp 用于构建 A2A (Agent-to-Agent) 应用,支持 Agent 之间的通信和协作。
注册 Agent 执行器,定义 Agent 的执行逻辑。
@app.agent_executor(runner=runner, **kwargs)
+class MyAgentExecutor(A2aAgentExecutor):
+ passfrom agentkit.apps import AgentkitA2aApp
+from google.adk.a2a.executor.a2a_agent_executor import A2aAgentExecutor
+from veadk import Agent, Runner
+from veadk.a2a.agent_card import get_agent_card
+from veadk.tools.demo_tools import get_city_weather
+
+# 创建 A2A 应用
+a2a_app = AgentkitA2aApp()
+
+# 创建 Agent
+agent = Agent(tools=[get_city_weather])
+runner = Runner(agent=agent)
+
+# 注册执行器
+@a2a_app.agent_executor(runner=runner)
+class WeatherAgentExecutor(A2aAgentExecutor):
+ """天气查询 Agent 执行器"""
+ pass
+
+# 运行应用
+if __name__ == "__main__":
+ a2a_app.run(
+ agent_card=get_agent_card(agent=agent, url="http://127.0.0.1:8000"),
+ host="127.0.0.1",
+ port=8000,
+ )from a2a.server.agent_execution import AgentExecutor
+from a2a.server.agent_execution.context import RequestContext
+from a2a.server.events.event_queue import EventQueue
+
+@a2a_app.agent_executor(runner=runner)
+class CustomAgentExecutor(AgentExecutor):
+ """自定义 Agent 执行器"""
+
+ async def execute(
+ self,
+ context: RequestContext,
+ event_queue: EventQueue
+ ) -> str:
+ """执行 Agent 逻辑
+
+ Args:
+ context: 请求上下文,包含输入消息和历史
+ event_queue: 事件队列,用于发送中间结果
+
+ Returns:
+ Agent 的响应结果
+ """
+ # 从上下文提取输入
+ user_message = context.current_input
+
+ # 发送中间事件(可选)
+ await event_queue.put({
+ "type": "thinking",
+ "content": "正在思考..."
+ })
+
+ # 执行 Agent
+ response = await self.runner.run(messages=user_message)
+
+ return responseAgentExecutor 或其子类execute 方法注册任务存储,用于持久化 A2A 任务状态。
@app.task_store(**kwargs)
+class MyTaskStore(TaskStore):
+ pass# 不指定 task_store,会使用内存存储(InMemoryTaskStore)
+a2a_app = AgentkitA2aApp()
+
+@a2a_app.agent_executor(runner=runner)
+class MyExecutor(A2aAgentExecutor):
+ passfrom a2a.server.tasks.task_store import TaskStore
+from a2a.types import Task
+import redis
+
+@a2a_app.task_store(redis_url="redis://localhost:6379")
+class RedisTaskStore(TaskStore):
+ """基于 Redis 的任务存储"""
+
+ def __init__(self, redis_url: str):
+ self.redis_client = redis.from_url(redis_url)
+
+ async def save_task(self, task: Task) -> None:
+ """保存任务"""
+ task_data = task.model_dump_json()
+ self.redis_client.set(f"task:{task.id}", task_data)
+
+ async def get_task(self, task_id: str) -> Task | None:
+ """获取任务"""
+ task_data = self.redis_client.get(f"task:{task_id}")
+ if task_data:
+ return Task.model_validate_json(task_data)
+ return None
+
+ async def delete_task(self, task_id: str) -> None:
+ """删除任务"""
+ self.redis_client.delete(f"task:{task_id}")TaskStoresave_task、get_task、delete_task 等方法所有装饰的函数都应该有良好的错误处理:
import logging
+
+logger = logging.getLogger(__name__)
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ try:
+ # 业务逻辑
+ result = await process(payload)
+ return result
+ except ValueError as e:
+ logger.warning(f"Invalid input: {e}")
+ return f"Invalid input: {str(e)}"
+ except Exception as e:
+ logger.error(f"Unexpected error: {e}", exc_info=True)
+ return "An error occurred. Please try again later."添加适当的日志以便追踪问题:
@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ request_id = headers.get("request_id", "unknown")
+ logger.info(f"[{request_id}] Processing request: {payload}")
+
+ try:
+ response = await runner.run(messages=payload["prompt"])
+ logger.info(f"[{request_id}] Request completed successfully")
+ return response
+ except Exception as e:
+ logger.error(f"[{request_id}] Request failed: {e}")
+ raise使用完整的类型注解提高代码质量:
from typing import Dict, Any
+
+@app.entrypoint
+async def run(payload: Dict[str, Any], headers: Dict[str, str]) -> str:
+ prompt: str = payload["prompt"]
+ user_id: str = headers.get("user_id", "anonymous")
+ # ...为所有函数添加详细的文档字符串:
@mcp_app.tool
+def calculate_distance(lat1: float, lon1: float, lat2: float, lon2: float) -> dict:
+ """计算两个地理坐标之间的距离
+
+ 使用 Haversine 公式计算地球表面两点间的大圆距离。
+
+ Args:
+ lat1: 起点纬度(度)
+ lon1: 起点经度(度)
+ lat2: 终点纬度(度)
+ lon2: 终点经度(度)
+
+ Returns:
+ 包含距离信息的字典,距离单位为公里
+
+ Example:
+ >>> calculate_distance(39.9, 116.4, 31.2, 121.5)
+ {"distance_km": 1067.5}
+ """
+ # 实现逻辑避免在装饰的函数中执行耗时初始化:
# ❌ 不好的做法
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ agent = Agent(tools=[...]) # 每次请求都创建
+ runner = Runner(agent=agent)
+ return await runner.run(messages=payload["prompt"])
+
+# ✅ 好的做法
+agent = Agent(tools=[...]) # 只创建一次
+runner = Runner(agent=agent)
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ return await runner.run(messages=payload["prompt"])samples/ 目录下的完整示例代码AgentKit Runtime 是一个统一的、托管式的 Agent 运行环境,旨在为您提供一个安全、高效、可扩展的 Serverless 平台,让您能专注于 Agent 的业务逻辑,而非繁琐的底层运维。
AgentKit Runtime 通过提供一个 Serverless 的托管环境,系统性地解决了以上所有问题。
本指南将引导您完成从环境配置、本地开发调试,到最终将 Agent 部署到生产环境的全过程。
在开始之前,请确保您已准备好:
提示:请确保您的 AccessKey 拥有
AgentKitFullAccess权限。
我们推荐使用
uv或python3 -m venv来管理您的 Python 虚拟环境。以下示例将使用uv。
uv安装指南请参考:uv installation
1. 创建并激活虚拟环境
mkdir agentkit-runtime-quickstart
+cd agentkit-runtime-quickstart
+uv venv --python 3.12.0
+source .venv/bin/activate2. 安装核心依赖
您可以通过
--index参数指定镜像源以加快安装速度。
uv pip install veadk-python
+uv pip install agentkit-sdk-python我们强烈推荐您使用 agentkit-cli 来快速启动项目。init 命令可以从模板创建一个结构完整的、支持流式输出的 Agent 项目。
# 使用 agentkit-cli 从模板创建项目
+agentkit init这会自动生成一个包含 simple_agent.py 和 requirements.txt 的项目结构,让您能立即开始开发。
使用 basic_stream 模板生成的 simple_agent.py 核心代码如下。它展示了如何基于 AgentkitSimpleApp 包装一个 veADK 的 Agent,并通过 Runner 执行,最终以 SSE(Server-Sent Events)事件流返回结果。
# 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 json
+import logging
+
+from google.adk.agents import RunConfig
+from google.adk.agents.run_config import StreamingMode
+from google.genai.types import Content, Part
+from veadk import Agent, Runner
+
+from agentkit.apps import AgentkitSimpleApp
+from veadk.prompts.agent_default_prompt import DEFAULT_DESCRIPTION, DEFAULT_INSTRUCTION
+
+logger = logging.getLogger(__name__)
+logger.setLevel(logging.INFO)
+
+app = AgentkitSimpleApp()
+
+app_name = "simple_streamable_app"
+
+agent_name = "Agent"
+description = DEFAULT_DESCRIPTION
+system_prompt = DEFAULT_INSTRUCTION
+
+
+tools = []
+
+# from veadk.tools.builtin_tools.web_search import web_search
+# tools.append(web_search)
+
+
+agent = Agent(
+ name=agent_name,
+ description=description,
+ instruction=system_prompt,
+ tools=tools,
+)
+agent.model._additional_args["stream_options"] = {"include_usage": True}
+runner = Runner(agent=agent, app_name=app_name)
+
+
+@app.entrypoint
+async def run(payload: dict, headers: dict):
+ prompt = payload["prompt"]
+ user_id = headers["user_id"]
+ session_id = headers["session_id"]
+
+ logger.info(
+ f"Running agent with prompt: {prompt}, user_id: {user_id}, session_id: {session_id}"
+ )
+
+ session_service = runner.short_term_memory.session_service # type: ignore
+
+ # prevent session recreation
+ session = await session_service.get_session(
+ app_name=app_name, user_id=user_id, session_id=session_id
+ )
+ if not session:
+ await session_service.create_session(
+ app_name=app_name, user_id=user_id, session_id=session_id
+ )
+
+ new_message = Content(role="user", parts=[Part(text=prompt)])
+ try:
+ async for event in runner.run_async(
+ user_id=user_id,
+ session_id=session_id,
+ new_message=new_message,
+ run_config=RunConfig(streaming_mode=StreamingMode.SSE),
+ ):
+ # Format as SSE data
+ sse_event = event.model_dump_json(exclude_none=True, by_alias=True)
+ logger.debug("Generated event in agent run streaming: %s", sse_event)
+ yield sse_event
+ except Exception as e:
+ logger.exception("Error in event_generator: %s", e)
+ # You might want to yield an error event here
+ error_data = json.dumps({"error": str(e)})
+ yield error_data
+
+
+@app.ping
+def ping() -> str:
+ return "pong!"
+
+
+if __name__ == "__main__":
+ app.run(host="0.0.0.0", port=8000)代码亮点:
AgentkitSimpleApp 实现了与 AgentKit Runtime 的无缝集成。在启动 Agent 服务之前,您需要配置火山引擎的访问凭证:
# 必需:配置您的火山引擎访问凭证
+export VOLCENGINE_ACCESS_KEY=your_ak
+export VOLCENGINE_SECRET_KEY=your_sk重要提示:请务必将
your_ak和your_sk替换为您的真实凭证。
一切就绪后,运行以下命令启动 Agent 服务:
python simple_agent.py服务将监听 http://0.0.0.0:8000。现在,打开另一个终端,使用 curl 来测试您的 Agent:
curl --location 'http://localhost:8000/invoke' \\
+ --header 'Content-Type: application/json' \\
+ --header 'user_id: test' \\
+ --header 'session_id: local_session' \\
+ --data '{"prompt": "讲一个笑话!"}'参数说明:
user_id:用户标识符session_id:会话标识符prompt:用户的自然语言请求**执行日志示例: **
调用成功后,控制台会输出详细的执行日志:
INFO: Started server process [38120]
+INFO: Waiting for application startup.
+INFO: Application startup complete.
+INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
+INFO: 127.0.0.1:60807 - "POST /invoke HTTP/1.1" 200 OK
+INFO:__main__:Running agent with prompt: 讲一个笑话!, user_id: test, session_id: local_session
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: Why
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: did
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: the
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: AI
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: apply
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: for
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: a
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: job
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: at
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: the
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: bakery
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: ?
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: Because
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: it
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: wanted
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: to
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: work
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: on
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: its
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: **
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: d
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: ough
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: **
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: processing
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: skills
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: !
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: 😄
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: Why did the AI apply for a job at the bakery?
+
+Because it wanted to work on its **dough** processing skills! 😄完成本地开发和测试后,您可以将智能体部署到 AgentKit 平台:
requirements.txt 中,使用模版生成的代码默认已经包含了所有必要的依赖。agentkit config和agentkit launch命令,配置和部署应用。agentkit invoke "讲一个笑话!"至此,您已成功完成了从本地开发到云端部署的全过程!
`,53)])])}const o=i(p,[["render",e]]);export{E as __pageData,o as default}; diff --git a/assets/content_4.runtime_1.runtime_quickstart.md.BmdJbidS.lean.js b/assets/content_4.runtime_1.runtime_quickstart.md.BmdJbidS.lean.js new file mode 100644 index 0000000..3451565 --- /dev/null +++ b/assets/content_4.runtime_1.runtime_quickstart.md.BmdJbidS.lean.js @@ -0,0 +1 @@ +import{_ as i,c as a,o as n,ag as t}from"./chunks/framework.CA4hJK0u.js";const E=JSON.parse('{"title":"AgentKit Runtime:从本地到云端的 Agent 部署利器","description":"","frontmatter":{},"headers":[],"relativePath":"content/4.runtime/1.runtime_quickstart.md","filePath":"content/4.runtime/1.runtime_quickstart.md","lastUpdated":1765808136000}'),p={name:"content/4.runtime/1.runtime_quickstart.md"};function e(l,s,h,k,r,g){return n(),a("div",null,[...s[0]||(s[0]=[t("",53)])])}const o=i(p,[["render",e]]);export{E as __pageData,o as default}; diff --git a/assets/content_5.tools_1.sandbox_quickstart.md.C65A9nS4.js b/assets/content_5.tools_1.sandbox_quickstart.md.C65A9nS4.js new file mode 100644 index 0000000..d3e42b6 --- /dev/null +++ b/assets/content_5.tools_1.sandbox_quickstart.md.C65A9nS4.js @@ -0,0 +1,62 @@ +import{_ as i,c as a,o as n,ag as t}from"./chunks/framework.CA4hJK0u.js";const c=JSON.parse('{"title":"AgentKit Built-in Tools 快速开始指南","description":"","frontmatter":{},"headers":[],"relativePath":"content/5.tools/1.sandbox_quickstart.md","filePath":"content/5.tools/1.sandbox_quickstart.md","lastUpdated":1764687855000}'),e={name:"content/5.tools/1.sandbox_quickstart.md"};function l(p,s,h,o,r,k){return n(),a("div",null,[...s[0]||(s[0]=[t(`Built-in Tools为Agent提供标准化的沙箱运行环境和工具接口。提供的All-in-one sandbox镜像集成了代码执行、浏览器自动化、终端操作等核心能力,支持标准化集成与API调用。
本文档将详细介绍如何在智能体代码中集成和使用 Built-in Tools,特别是代码执行沙箱功能。通过本指南,您将学会如何创建、配置和调用沙箱工具。
在开始编写代码之前,您需要先在火山引擎控制台创建一个沙箱工具实例:
TOOL_ID,后续配置中会用到以下代码展示了如何使用 VeADK 构建一个具备代码执行能力的智能体。通过集成 Built-in Tools 的 run_code 工具,您的智能体将能够在沙箱环境中安全地执行代码。 我们推荐您使用agentkit-cli,从Basic Agent模版来创建项目。在模版创建完成后,你需要做以下修改:
run_codeAGENTKIT_TOOL_ID 为您的沙箱工具实例 ID 最终,您的代码文件应该如下:将代码保存为simple_agent_tool.py
from veadk import Agent, Runner
+from veadk.tools.builtin_tools.run_code import run_code
+from agentkit.apps import AgentkitSimpleApp
+
+app = AgentkitSimpleApp()
+agent: Agent = Agent(
+ tools=[run_code],
+)
+runner = Runner(agent=agent)
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ prompt = payload["prompt"]
+ user_id = headers["user_id"]
+ session_id = headers["session_id"]
+
+ response = await runner.run(
+ messages=prompt,
+ user_id=user_id,
+ session_id=session_id
+ )
+ return response
+@app.ping
+def ping() -> str:
+ return "pong!"
+
+if __name__ == "__main__":
+ app.run(host="0.0.0.0", port=8000)async/await 语法支持高并发请求您可以直接使用 Python 包管理工具 pip 从 PyPI 平台 来安装 veadk-python:
pip install veadk-python说明:支持调用built-in-tools的veadk-python版本为0.2.15及以上。
在启动智能体之前,需要配置以下环境变量:
# 必需配置:沙箱工具 ID(从控制台获取)
+export AGENTKIT_TOOL_ID=t-ye7fhfmghsc1kdxxxxxx
+
+# 必需配置:火山引擎访问凭证
+export VOLCENGINE_ACCESS_KEY=your_ak
+export VOLCENGINE_SECRET_KEY=your_sk📝 注意事项:
your_ak、your_sk 等占位符替换为您的实际配置值AGENTKIT_TOOL_ID 从火山引擎控制台创建沙箱工具后获取配置完环境变量后,运行以下命令启动智能体:
python simple_agent_tool.py服务启动成功后,将监听 http://0.0.0.0:8000,您可以通过该地址调用智能体。
工具实例支持基于会话的智能调度管理:
session_id 调用时,系统会自动创建对应的沙箱会话实例session_id 的多次请求将共享同一个沙箱实例,保持代码执行的上下文连续性session_id 的请求使用独立的沙箱环境,互不干扰使用以下 curl 命令测试智能体的代码执行能力:
curl --location 'http://localhost:8000/invoke' \\
+ --header 'Content-Type: application/json' \\
+ --header 'user_id: veadk-test' \\
+ --header 'session_id: local_session' \\
+ --data '{"prompt": "给我在50和100之间一个随机的质数"}'参数说明:
user_id:用户标识符session_id:会话标识符,用于关联沙箱实例prompt:用户的自然语言请求调用成功后,控制台会输出详细的执行日志:
2025-11-23 21:10:24 | DEBUG | runner.py:578 - Function call: id='call_jwrcwdayjj8xnlgalyzzcoqq' args={'code': 'import random\\n\\ndef is_prime(n):\\n if n <= 1:\\n return False\\n if n == 2:\\n return True\\n if n % 2 == 0:\\n return False\\n for i in range(3, int(n**0.5) + 1, 2):\\n if n % i == 0:\\n return False\\n return True\\n\\nprimes_between = [p for p in range(50, 101) if is_prime(p)]\\nrandom_prime = random.choice(primes_between)\\nprint(random_prime)', 'language': 'python3'} name='run_code'
+2025-11-23 21:10:24 | DEBUG | run_code.py:48 - tools endpoint: agentkit.cn-beijing.volces.com
+2025-11-23 21:10:24 | DEBUG | run_code.py:54 - tool_user_session_id: veAgent_veadk-test_local_session
+2025-11-23 21:10:24 | DEBUG | run_code.py:56 - Running code in language: python3, session_id=local_session, code=import random
+
+def is_prime(n):
+ if n <= 1:
+ return False
+ if n == 2:
+ return True
+ if n % 2 == 0:
+ return False
+ for i in range(3, int(n**0.5) + 1, 2):
+ if n % i == 0:
+ return False
+ return True
+
+primes_between = [p for p in range(50, 101) if is_prime(p)]
+random_prime = random.choice(primes_between)
+print(random_prime), tool_id=t-ye7yhff668o2eybtfvr0, host=agentkit.cn-beijing.volces.com, service=agentkit, region=cn-beijing
+2025-11-23 21:10:24 | DEBUG | run_code.py:65 - Get AK/SK from tool context failed.
+2025-11-23 21:10:24 | DEBUG | run_code.py:77 - Successfully get AK/SK from environment variables.
+2025-11-23 21:10:25 | DEBUG | run_code.py:103 - Invoke run code response: {'ResponseMetadata': {'RequestId': '****', 'Action': 'InvokeTool', 'Version': '2025-10-30', 'Service': 'agentkit', 'Region': 'cn-beijing'}, 'Result': {'ToolId': 't-****', 'UserSessionId': '****', 'SessionId': 's-****', 'Endpoint': '', 'InternalEndpoint': '', 'Result': '{\\n "success": true,\\n "message": "Code executed successfully",\\n "data": {\\n "kernel_name": "python3",\\n "session_id": "****",\\n "status": "ok",\\n "execution_count": 1,\\n "outputs": [\\n {\\n "output_type": "stream",\\n "name": "stdout",\\n "text": "67\\\\n",\\n "data": null,\\n "metadata": {},\\n "execution_count": null,\\n "ename": null,\\n "evalue": null,\\n "traceback": null\\n }\\n ],\\n "code": "import random\\\\n\\\\ndef is_prime(n):\\\\n if n \\\\u003c= 1:\\\\n return False\\\\n if n == 2:\\\\n return True\\\\n if n % 2 == 0:\\\\n return False\\\\n for i in range(3, int(n**0.5) + 1, 2):\\\\n if n % i == 0:\\\\n return False\\\\n return True\\\\n\\\\nprimes_between = [p for p in range(50, 101) if is_prime(p)]\\\\nrandom_prime = random.choice(primes_between)\\\\nprint(random_prime)",\\n "msg_id": "****"\\n }\\n}'}}
+2025-11-23 21:10:38 | DEBUG | runner.py:586 - Event output: 在50到100之间的随机质数为:67
+2025-11-23 21:10:38 | WARNING | runner.py:652 - No tracer is configured in the agent, no trace id provided.
+INFO: 127.0.0.1:52785 - "POST /invoke HTTP/1.1" 200 OK完成本地开发和测试后,您可以将智能体部署到 AgentKit 平台:
requirements.txt 中agentkit init 命令,初始化项目,会生成 agentkit.yaml 文件(如果前面已执行,跳过此步)agentkit.yaml文件配置,应用入口设置为您刚才已经调通的应用代码simple_agent_tool.py,即:entry_point: simple_agent_tool.pyrequirements.txt 中agentkit config和agentkit launch命令,配置和部署应用。agentkit invoke "给我在50和100之间一个随机的质数"AI Agent 运行过程中面临多轮任务日益复杂、上下文窗口不足的问题,需要有记忆能力来进行上下文保持与个性化定制。Agentkit Memory 提供统一的记忆库使用接口并与主流框架进行对接,为 Agent 运行记忆库支持提供跨会话、上下文感知和个性化交互,实现 Agent 的持续学习与演进。本章节将指导您安装依赖项并实现长期记忆功能。
以下示例展示了如何使用 Agentkit Memory 实现长期记忆功能。
步骤如下
通过火山引擎控制台,为智能体创建记忆库Agentkit-Memory
在记忆详情-集成代码页面,获取连接信息。
DATABASE_MEM0_BASE_URL="https://mem0-your-mem-url.mem0.volces.com:8000"
+DATABASE_MEM0_API_KEY="xxxxxx-xxxxxxx"DATABASE_VIKINGMEM_COLLECTION=<collection_name of your vikingdb memory> #index
+DATABASE_VIKINGMEM_MEMORY_TYPE=memory_summary_04uyfx # memory type, separate multiple by comma, e.g. event_v1,event_v2VeADK是一个开源的智能体开发框架,提供了智能体的开发、运行、调试等功能,由火山引擎团队维护。 以下示例展示了如何使用 VeADK 构建一个带长期记忆能力的智能体,记忆库后端采用 mem0。智能体可以根据用户输入的问题,使用长期记忆来存储用户偏好、会话摘要等个性化交互信息。
您无需从 0-1 构建 veadk 项目,我们推荐您使用 agentkit-cli,从 Basic Agent App 模版来创建项目(模板使用 VeADK 框架)。在模版创建完成后,你需要做以下修改:
LongTermMemoryagentkit.yamlmem0ai==0.1.118到requirements.txtrunner.save_session_to_long_term_memory,将对话结果保存到长期记忆库最终,您的代码文件应该如下:
'''
+**simple agent demo app**
+
+Before running, the user must set the following environment variables; otherwise, runtime exceptions will inevitably occur:
+- MODEL_AGENT_NAME # model id in Volcano Engine Ark platform
+- MODEL_AGENT_API_KEY # model api key in Volcano Engine Ark platform
+
+MODEL_AGENT_NAME and MODEL_AGENT_API_KEY are used to access the model service of the Volcano Engine Ark platform.
+'''
+import logging
+import os
+
+from veadk import Agent, Runner
+from veadk.memory.long_term_memory import LongTermMemory
+
+
+from agentkit.apps import AgentkitSimpleApp
+
+logger = logging.getLogger(__name__)
+
+index = "simple_app" # required for viking backend, arbitrary for mem0 backend
+
+backend = "mem0" # one of "mem0", "viking_mem"
+if backend == "viking_mem":
+ collection_name = os.getenv("DATABASE_VIKINGMEM_COLLECTION")
+ if not collection_name:
+ raise ValueError("DATABASE_VIKINGMEM_COLLECTION environment variable is not set")
+ index = collection_name
+
+app = AgentkitSimpleApp()
+long_term_memory = LongTermMemory(
+ backend=backend,
+ index=index
+)
+
+agent = Agent(
+ name="simple_app_agent",
+ instruction="You are a helpful assistant.",
+ long_term_memory=long_term_memory
+)
+runner = Runner(agent=agent)
+
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ prompt = payload["prompt"]
+ user_id = headers["user_id"]
+ session_id = headers["session_id"]
+
+ logger.info(
+ f"Running agent with prompt: {prompt}, user_id: {user_id}, session_id: {session_id}"
+ )
+ response = await runner.run(messages=prompt, user_id=user_id, session_id=session_id)
+
+ logger.info(f"Run response: {response}")
+
+ # save the teaching prompt and answer in long term memory
+ await runner.save_session_to_long_term_memory(session_id=session_id, user_id=user_id)
+
+ return response
+
+
+@app.ping
+def ping() -> str:
+ return "pong!"
+
+
+if __name__ == "__main__":
+ app.run(host="0.0.0.0", port=8000)请为您的 agentkit.yaml 文件添加如下配置
# 当长期记忆后端为 mem0 时,添加如下配置
+launch_types:
+ cloud:
+ runtime_envs:
+ DATABASE_MEM0_BASE_URL: <your mem0 url>
+ DATABASE_MEM0_API_KEY: <your mem0 api key>
+
+# 当长期记忆后端为 VikingDB 时,添加如下配置
+launch_types:
+ cloud:
+ runtime_envs:
+ DATABASE_VIKINGMEM_COLLECTION: <your vikingdb collection name>
+ DATABASE_VIKINGMEM_MEMORY_TYPE: <your vikingdb memory type, defaults to "event_v1", separate multiple by comma, e.g. event_v1,event_v2>运行 agentkit launch。构建好 Runtime 链接信息将被自动保存在 agentkit.yaml 文件中。
执行如下发起调用
agentkit invoke "My secret is 0xabcd"将自动使用 user_id="agentkit_user", session_id="agentkit_sample_session"来发起调用。
在首轮调用中,您保存了密码。我们需要更换session_id,来验证 Agent 是否能正确读取到记忆库中的信息。建议您等待约 1 分钟,待长期记忆抽取完成后,再发起调用。
agentkit invoke \\
+ --payload '{"prompt": "What is my secret?"}' \\
+ --headers '{"user_id": "agentkit_user", "session_id": "s123"}'您将看到 Agent 成功读取到记忆库中的信息,并告诉你密码是 0xabcd。
Agentkit Knowledge 提供主流的知识库的一键配置导入能力,实现在 AgentKit 平台轻松关联知识库,并提供统一的知识库接口与框架对接,提升 Agent 使用不同知识库的便利性。
步骤如下
通过火山引擎控制台,为智能体创建知识库VikingDB-Knowledge,并添加下面内容作为qa.md到知识库customer_support中。
# 智能客服知识库
+
+## 1. 公司简介
+
+VE 科技是一家专注于智能客服与知识管理的高科技公司。我们的核心产品是 **智能客服系统**,通过自然语言处理与知识库检索,为企业客户提供高效、智能的自动化客服解决方案。
+
+## 2. 产品功能说明
+
+- **自动问答**:基于知识库,快速响应常见问题。
+- **多渠道接入**:支持网页、App、微信、飞书等渠道。
+- **智能推荐**:根据上下文推荐相关答案。
+- **数据分析**:提供用户问题统计与客服绩效报告。
+- **自助知识库管理**:支持非技术人员快速编辑知识内容。
+
+---
+
+## 3. 常见问题 (FAQ)
+
+### Q1: 智能客服系统支持哪些语言?
+
+A1: 目前支持 **中文** 和 **英文**,后续将逐步增加日语、韩语等多语言支持。
+
+### Q2: 系统可以接入现有的 CRM 吗?
+
+A2: 可以。我们的系统支持通过 API 与主流 CRM 系统(如 Salesforce、Zoho、金蝶)进行无缝集成。
+
+### Q3: 如果机器人无法回答用户问题,会怎么办?
+
+A3: 系统会自动将问题转接至人工客服,并在后台记录该问题,方便管理员补充到知识库。
+
+### Q4: 知识库内容多久更新一次?
+
+## A4: 知识库支持 **实时更新**,管理员提交后即可立即生效。
+
+## 4. 联系我们
+
+- 官网:[https://www.example.com](https://www.example.com)
+- 客服邮箱:support@ve
+- 服务热线:400-123-4567通过火山引擎控制台,为智能体导入知识库Agentkit-Knowledge
在记忆详情-集成代码页面,获取连接信息。
export DATABASE_VIKING_COLLECTION=customer_support
+export DATABASE_VIKING_PROJECT=default
+export DATABASE_VIKING_REGION=cn-beijingVeADK是一个开源的智能体开发框架,提供了智能体的开发、运行、调试等功能,由火山引擎团队维护。
以下示例展示了如何使用 VeADK 构建一个带知识库能力的智能体,知识库后端采用 VikingDB Knowledge。智能体可以根据用户输入的问题,使用知识库来回答用户的问题。
您无需从 0-1 构建 veadk 项目,推荐使用 agentkit-cli,从 Basic Agent App 模版来创建项目(模板使用 VeADK 框架)。在模版创建完成后,你需要做以下修改:
Knowledgebaseagentkit.yaml最终,您的代码文件应该如下:
'''
+**simple agent demo app**
+
+Before running, the user must set the following environment variables; otherwise, runtime exceptions will inevitably occur:
+- MODEL_AGENT_NAME # model id in Volcano Engine Ark platform
+- MODEL_AGENT_API_KEY # model api key in Volcano Engine Ark platform
+
+MODEL_AGENT_NAME and MODEL_AGENT_API_KEY are used to access the model service of the Volcano Engine Ark platform.
+'''
+import logging
+import os
+
+from veadk import Agent, Runner
+from veadk.knowledgebase import KnowledgeBase
+
+
+from agentkit.apps import AgentkitSimpleApp
+
+logger = logging.getLogger(__name__)
+
+collection_name = os.getenv("DATABASE_VIKING_COLLECTION")
+if not collection_name:
+ raise ValueError("DATABASE_VIKING_COLLECTION environment variable is not set")
+
+model_name = "doubao-seed-1-6-250615"
+
+app = AgentkitSimpleApp()
+knowledgebase = KnowledgeBase(backend="viking", index=collection_name)
+
+
+agent = Agent(
+ instruction="Answer customer's questions according to your knowledgebase.",
+ model_name=model_name,
+ knowledgebase=knowledgebase
+)
+runner = Runner(agent=agent)
+
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ prompt = payload["prompt"]
+ user_id = headers["user_id"]
+ session_id = headers["session_id"]
+
+ logger.info(
+ f"Running agent with prompt: {prompt}, user_id: {user_id}, session_id: {session_id}"
+ )
+ response = await runner.run(messages=prompt, user_id=user_id, session_id=session_id)
+
+ logger.info(f"Run response: {response}")
+ return response
+
+
+@app.ping
+def ping() -> str:
+ return "pong!"
+
+
+if __name__ == "__main__":
+ app.run(host="0.0.0.0", port=8000)请为您的 agentkit.yaml 文件添加如下配置
launch_types:
+ cloud:
+ runtime_envs:
+ DATABASE_VIKING_COLLECTION: <your viking collection name>运行 agentkit launch。构建好 Runtime 链接信息将被自动保存在 agentkit.yaml 文件中。
执行如下发起调用
agentkit invoke "你们有什么产品?"您将看到 Agent 成功读取到知识库中的信息,并将qa.md中的信息重新组织语言后回答您。
AgentKit MCP 提供统一的 MCP 网关与工具治理中枢。以共享实例、预制认证插件与自动搜索能力,降低接入门槛、减少 Token 成本、提升工具命中与可靠性,让团队可以专注在业务逻辑与体验打磨。 核心定位:统一入口、轻障碍接入、可治理的工具体系。承载 MCP 访问与会话保持,结合 OAuth2 与 API-Key 的认证插件,以及跨工具的语义搜索能力,形成“易接入、可治理、低成本”的工程骨架。
AgentKit MCP 主要包括 MCP 服务和 MCP 工具集
支持将企业既有 Web/HTTP 服务与第三方接口需要快速进入 Agent。AgentKit 支持两条路径:
适用场景
随着工具数量膨胀或客户端存在工具上限(如 Trae 最多 50 个),自动搜索将“工具全集”对 LLM 的暴露收敛为 search/use 两个封装工具,以向量检索选择高匹配度工具,降低上下文冗余与延迟,并提升调用准确率。
适用场景:
AgentKit MCP 认证链路优先采用 OAuth2 客户端凭证 模式,适用于前端应用访问 Agent runtime、服务端任务访问 Agent runtime,以及 Agent 访问 MCP Server。同时提供 API-Key 作为低依赖的补充方案,并规划后续的轮转与托管。
认证模式的区分:
开始前你需要准备:
一个开通了 AgentKit 的火山账号的 AccessKey & SecretKey
Tips: 需要确保 AccessKey 有 AgentKitFullAccess 权限。
MCP 服务(可以部署在 VeFaas 或公网可访问的位置)
Python 3.10+ installed
方舟APIKEY
可以使用
uv或者python3 -m venv进行虚拟环境管理,下文将以uv做为示例
uv安装参考:uv install
虚拟环境配置
mkdir agentkit-mcp-quickstart
+cd agentkit-mcp-quickstart
+uv venv --python 3.12.0
+source .venv/bin/activate安装依赖
可以通过
--index指定源,加快安装速度
uv pip install veadk-python
+uv pip install google-adk
+pip install agentkit-sdk-python登录火山引擎 AgentKit 控制台。
为准备好的后端 创建 MCP 服务。
获取到创建后的 MCP 服务 Endpoint 和 ApiKey。会看到以下类似的输出:
httpUrl即为 MCP 服务的 Endpoint,Authorization即为 ApiKey。
{
+ "mcpServers": {
+ "create-http-334df4": {
+ "httpUrl": "https://sd4fc6lpoh486npgcaav0.apigateway-cn-beijing.volceapi.com/mcp/create-http-334df4",
+ "headers": {
+ "Authorization": "Bearer P66l-rpaLbxxxxxxxxxxxxxxo2PQ"
+ }
+ }
+ }
+}环境变量配置
export MCP_ENDPOINT={{第三步中获取的Endpoint}}
+export MCP_AUTH_KEY={{第三步中获取的ApiKey}}
+export API_KEY={{方舟的APIKEY}}代码示例
代码示例中,我们使用 VeADK 框架,创建了一个简单的智能体,用于调用 MCP 服务。
import logging
+
+from veadk import Agent, Runner
+from veadk.config import getenv
+from agentkit.apps import AgentkitSimpleApp
+from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, StreamableHTTPConnectionParams
+
+logger = logging.getLogger(__name__)
+
+
+url = getenv("MCP_ENDPOINT")
+mcp_auth_key = getenv("MCP_AUTH_KEY")
+apikey = getenv("API_KEY")
+
+mcp_ecs_toolset = MCPToolset(
+ connection_params=StreamableHTTPConnectionParams(
+ url=url,
+ headers={"Authorization": f"Bearer {mcp_auth_key}"}
+ ),
+)
+
+app = AgentkitSimpleApp()
+
+root_agent = Agent(
+ name="ecs_helper",
+ model_name="doubao-1-5-pro-256k-250115",
+ instruction='''
+ Help user find ECS instances and their details.
+ ''',
+ description="ECS Helper Agent",
+ tools=[mcp_ecs_toolset]
+)
+
+runner = Runner(agent=root_agent)
+
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ prompt = payload["prompt"]
+ user_id = headers["user_id"]
+ session_id = headers["session_id"]
+
+ logger.info(
+ f"Running agent with prompt: {prompt}, user_id: {user_id}, session_id: {session_id}"
+ )
+
+ # 运行智能体,自动处理工具调用
+ response = await runner.run(
+ messages=prompt,
+ user_id=user_id,
+ session_id=session_id
+ )
+
+ logger.info(f"Run response: {response}")
+ return response
+
+@app.ping
+def ping() -> str:
+ """健康检查接口"""
+ return "pong!"
+
+if __name__ == "__main__":
+ # 启动本地开发服务器
+ app.run(host="0.0.0.0", port=8000)执行请求
curl --location 'http://localhost:8000/invoke' \\
+ --header 'Content-Type: application/json' \\
+ --header 'user_id: veadk-test' \\
+ --header 'session_id: local_session' \\
+ --data '{"prompt": "分析下我的ecs实例"}'运行结果
2025-10-24 20:17:33 | INFO | ark_veauth.py:25 - Fetching ARK token...
+2025-10-24 20:17:33 | INFO | agent.py:118 - Model extra config: {'extra_headers': {'x-is-encrypted': 'true', 'veadk-source': 'veadk', 'veadk-version': '0.2.13', 'User-Agent': 'VeADK/0.2.13', 'X-Client-Request-Id': 'veadk/0.2.13'}, 'extra_body': {'caching': {'type': 'enabled'}, 'expire_at': 1761311852}}
+2025-10-24 20:17:33 | DEBUG | agent.py:127 - LiteLLM client created with config: {'extra_headers': {'x-is-encrypted': 'true', 'veadk-source': 'veadk', 'veadk-version': '0.2.13', 'User-Agent': 'VeADK/0.2.13', 'X-Client-Request-Id': 'veadk/0.2.13'}, 'extra_body': {'caching': {'type': 'enabled'}, 'expire_at': 1761311852}}
+2025-10-24 20:17:33 | INFO | agent.py:153 - VeADK version: 0.2.13
+2025-10-24 20:17:33 | INFO | agent.py:155 - Agent \`ecs_helper\` init done.
+2025-10-24 20:17:33 | DEBUG | agent.py:156 - Agent: {'name': 'ecs_helper', 'tools': [<google.adk.tools.mcp_tool.mcp_toolset.MCPToolset object at 0x7f8b4f24b9b0>], 'model_name': 'doubao-1-5-pro-256k-250115', 'model_api_base': 'https://ark.cn-beijing.volces.com/api/v3/'}
+2025-10-24 20:17:33 | WARNING | runner.py:198 - No short term memory or session service provided, use an in-memory one instead.
+2025-10-24 20:17:33 | INFO | runner.py:217 - No long term memory provided.
+INFO: Started server process [1330124]
+INFO: Waiting for application startup.
+INFO: Application startup complete.
+INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
+2025-10-24 20:18:35 | INFO | runner.py:250 - Run config: speech_config=None response_modalities=None save_input_blobs_as_artifacts=False support_cfc=False streaming_mode=<StreamingMode.NONE: None> output_audio_transcription=AudioTranscriptionConfig() input_audio_transcription=AudioTranscriptionConfig() realtime_input_config=None enable_affective_dialog=None proactivity=None session_resumption=None context_window_compression=None save_live_audio=False max_llm_calls=100
+2025-10-24 20:18:35 | DEBUG | runner.py:265 - Auto create session: local_session, user_id: veadk-test, app_name: veadk_default_app
+2025-10-24 20:18:38 | DEBUG | runner.py:280 - Function call: id='call_xbyfcvc86wc26mbxz39vst12' args={'region': 'cn-beijing', 'needNum': 10} name='describe_instances'
+2025-10-24 20:19:14 | DEBUG | runner.py:288 - Event output: 以下是您的ECS实例详情:
+1. **实例1**:
+ - **实例ID**:i-ye7irm2sqobw80cqxd40
+ - **创建时间**:2025-10-23T21:36:31+08:00
+ - **计费方式**:PostPaid(按量计费)
+ - **实例规格**:ecs.e-c1m2.xlarge
+ - **CPU**:4核(核心数2,每核心线程数2)
+ - **内存**:8192MB
+ - **操作系统**:Windows Server 2022 Datacenter Edition 64 - bit Chinese
+ - **镜像ID**:image-ye5907jc6ikhx1exow93
+ - **状态**:RUNNING(运行中)
+ - **所属可用区**:cn - beijing - a
+2. **实例2**:
+ - **实例ID**:i-ye7ipm0dtsqc6imh310d
+ - **创建时间**:2025-10-23T21:05:44+08:00
+ - **计费方式**:PostPaid(按量计费)
+ - **实例规格**:ecs.e-c1m2.xlarge
+ - **CPU**:4核(核心数2,每核心线程数2)
+ - **内存**:8192MB
+ - **操作系统**:Debian 12 64 bit
+ - **镜像ID**:image-ydzwsvy72n46nmxzvafi
+ - **状态**:RUNNING(运行中)
+ - **所属可用区**:cn - beijing - a
+3. **实例3**:
+ - **实例ID**:i-ye7ilsbbpcbw80ca2ymj
+ - **创建时间**:2025-10-23T20:06:54+08:00
+ - **计费方式**:PostPaid(按量计费)
+ - **实例规格**:ecs.e-c1m2.xlarge
+ - **CPU**:4核(核心数2,每核心线程数2)
+ - **内存**:8192MB
+ - **操作系统**:Windows Server 2022 Datacenter Edition 64 - bit Chinese
+ - **镜像ID**:image-ye5907jc6ikhx1exow93
+ - **状态**:RUNNING(运行中)
+ - **所属可用区**:cn - beijing - a
+4. **实例4**:
+ - **实例ID**:i-ye7fg1hgqoxjd1utrfy3
+ - **创建时间**:2025-10-22T14:57:49+08:00
+ - **计费方式**:PostPaid(按量计费)
+ - **实例规格**:ecs.e-c1m2.xlarge
+ - **CPU**:4核(核心数2,每核心线程数2)
+ - **内存**:8192MB
+ - **操作系统**:Windows Server 2022 Datacenter Edition 64 - bit Chinese
+ - **镜像ID**:image-ye5907jc6ikhx1exow93
+ - **状态**:RUNNING(运行中)
+ - **所属可用区**:cn - beijing - a
+5. **实例5**:
+ - **实例ID**:i-ye5ejwoow0cva4fqydfc
+ - **创建时间**:2025-09-24T14:25:37+08:00
+ - **计费方式**:PostPaid(按量计费)
+ - **实例规格**:ecs.e-c1m2.xlarge
+ - **CPU**:4核(核心数2,每核心线程数2)
+ - **内存**:8192MB
+ - **操作系统**:Windows Server 2022 Datacenter Edition 64 - bit Chinese
+ - **镜像ID**:image-ye5907jc6ikhx1exow93
+ - **状态**:RUNNING(运行中)
+ - **所属可用区**:cn - beijing - a
+6. **实例6**:
+ - **实例ID**:i-ye5ejub08wbw80bpd7hr
+ - **创建时间**:2025-09-24T14:24:35+08:00
+ - **计费方式**:PostPaid(按量计费)
+ - **实例规格**:ecs.e-c1m2.xlarge
+ - **CPU**:4核(核心数2,每核心线程数2)
+ - **内存**:8192MB
+ - **操作系统**:Windows Server 2022 Datacenter Edition 64 - bit Chinese
+ - **镜像ID**:image-ye5907jc6ikhx1exow93
+ - **状态**:RUNNING(运行中)
+ - **所属可用区**:cn - beijing - a
+7. **实例7**:
+ - **实例ID**:i-ye5e5jyq68bw80c889i5
+ - **创建时间**:2025-09-24T10:44:54+08:00
+ - **计费方式**:PostPaid(按量计费)
+ - **实例规格**:ecs.e-c1m2.xlarge
+ - **CPU**:4核(核心数2,每核心线程数2)
+ - **内存**:8192MB
+ - **操作系统**:Windows Server 2022 Datacenter Edition 64 - bit Chinese
+ - **镜像ID**:image-ye5907jc6ikhx1exow93
+ - **状态**:RUNNING(运行中)
+ - **所属可用区**:cn - beijing - a
+8. **实例8**:
+ - **实例ID**:i-ye5c4jbx8gqc6ily6b30
+ - **创建时间**:2025-09-23T16:02:05+08:00
+ - **计费方式**:PostPaid(按量计费)
+ - **实例规格**:ecs.e-c1m2.xlarge
+ - **CPU**:4核(核心数2,每核心线程数2)
+ - **内存**:8192MB
+ - **操作系统**:Windows Server 2022 Datacenter Edition 64 - bit Chinese
+ - **镜像ID**:image-ye5907jc6ikhx1exow93
+ - **状态**:RUNNING(运行中)
+ - **所属可用区**:cn - beijing - a
+9. **实例9**:
+ - **实例ID**:i-ye5c4end34xjd1umbfns
+ - **创建时间**:2025-09-23T16:00:05+08:00
+ - **计费方式**:PostPaid(按量计费)
+ - **实例规格**:ecs.e-c1m2.xlarge
+ - **CPU**:4核(核心数2,每核心线程数2)
+ - **内存**:8192MB
+ - **操作系统**:Debian 12 64 bit
+ - **镜像ID**:image-ydzwsvfxhokhx11pdmlv
+ - **状态**:RUNNING(运行中)
+ - **所属可用区**:cn - beijing - a
+10. **实例10**:
+ - **实例ID**:i-ye5blj0xdsxjd1tk1vfh
+ - **创建时间**:2025-09-23T11:09:46+08:00
+ - **计费方式**:PostPaid(按量计费)
+ - **实例规格**:ecs.e-c1m2.xlarge
+ - **CPU**:4核(核心数2,每核心线程数2)
+ - **内存**:8192MB
+ - **操作系统**:Debian 12 64 bit
+ - **镜像ID**:image-ydzwsvfxhokhx11pdmlv
+ - **状态**:RUNNING(运行中)
+ - **所属可用区**:cn - beijing - a
+
+以上10个实例均为按量计费,规格为ecs.e-c1m2.xlarge ,且大部分使用Windows Server 2022 Datacenter Edition 64 - bit Chinese操作系统,少数使用Debian 12 64 bit操作系统,目前状态均为运行中,所属可用区为cn - beijing - a 。若您还需要进一步分析或有其他操作需求,可继续向我提问。AgentKit is an enterprise-grade AI Agent development platform launched by Volcengine. It provides developers with a complete solution for building, deploying, and operating Agents. Through a standardized development toolchain and cloud-native infrastructure, the platform significantly lowers the barrier to developing and deploying complex intelligent agent applications.
agentkit CLI toolchain covering project initialization, local debugging, cloud deployment, and online operations.AgentKit’s core design concept is to separate the definition and execution of an Agent App.
agentkit.yaml file.agentkit CLI and AgentKit Platform parse the definition file and automatically complete a series of tedious tasks such as environment preparation, code packaging, image building, continuous integration, and cloud deployment.This separation allows developers to focus on implementing business logic while AgentKit handles complex engineering problems, enabling agile development and fast production delivery.
This guide will walk you through installing AgentKit and completing the basic configuration.
uv or pip recommendedWe strongly recommend installing AgentKit in a Python virtual environment to avoid conflicts with system packages.
Recommended for production deployments:
pip install agentkit-sdk-pythonIncludes the latest features and fixes:
pip install --pre agentkit-sdk-pythonInstall a specific version:
pip install agentkit-sdk-python==0.1.7We recommend using uv to manage virtual environments and dependencies.
# install uv
+curl -LsSf https://astral.sh/uv/install.sh | sh
+
+# Initialize uv environment
+uv init --no-workspace
+
+# Specify Python version for the environment
+uv venv --python 3.12
+
+# Install AgentKit using uv
+uv add agentkit-sdk-python
+
+# Install veadk (recommended for local debugging)
+uv add veadk-python
+
+# Activate the virtual environment
+source .venv/bin/activateFor developers and customization scenarios:
# clone repo
+git clone git@github.com:volcengine/agentkit-sdk-python.git
+
+cd agentkit-sdk-python
+
+# we use uv to build this project
+uv venv --python 3.12
+
+# only install necessary requirements
+uv sync
+
+# install agentkit-sdk-python with editable mode
+uv pip install -e .
+
+# Activate the virtual environment
+source .venv/bin/activateIf you prefer pip and venv, you can also run:
# Create virtual environment
+python3 -m venv .venv
+
+# Activate virtual environment
+source .venv/bin/activate
+
+# Install AgentKit
+pip install agentkit-sdk-pythonAfter installation, run the following command to verify that the agentkit CLI is available:
agentkit --versionIf the version is printed successfully, AgentKit has been installed.
Before using the agentkit CLI to interact with AgentKit Platform, you need to configure access credentials (AK/SK).
Use AgentKit’s global configuration feature to store your credentials securely:
# Initialize global configuration
+agentkit config --global --init
+
+# Set your access credentials
+agentkit config --global --set volcengine.access_key="YOUR_ACCESS_KEY"
+agentkit config --global --set volcengine.secret_key="YOUR_SECRET_KEY"
+
+# Verify configuration
+agentkit config --global --showThis stores credentials securely in ~/.agentkit/config.yaml, avoiding exposure of sensitive information in shell history.
For temporary development debugging, you can set environment variables:
export VOLCENGINE_ACCESS_KEY="YOUR_ACCESS_KEY"
+export VOLCENGINE_SECRET_KEY="YOUR_SECRET_KEY"⚠️ Note: For security reasons, it is not recommended to add export commands containing sensitive information to shell configuration files (such as ~/.bashrc or ~/.zshrc), because this may cause credential leakage.
You have now installed and configured AgentKit, and you can start building your first Agent.
This guide will walk you through developing a simple Agent using the “Basic Agent App” template, and quickly experiencing the full AgentKit workflow from development and deployment to testing. AgentKit provides multiple templates, including basic apps, streaming output, and A2A protocol, and supports both Python and Golang development.
First, you need a Volcengine account and to enable the AgentKit service. Please visit the Volcengine Console to complete registration and activation.
Then, create and obtain access keys (AK/SK) on the Access Control page.
After obtaining them, set them as environment variables:
export VOLCENGINE_ACCESS_KEY=<your_access_key>
+export VOLCENGINE_SECRET_KEY=<your_secret_key>Your Agent usually needs to call a large language model (LLM) to provide core intelligence. AgentKit Platform supports multiple models from Volcengine Ark. Make sure you have enabled the Volcengine Ark service and obtained the model inference Endpoint and API Key.
Get the inference endpoint (Endpoint): On the Ark platform’s “Online Inference” page, you can select a preset inference endpoint or create a custom inference endpoint.
Get the API Key: On the “API Key Management” page, select or create a new API Key.
Please record your Endpoint ID such as ep-20250520174054-xxxxx (it can also be a model ID such as deepseek-v3-1-terminus) and API Key. You will later configure them for the Agent via the environment variables MODEL_AGENT_NAME and MODEL_AGENT_API_KEY.
If you do not provide this information, AgentKit Platform will automatically inject a built-in
doubao-seed-1-6model for you during cloud deployment.
If you plan to run and debug the Agent locally (Local mode), because the local environment cannot automatically inject cloud credentials, you must configure the access credentials manually; otherwise, the Agent will not be able to call the LLM.
You can configure credentials in one of the following two ways:
Option 1: Configure Ark model credentials
Directly specify the model endpoint and API Key to use:
# Set via --runtime_envs (-e) during config
+agentkit config -e MODEL_AGENT_NAME=<your_endpoint_id> -e MODEL_AGENT_API_KEY=<your_api_key>Option 2: Configure Volcengine access keys
If you configure Volcengine AK/SK, veADK will try to automatically obtain your model access permissions:
# Set via --runtime_envs (-e) during config
+agentkit config -e VOLCENGINE_ACCESS_KEY=<your_access_key> -e VOLCENGINE_SECRET_KEY=<your_secret_key>Note:
- In Local mode, directly
exporting environment variables in the host shell does not take effect inside the container. You must useagentkit config -eto write them intoagentkit.yamlunderruntime_envs.- In Cloud mode, the Runtime automatically injects related credentials, and you usually do not need to manually configure the above environment variables.
Before you begin, ensure you have followed the Install AgentKit guide to complete installation of the agentkit CLI and environment configuration.
Create a project directory and initialize your Agent app using agentkit init:
mkdir simple-agent && cd simple-agent
+agentkit initAfter running, a list of available templates will be shown. Select template 1 (Basic Agent App). You can also specify a template directly using the --template parameter:
# Use basic template
+agentkit init --template basic
+
+# Use streaming output template
+agentkit init --template basic_stream
+
+# List all available templates
+agentkit init --list-templatesAfter the command runs, template code and config files will be generated in the current directory:
.
+├── agentkit.yaml # Core configuration file for the Agent.
+├── requirements.txt # Python dependencies for the project.
+└── simple_agent.py # Entry point for the Agent application.You can use agentkit launch to build and deploy the app to the cloud in one command. This command uses the configuration in agentkit.yaml.
If you need custom configuration (for example, specify deployment region, image repository, or provide model keys), you can edit agentkit.yaml manually, or run agentkit config to generate configuration through an interactive wizard.
agentkit configThe configuration wizard will guide you to complete the following settings:
General settings (press Enter to use default values):
simple_agent, press Enter to accept)simple_agent.py)requirements.txt or go.modMODEL_AGENT_NAME: Ark model endpoint ID (optional)MODEL_AGENT_API_KEY: Ark model API Key (optional)cloud (cloud build and deployment)Cloud deployment settings:
`,41)),s("ul",null,[i[3]||(i[3]=s("li",null,[s("strong",null,"1.Service region"),e(": default "),s("code",null,"cn-beijing")],-1)),s("li",null,[i[0]||(i[0]=s("strong",null,"2.Image tag",-1)),i[1]||(i[1]=e(": default ",-1)),s("code",null,r(t.timestamp),1),i[2]||(i[2]=e(", will be rendered as a timestamp in the format 20251218154940",-1))]),i[4]||(i[4]=s("li",null,[s("strong",null,"3.CR image repository"),e(": CLI will automatically generate the CR instance name, CR namespace, and CR repository name. Users can also specify manually (recommended to keep automatic).")],-1))]),i[6]||(i[6]=a(`After configuration is complete, run the launch command to deploy with one click:
agentkit launchThis command automatically completes the following steps:
After a successful deployment, you will see output like:
✅ Runtime created successfully: r-ye9j62wydcn****nhsoa, request_id: 20251120***************5344
+Waiting for Runtime to be Ready...
+💡 Tip: Runtime is initializing, please be patient and do not interrupt the process
+✅ Runtime status is Ready
+ Runtime status: Releasing ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:01:23
+Endpoint: https://sd4fe31poh486****.apigateway-cn-beijing.volceapi.com
+100% ▶ Deployment complete
+✅ Successfully launched agent: https://sd4fe31poh486npgcaqq0.apigateway-cn-beijing.volceapi.com
+Built image: agentkit-cli-21076x****-cn-beijing.cr.volces.com/agentkit/myapp:2025112017****
+Endpoint: https://sd4fe31poh486****.apigateway-cn-beijing.volceapi.comTip: The first deployment usually takes about 2–3 minutes. Please be patient.
Test the Agent with the invoke command:
agentkit invoke "Hello"If you see output similar to the following, congratulations—your first Agent is running successfully!
(agentkit) test@localhost:~/workspace/simple-agent$ agentkit invoke "Hello"
+Invoking agent...
+Using default headers: {'user_id': 'agentkit_user', 'session_id': 'agentkit_sample_session'}
+✅ Invocation successful
+📝 Response:
+Hello! I am an AI assistant developed by the **** team, specializing in data science (information gathering, data analysis, etc.), document writing (writing multi-chapter articles, in-depth research reports), and software development (creating websites/applications, solving coding problems, etc.).
+If you have any specific needs, I'd be happy to help!Congratulations on completing development and deployment of your first Agent!
Next, you can:
agentkit memory, agentkit knowledge, and agentkit tools to manage platform servicesThis guide is intended to help you diagnose and resolve common issues you may encounter when using AgentKit. If you cannot find a solution here, feel free to contact us via GitHub Issues.
agentkit command not found agentkit command in the terminal, the system reports command not found.pip has not been added to the system PATH environment variable.pip show agentkit-sdk-python or uv pip show agentkit-sdk-python and find the install path indicated by the Location field.bin directory (for example .../site-packages/bin), you should be able to find the agentkit executable.bin directory to your ~/.bashrc, ~/.zshrc, or other shell configuration files.export PATH="/path/to/your/python/bin:$PATH"source ~/.bashrc or restart the terminal to apply the changes.agentkit-sdk-python, pip reports dependency version conflicts.uv or venv to create a clean virtual environment in your project to avoid conflicts with system-level Python packages.uv venv
+source .venv/bin/activate
+uv pip install agentkit-sdk-pythonpip uninstall agentkit-sdk-python
+pip install agentkit-sdk-pythonecho $VOLCENGINE_ACCESS_KEY
+echo $VOLCENGINE_SECRET_KEYagentkit launch, it reports configuration file parsing failure.agentkit.yaml is formatted correctly (pay attention to indentation)agentkit config to generate configurationCreateRegistry: QuotaExceeded.Registry The quota of Registry is exceeded.agentkit config, configure it to use an existing CR instance namerequirements.txt are correctReleasing state for a long time.agentkit status to check statusagentkit destroy and then redeployFailed or Error.agentkit destroy and redeployingagentkit invoke, it reports connection failure or timeout.agentkit status to confirm Runtime status is ReadyInvalidAccessKeyId or SignatureDoesNotMatch.AccessDenied or insufficient permissions.If the above solutions cannot resolve your issue, please:
Check logs:
Contact support:
Read the docs:
AgentKit CLI is a powerful command-line tool designed for developers to simplify and accelerate the full lifecycle of Agent application development, deployment, and management. Whether you’re rapidly prototyping locally or deploying at scale in production, the agentkit command delivers a consistent and efficient developer experience.
agentkit.yaml file—clear, portable, and easy to version-control.agentkit launch combine multiple steps (build, deploy, etc.) into one, dramatically improving efficiency.agentkit config guide you through setup and reduce the learning curve.The agentkit CLI provides a set of intuitive commands to manage your Agent applications:
| Command | Description |
|---|---|
agentkit init | Initialize a new Agent project, with optional templates. |
agentkit config | Configure agentkit.yaml via an interactive wizard. |
agentkit build | Build your Agent application into a Docker image. |
agentkit deploy | Deploy a built image to the specified environment (local or cloud). |
agentkit launch | Build and deploy in one command—the most commonly used command during development. |
agentkit invoke | Interact with a deployed Agent for quick testing. |
agentkit status | View the Agent runtime status and endpoint. |
agentkit destroy | Stop and destroy the Agent instance, releasing related resources. |
| Command | Description |
|---|---|
agentkit memory | Manage AgentKit Memory collections. |
agentkit knowledge | Manage AgentKit Knowledge bases. |
agentkit tools | Manage AgentKit Tools and Sessions. |
agentkit runtime | Manage AgentKit Runtime instances. |
Want detailed usage for each command? See Command Reference.
One of the core features of AgentKit CLI is its flexible deployment model, designed to adapt to different stages from development to production.
local) Build and deploy on your local machine—ideal for fast development and debugging.
Source code → Local Docker build → Run local containercloud) Fully host build and deployment on the AgentKit Platform—a best practice for production.
Source code → Cloud auto build → Cloud image registry → Production-grade Runtimehybrid) Build the image locally, then push it to the cloud AgentKit Platform for deployment. This combines local control with cloud capabilities.
Source code → Local Docker build → Upload to cloud image registry → Production-grade Runtimeagentkit.yaml) agentkit.yaml is the core of an AgentKit project. It defines all application configuration in a declarative manner. We strongly recommend managing this file with the agentkit config command.
# General configuration
+common:
+ agent_name: my-agent
+ entry_point: app.py
+ language_version: '3.12'
+ launch_type: cloud # Define the default deployment mode
+
+# Mode-specific configuration
+launch_types:
+ cloud:
+ region: cn-beijing
+ image_tag: latest
+ runtime_envs:
+ MODEL_API_KEY: "your-api-key"Want detailed explanations of all configuration options? See Configuration Reference.
In just a few minutes, you can deploy your first Agent.
# 1. Initialize a project (choose the Basic App template)
+mkdir my-first-agent && cd my-first-agent
+agentkit init my-first-agent
+
+# Or specify a particular template
+agentkit init my-first-agent --template basic_stream # Streaming output template
+agentkit init my-first-agent --template a2a # A2A protocol template
+
+# 2. Configure the app (via the interactive wizard)
+agentkit config
+
+# 3. Deploy to the cloud in one command
+agentkit launch
+
+# 4. Test your Agent
+agentkit invoke "Hello!"
+
+# 5. Check runtime status
+agentkit status
+
+# 6. Clean up resources (optional)
+agentkit destroy# List available templates
+agentkit init --list-templates
+
+# Manage platform services
+agentkit memory list # List memory collections
+agentkit knowledge list # List knowledge bases
+agentkit tools list # List tools
+agentkit runtime list # List runtime instancesrequirements.txtgo.mod# Initialize global configuration
+agentkit config --global --init
+
+# Set access credentials
+agentkit config --global --set volcengine.access_key="your_access_key"
+agentkit config --global --set volcengine.secret_key="your_secret_key"
+
+# (Optional for Byteplus) Set BytePlus as the default cloud provider
+agentkit config --global --set defaults.cloud_provider=byteplus
+
+# (Optional for Byteplus) Set Byteplus access credentials
+agentkit config --global --set byteplus.access_key="your_byteplus_access_key"
+agentkit config --global --set byteplus.secret_key="your_byteplus_secret_key"agentkit.yaml.AgentKit CLI is the core tool for interacting with the AgentKit Platform. It provides a complete set of commands designed to simplify and automate the full lifecycle of Agent development, deployment, and management. Whether you are initializing a new project, configuring cloud resources, or testing and iterating on your Agent, AgentKit CLI provides strong support.
This document introduces the purpose, parameters/options, and best practices for each command, helping you use AgentKit CLI efficiently to build excellent Agent applications.
AgentKit CLI follows the standard format: agentkit <command> [arguments] [options].
| Command | Description | Core Use Cases |
|---|---|---|
init | Initialize a project: Create a brand-new Agent project or wrap existing code. | Start new Agent development; quickly deploy existing code. |
config | Configure an app: Manage project configuration interactively or non-interactively. | Set deployment mode, environment variables, image tags, etc. |
build | Build an image: Package your Agent code into a portable Docker image. | Prepare for deployment; CI/CD integration. |
deploy | Deploy an app: Publish a built image to the target runtime environment. | Go live or update an Agent service. |
launch | One-command launch: Automatically completes both build and deploy. | Fast iteration; simplified release workflow. |
invoke | Test invocation: Invoke an Agent locally or in the cloud for functional validation. | Debug Agent logic; end-to-end validation. |
status | View status: Get runtime status and endpoint information for a deployed Agent. | Monitor service health; obtain access URL. |
destroy | Clean up resources: Stop and delete deployed Agent instances and related resources. | Take a service offline; release cloud resources. |
agentkit init agentkit init guides you through creating a new Agent project. It supports both “start from scratch” and “wrap existing code”, significantly improving bootstrap efficiency.
veadk Agent definition file into a deployable AgentKit project to reuse code.# Template mode: create from a preset template
+agentkit init [project_name] [options]
+
+# Wrapper mode: wrap an existing Agent definition file
+agentkit init [project_name] --from-agent <path_to_agent_file> [options]project_name (optional): smart-faq-agent.simple_agent; in wrapper mode, auto-generated from the source filename (e.g. agentkit-my_agent)._), and hyphens (-).| Option | Description | Example |
|---|---|---|
--template, -t | Select a project template such as basic, basic_stream, a2a. | --template basic |
--agent-name | Set the display name of the Agent. | --agent-name "Intelligent Customer Support" |
--description | Describe what the Agent does (especially important in multi-agent collaboration). | --description "Handle common user questions" |
--system-prompt | Define the Agent system prompt to shape its role and behavior. | --system-prompt "You are a professional customer support agent..." |
--model-name | Specify the model name on Volcengine Ark. | --model-name "doubao-pro-32k" |
--tools | Comma-separated list of tools such as web_search,run_code. | --tools "web_search" |
| Option | Description | Example |
|---|---|---|
--from-agent, -f | (Required) Path to an existing Python file that contains a veadk.Agent definition. | --from-agent ./my_existing_agent.py |
--agent-var | If auto-detection fails, manually specify the variable name of the Agent object in the file. | --agent-var "custom_agent_instance" |
--wrapper-type | Wrapper type to generate: basic (standard) or stream (streaming). | --wrapper-type stream |
| Option | Description | Default |
|---|---|---|
--directory | Target directory where the project will be created. | Current directory (.) |
# Example 1: interactive creation; guides you to choose a template
+agentkit init my-first-agent
+
+# Example 2: create directly using the 'basic' template
+agentkit init weather-report-agent --template basic
+
+# Example 3: create in a specified directory
+agentkit init my_agent --template basic_stream --directory ./my_agents
+
+# Example 4: shorthand
+agentkit init weather -t basic
+
+# Example 5: customize Agent attributes
+agentkit init custom-agent \\
+ --template basic \\
+ --agent-name "Advanced Assistant" \\
+ --description "An agent with web access and code execution" \\
+ --tools "web_search,run_code"
+
+# Example 6: create a streaming output Agent
+agentkit init stream_agent \\
+ --template basic_stream \\
+ --agent-name "Streaming Chat Assistant" \\
+ --model-name "doubao-seed-1-6-250615"# Example 7: wrap an existing Agent file (auto-detect Agent variable)
+agentkit init --from-agent ./my_agent.py
+
+# Example 8: wrap and specify a project name
+agentkit init weather_bot --from-agent ./weather_agent.py
+
+# Example 9: shorthand and specify Agent variable name
+agentkit init -f ./my_agent.py --agent-var my_custom_agent
+
+# Example 10: generate a streaming wrapper
+agentkit init chat_bot \\
+ --from-agent ./chat_agent.py \\
+ --wrapper-type stream
+
+# Example 11: wrap into a specified directory
+agentkit init deployed_agent \\
+ --from-agent ../agents/production_agent.py \\
+ --agent-var prod_agent \\
+ --wrapper-type basic \\
+ --directory ./deployment
+
+# Example 12: a complete wrapper command
+agentkit init my_deployed_bot \\
+ -f ~/projects/agents/my_bot.py \\
+ --agent-var bot \\
+ --wrapper-type stream \\
+ --directory ./deployBest practices
basic template; it provides a simple project structure.veadk Agent logic, wrapper mode helps you avoid rewriting code and focus on fast deployment.After running a template-mode command, you will see output similar to:
✨ Build AI Agents with Ease ✨
+
+Available Templates
+┌────┬──────────────────────────┬──────────┬──────────────────────────────────────────────┐
+│ ID │ Name │ Type │ Description │
+├────┼──────────────────────────┼──────────┼──────────────────────────────────────────────┤
+│ 1 │ Basic Agent App │ Basic App│ Basic Agent app, great for getting started │
+│ 2 │ Basic Stream Agent App │ Stream App│ Agent app with streaming output │
+│ 3 │ A2A Agent App │ A2A App │ Multi-agent app supporting the A2A protocol │
+│ 4 │ Eino A2A Agent App │ A2A App │ A2A app based on the Eino framework (Golang) │
+└────┴──────────────────────────┴──────────┴──────────────────────────────────────────────┘
+
+Please select a template by entering the ID (1-2):
+Template ID: 1
+Selected: Basic Agent App
+
+Creating project: my_weather_agent
+Using template: Basic Agent App
+
+✨ Project initialized successfully!
+Template: Basic Agent App
+Entry point: my_weather_agent.py
+Language: Python 3.12
+
+Created files:
+ ✓ my_weather_agent.py
+ ✓ requirements.txt
+ ✓ agentkit.yaml
+ ✓ .dockerignore
+
+Next steps:
+ 1. Review and modify the generated files
+ 2. Use agentkit config to configure your agent
+ 3. Use agentkit launch to build and deployAfter running a wrapper-mode command, you will see output similar to:
✨ Build AI Agents with Ease ✨
+
+🔄 Wrapping existing Agent file
+
+Project name: agentkit-my_agent
+Agent file: ./my_agent.py
+Wrapper type: basic
+
+✨ Project initialized successfully!
+Template: Agent Wrapper (Basic)
+Entry point: agentkit-my_agent.py
+Language: Python 3.12
+Agent file: my_agent.py
+Agent variable: agent
+
+Created files:
+ ✓ my_agent.py
+ ✓ agentkit-my_agent.py
+ ✓ requirements.txt
+ ✓ agentkit.yaml
+ ✓ .dockerignore
+
+Next steps:
+ 1. Review and modify the generated files
+ 2. Use agentkit config to configure your agent
+ 3. Use agentkit launch to build and deployWrapper mode is a powerful feature that lets you quickly deploy an existing Agent definition file to the AgentKit platform without rewriting code.
agentkit.yaml and other required deployment files.The generated wrapper file is responsible for:
veadk Runner.@app.entrypoint and @app.ping interfaces required by AgentKit.Your Agent file must meet the following requirements:
Basic requirements:
# Must be a Python file (.py)
+# Must contain an Agent object definition
+
+from veadk import Agent
+
+# Agent definition - variable name can be agent, my_agent, etc.
+agent = Agent(
+ model="doubao-seed-1-6-250615",
+ description="My Agent"
+)Supported Agent variable names:
agent, main_agent, my_agent, etc.--agent-var.Unsupported cases:
Agent(...) definition in the file.| Feature | Basic wrapper | Stream wrapper |
|---|---|---|
| Response mode | Return the full result once | Streaming return (SSE) |
| Typical scenarios | Standard chat; short responses | Long-form generation; real-time output |
| Dependencies | veadk-python | veadk-python + google-adk |
| Config requirements | None | Agent must support streaming output |
| Client UX | Wait and then show once | Token-by-token display; better interactivity |
Good scenarios for wrapper mode:
veadk Agent code and want to deploy quickly.Good scenarios for template mode:
my_project/
+├── my_agent.py # your original Agent definition
+├── agentkit-my_agent.py # wrapper generated by AgentKit (entry point)
+├── requirements.txt # dependencies list (with usage notes)
+├── agentkit.yaml # deployment config (entry_point points to wrapper)
+└── .dockerignore # Docker build ignore rulesWrapper file example (basic type):
# Import your Agent
+from my_agent import agent
+
+from veadk import Runner
+from agentkit.apps import AgentkitSimpleApp
+
+app = AgentkitSimpleApp()
+runner = Runner(agent=agent)
+
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ prompt = payload["prompt"]
+ user_id = headers["user_id"]
+ session_id = headers["session_id"]
+
+ response = await runner.run(
+ messages=prompt,
+ user_id=user_id,
+ session_id=session_id,
+ )
+ return response
+
+
+@app.ping
+def ping() -> str:
+ return "pong!"
+
+
+if __name__ == "__main__":
+ app.run(host="0.0.0.0", port=8000)Q: What if the Agent definition cannot be found?
A: Use --agent-var to explicitly specify the Agent variable name:
agentkit init -f ./my_agent.py --agent-var my_custom_agent_nameQ: Can I modify the generated wrapper?
A: Yes. The wrapper is standard Python code and can be modified as needed. Just make sure @app.entrypoint and @app.ping remain unchanged.
Q: Will the original Agent file be modified?
A: No. The system only copies your file into the target directory; it does not modify the original file.
Q: How do I add extra dependencies in the wrapper project?
A: Edit the generated requirements.txt file and add the dependency packages you need. The file already contains usage notes.
Configure parameters for an Agent application. Three modes are supported: interactive (guided), non-interactive (fast updates), and hybrid (flexible combination).
🆕 Global configuration support: A global configuration file (~/.agentkit/config.yaml) is available to share configuration across projects.
# Project configuration
+agentkit config [arguments] [options]
+
+# Project level: set the cloud provider (volcengine/byteplus)
+agentkit config --cloud_provider byteplus
+
+# Global configuration 🆕
+agentkit config --global [options]Run with no parameters; the wizard guides you step-by-step:
agentkit configInteractive flow example:
[1/7] 🤖 Agent name: my_agent
+[2/7] 📝 Entry point: my_agent.py
+[3/7] 📄 App description: My weather query agent
+[4/7] 🐍 Python version: 3.12
+[5/7] 📦 Dependencies file: requirements.txt
+[6/7] 🚀 Deployment mode (choose one):
+ 1. local - build and run locally
+ 2. hybrid - build locally, run in the cloud
+ 3. cloud - build and run in the cloud (recommended)
+[7/7] 🔐 App-level environment variables (shared by all modes):
+ Variable: MODEL_API_KEY=xxxxxConfigure directly via command-line parameters without manual input:
# Full configuration example
+agentkit config \\
+ --agent_name myAgent \\
+ --entry_point agent.py \\
+ --launch_type cloud \\
+ --cloud_provider byteplus \\
+ --image_tag v1.0.0 \\
+ --runtime_envs API_KEY=xxxxx# Incremental updates (only modify part of the configuration)
+agentkit config --entry_point new_agent.py
+agentkit config --image_tag v1.0.1Specify some parameters via the command line and input the rest interactively:
agentkit config --agent_name myAgent --interactive| Parameter | Description | Example |
|---|---|---|
--agent_name | Agent application name | my_weather_bot |
--entry_point | Entry file (must end with .py) | agent.py |
--description | App description | "Weather assistant" |
--language_version | Language version | 3.12 |
--dependencies_file | Dependencies file | requirements.txt |
--launch_type | Deployment mode | local, hybrid, cloud |
--cloud_provider / --cloud-provider | Cloud provider | volcengine, byteplus |
AgentKit supports two-level environment variable configuration:
| Parameter | Level | Description | Use cases |
|---|---|---|---|
--runtime_envs / -e | App level | Shared across all deployment modes | API keys, model endpoints, cross-environment configuration |
--workflow-runtime-envs | Workflow level | Only applies to the current deployment mode | Debug flags, mode-specific configuration |
Examples:
# App level (shared across all modes)
+agentkit config \\
+ -e API_KEY=shared-key \\
+ -e MODEL_ENDPOINT=https://api.example.com
+
+# Workflow level (current mode only)
+agentkit config \\
+ --workflow-runtime-envs DEBUG=true \\
+ --workflow-runtime-envs LOCAL_CACHE=/tmp
+
+# Mixed usage
+agentkit config \\
+ -e API_KEY=shared \\
+ --workflow-runtime-envs DEBUG=trueMerge rules:
| Parameter | Description | Example |
|---|---|---|
--region | Volcengine region | cn-beijing |
--tos_bucket | TOS bucket | agentkit-bucket |
--image_tag | Image tag | v1.0.0, latest |
--cr_instance_name | CR instance name | my-cr-instance |
--cr_namespace_name | CR namespace | agentkit |
--cr_repo_name | CR repository name | my-agent |
💡 Tip: the
--cr_*parameters also support legacy aliases--ve_cr_*for backward compatibility.
You can use agentkit config to bind (or unbind) runtime resources. When agentkit launch/deploy creates/updates a runtime, the bindings are passed through to the Runtime API.
Supported binding fields:
memory_id: bind a Memoryknowledge_id: bind a Knowledgetool_id: bind a Toolmcp_toolset_id: bind an MCP ToolsetCommand-line examples:
# Bind resources
+agentkit config \\
+ --memory_id mem-xxx \\
+ --knowledge_id kb-xxx \\
+ --tool_id tool-xxx \\
+ --mcp_toolset_id mcp-ts-xxx
+
+# Unbind (set to empty string)
+agentkit config --memory_id ""YAML persisted location (agentkit.yaml):
launch_types:
+ cloud: # or hybrid
+ runtime_bindings:
+ memory_id: mem-xxx
+ knowledge_id: kb-xxx
+ tool_id: tool-xxx
+ mcp_toolset_id: mcp-ts-xxx💡 Unbind semantics:
- Omit a key in config: do not change that binding
- Set to
""ornull: clear/unbind (a clear operation will be sent when updating the Runtime)
You can use agentkit config to set runtime networking (VPC/private network, public network, or dual-stack). This configuration takes effect only when creating a runtime for the first time (CreateRuntime).
⚠️ Limitation: If a runtime already exists,
agentkit launch/deploywill call UpdateRuntime. UpdateRuntime does not support modifyingnetwork_configuration, so this setting will not affect existing runtimes. If you need to change the network, destroy and recreate the runtime.
Command-line example (private network):
agentkit config \\
+ --runtime-network-mode private \\
+ --runtime-vpc-id vpc-xxxxxxxx \\
+ --runtime-subnet-id subnet-aaaaaaaa \\
+ --runtime-enable-shared-internet-accessYAML format (agentkit.yaml):
launch_types:
+ cloud: # or hybrid
+ runtime_network:
+ mode: private # public | private | both
+ vpc_id: vpc-xxxxxxxx # required for private/both
+ enable_shared_internet_access: true # only effective for private/both
+ subnet_ids:
+ - subnet-aaaaaaaamode values:
public: public access onlyprivate: private access only (requires vpc_id)both: enable both public and private access (requires vpc_id)enable_shared_internet_access:
mode is private or both. When enabled, the runtime uses the platform-provided shared public egress to access the public internet.mode=public and this flag is enabled, AgentKit will error to prevent a misleading “configured but not effective” setup.| Option | Description |
|---|---|
--config, -c | Specify the configuration file path (default: agentkit.yaml) |
--interactive, -i | Force interactive mode |
--dry-run | Preview changes without saving |
--show, -s | Show current configuration |
AgentKit supports a global configuration file (~/.agentkit/config.yaml) for sharing configuration across projects.
| Option | Description |
|---|---|
--global, -g | Operate on the global config instead of the project config |
--init | Initialize the global config file (create a template) |
--set | Set a global config field (format: key=value) |
Supported global config fields:
| Field | Description | Example |
|---|---|---|
volcengine.access_key | Volcengine Access Key | AK*** |
volcengine.secret_key | Volcengine Secret Key | SK*** |
volcengine.region | Default region | cn-beijing |
cr.instance_name | CR instance name | team-cr-instance |
cr.namespace_name | CR namespace | agentkit-team |
tos.bucket | TOS bucket name | team-agentkit-builds |
tos.prefix | TOS object prefix | agentkit-builds |
tos.region | TOS region | cn-beijing |
Configuration precedence:
Environment variables > Project config (agentkit.yaml) > Global config > Defaultsagentkit config# Update entry point
+agentkit config --entry_point new_agent.py
+
+# Update image tag
+agentkit config --image_tag v1.0.1
+
+# Add an environment variable
+agentkit config -e NEW_KEY=new_valueagentkit config \\
+ --agent_name weather-bot \\
+ --entry_point agent.py \\
+ --description "Weather assistant" \\
+ --launch_type cloud \\
+ --image_tag v1.0.0 \\
+ --region cn-beijing \\
+ -e API_KEY=xxxxx \\
+ -e MODEL_ENDPOINT=https://api.example.com# Show changes but do not save
+agentkit config --entry_point agent.py --image_tag v2.0 --dry-runExample output:
General config - changes:
+┌──────────────┬──────────────┬──────────────┐
+│ Config item │ Old value │ New value │
+├──────────────┼──────────────┼──────────────┤
+│ entry_point │ old_agent.py │ agent.py │
+│ image_tag │ v1.0 │ v2.0 │
+└──────────────┴──────────────┴──────────────┘
+
+🔍 Dry-run: no changes were savedagentkit config --showInitialize global configuration:
# Create a global config template
+agentkit config --global --initOutput:
✅ Global configuration file created: ~/.agentkit/config.yaml
+
+📝 A template has been generated containing the following fields:
+
+🔐 Volcengine credentials
+ access_key: ''
+ secret_key: ''
+ region: cn-beijing
+
+📦 CR configuration
+ instance_name: ''
+ namespace_name: ''
+
+🗂️ TOS configuration
+ bucket: ''
+ prefix: agentkit-builds
+ region: cn-beijingShow global configuration:
agentkit config --global --showSet global configuration:
# Set a single field
+agentkit config --global --set cr.instance_name=team-cr-instance
+agentkit config --global --set tos.bucket=team-bucket
+
+# Set credentials
+agentkit config --global --set volcengine.access_key=AK***
+agentkit config --global --set volcengine.secret_key=SK***Team collaboration scenario:
# 1. Team admin creates and shares global configuration
+agentkit config --global --init
+vim ~/.agentkit/config.yaml # fill in team-shared configuration
+
+# 2. Team members automatically use global config when initializing projects
+agentkit init my-agent
+# related fields in agentkit.yaml are left empty; global config is used at runtime
+
+# 3. Special projects can override global configuration in agentkit.yaml
+agentkit config --cr_instance_name special-cr # override global config# Use in CI/CD pipelines
+agentkit config \\
+ --agent_name \${CI_PROJECT_NAME} \\
+ --entry_point agent.py \\
+ --launch_type cloud \\
+ --image_tag \${CI_COMMIT_TAG} \\
+ -e DEPLOY_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
+
+agentkit launchIn interactive mode, environment variable configuration supports convenience commands:
🔐 App-level environment variables (enter KEY=VALUE; empty line to finish)
+
+ Available commands:
+ - Enter KEY=VALUE to add a variable
+ - Enter 'list' to show existing variables
+ - Enter 'del KEY' to delete a variable
+ - Enter 'clear' to clear all
+ - Press Enter on an empty line to finish
+
+Variable: MODEL_API_KEY=xxxxx
+✅ Added: MODEL_API_KEY
+
+Variable: list
+Current variables:
+ MODEL_API_KEY=xxxxx
+
+Variable: [press Enter to finish]
+📋 Configured 1 shared variableAll configuration is validated automatically:
.pylocal, hybrid, or cloudValidation failures show detailed errors and exit.
Use interactive mode for first-time setup for a guided experience
agentkit configUse non-interactive mode for daily updates for speed and efficiency
agentkit config --entry_point new_agent.pyUse non-interactive mode in CI/CD for full automation
agentkit config --agent_name $PROJECT --image_tag $TAGPreview before applying to avoid mistakes
agentkit config --entry_point agent.py --dry-runManage environment variables by level:
Use global config for team collaboration 🆕:
# Team admin
+agentkit config --global --init
+agentkit config --global --set cr.instance_name=team-cr
+agentkit config --global --set tos.bucket=team-bucket
+
+# Team members
+agentkit init my-agent # automatically uses global config
+agentkit launch # automatically uses global config at runtimeUnderstand configuration precedence:
Environment variables > Project config > Global config > DefaultsPackage your Agent code into a Docker image in preparation for deployment.
agentkit build [options]--config-file configuration file path
agentkit.yaml--platform build platform
auto (auto-detect)--regenerate-dockerfile force regenerate Dockerfile
FalseAgentKit supports customizing Docker image builds via the docker_build section. Add the following to agentkit.yaml.
base_image - custom base image
Python projects (string form):
docker_build:
+ base_image: "python:3.12-slim"
+ # Or use an Alpine image
+ base_image: "python:3.12-alpine"build_script - custom build script
docker_build:
+ build_script: "scripts/setup.sh"Python project example:
agent_name: my-agent
+entry_point: agent.py
+language: Python
+language_version: "3.12"
+dependencies_file: requirements.txt
+launch_type: local
+
+# Docker build customization
+docker_build:
+ base_image: "python:3.12-alpine"
+ build_script: "scripts/setup.sh"Build script example (scripts/setup.sh):
#!/bin/bash
+# Install system dependencies
+apt-get update && apt-get install -y gcc g++ libpq-dev
+# Or on Alpine: apk add --no-cache gcc musl-dev postgresql-dev
+
+echo "Custom build script completed"| Scenario | Configuration | Example |
|---|---|---|
| Use a lightweight image | Specify an Alpine base image | base_image: "python:3.12-alpine" |
| Install system dependencies | Write a build script | build_script: "scripts/install_deps.sh" |
| Compile C extensions | Install a build toolchain | Install gcc, g++, etc. in the script |
| Configure certificates | Update CA certificates | Run update-ca-certificates in the script |
| Multi-stage builds | Specify builder and runtime separately | Golang projects only |
.agentkit/dockerfile_backups/)--regenerate-dockerfile to force regenerationExample metadata header:
# ============================================================================
+# AUTO-GENERATED by AgentKit v1.x.x
+# ============================================================================
+# Source: agentkit.yaml
+# Checksum: sha256:...
+# Generated: 2025-01-17T10:30:00
+#
+# This file is automatically generated and managed by AgentKit:
+# - It will be auto-updated when agentkit.yaml config changes
+# - To fully customize, remove this header comment
+# ============================================================================The build strategy is chosen automatically based on launch_type:
Build with Docker on your machine:
🔨 Starting local image build...
+[1/3] Generating Dockerfile...
+[2/3] Building Docker image...
+[3/3] Verifying image availability...
+✅ Build succeeded: my-agent:latestEstimated time: 1–3 minutes.
Build automatically on Volcengine:
🔨 Starting cloud build...
+[1/6] Generating Dockerfile...
+[2/6] Packaging project code...
+[3/6] Uploading to object storage...
+[4/6] Preparing image registry...
+[5/6] Creating build pipeline...
+[6/6] Executing build task...
+✅ Build succeeded: xxx.cr.volces.com/agentkit/my-agent:latestEstimated time: 3–5 minutes.
{agent_name}:{image_tag}# Example 1: build with default configuration
+agentkit build
+
+# Example 2: specify config file
+agentkit build --config-file ./prod.yaml
+
+# Example 3: force regenerate Dockerfile
+agentkit build --regenerate-dockerfile
+
+# Example 4: force refresh after config changes
+agentkit build --config-file ./prod.yaml --regenerate-dockerfileExample 5: use an Alpine base image
agentkit.yaml:docker_build:
+ base_image: "python:3.12-alpine"
+ build_script: "scripts/alpine-setup.sh"scripts/alpine-setup.sh:#!/bin/sh
+apk add --no-cache gcc musl-dev postgresql-devagentkit buildExample 6: install system dependencies (C extensions)
agentkit.yaml:docker_build:
+ build_script: "scripts/install-deps.sh"scripts/install-deps.sh:#!/bin/bash
+apt-get update && apt-get install -y \\
+ gcc g++ \\
+ libpq-dev \\
+ libxml2-dev \\
+ libxslt1-devagentkit buildExample 7: Golang multi-stage build
Modify agentkit.yaml:
docker_build:
+ base_image:
+ builder: "golang:1.24-alpine"
+ runtime: "alpine:3.19"
+ build_script: "scripts/install-certs.sh"Build:
agentkit buildLocal mode prerequisites:
Cloud mode prerequisites:
Docker build customization:
.agentkit/dockerfile_backups/Tip: build metadata will be written back to the config file for use by the deploy command.
Deploy the built image and start the Agent to serve requests.
agentkit deploy [options]--config-file Configuration file path
agentkit.yamlAutomatically selects the deployment target based on the configured launch_type:
Starts the container on your local machine:
🚀 Starting deployment to local Docker...
+[1/3] Stopping old container version...
+[2/3] Starting new container...
+[3/3] Verifying container status...
+✅ Deployment successful! Container is running
+🌐 Access URL: http://localhost:8000Estimated time: 10-30 seconds
Creates a Runtime on Volcengine:
🚀 Starting deployment to cloud platform...
+✅ Generated Runtime name: my-agent-20250120-abc123
+✅ Created Runtime: r-xxxxxx
+⏳ Waiting for Runtime to be ready...
+✅ Runtime is ready!
+🌐 Access URL: http://xxx.apigateway-cn-beijing.volceapi.comEstimated time: 1-2 minutes
# Example 1: Deploy to default environment
+agentkit deploy
+
+# Example 2: Deploy to production environment
+agentkit deploy --config-file ./prod.yamlLocal Mode:
localhost:portCloud Mode:
Build + Deploy in one step! Equivalent to automatically running build then deploy.
agentkit launch [options]--config-file Configuration file path
agentkit.yaml🚀 Starting Agent launch...
+
+━━━ Step 1: Build Image ━━━
+🔨 Reading config: agentkit.yaml
+🔨 Starting build...
+✅ Build completed
+
+━━━ Step 2: Deploy Application ━━━
+🚀 Starting deployment...
+✅ Deployment completed
+
+✨ Agent launched successfully!# Example 1: One-click launch
+agentkit launch
+
+# Example 2: Launch to production environment
+agentkit launch --config-file ./prod.yamlSend a test request to a deployed Agent to verify functionality.
agentkit invoke [message content] [options]⚠️ Important: You must provide either message content or the --payload option, but not both
Message Content
{"prompt": "your message"}--payloadagentkit invoke "hello" or agentkit invoke "how's the weather today?"Options
--payload, -p Custom request data
--payload '{"prompt": "hello", "context": "greeting"}'--headers, -h Custom request headers
user_id and session_id by default--headers '{"user_id": "test123"}'--raw Output raw response (for debugging)
agentkit invoke "hello" --raw--show-reasoning Output reasoning content (for LangChain debugging)
additional_kwargs.reasoning_content, incrementally prints this fieldagentkit invoke "1+1=?" --show-reasoning--apikey, -ak API Key
--config-file Configuration file path
agentkit.yaml in current directoryagentkit invoke "How's the weather in Hangzhou today?"Equivalent to sending the following JSON:
{
+ "prompt": "How's the weather in Hangzhou today?"
+}agentkit invoke --payload '{"prompt": "Hangzhou weather?", "user_location": "Hangzhou"}'agentkit invoke \\
+ --payload '{"prompt": "Hangzhou weather?"}' \\
+ --headers '{"user_id": "user123", "session_id": "sess456"}'agentkit invoke "hello" --apikey your_api_key_here💬 Calling Agent...
+✅ Runtime ID: r-xxxxxx
+🌐 Calling address: http://xxx.apigateway-cn-beijing.volceapi.com
+✅ Call successful!
+
+📡 Agent response:
+Hangzhou is sunny today, 22°C, great for going out.--payload are mutually exclusiveagentkit status)View the Agent's running status, including whether it's online, access URL, and other information.
agentkit status [options]--config-file Configuration file path
agentkit.yaml✅ Container name: my-agent
+✅ Running status: running
+🌐 Access URL: http://localhost:8000
+
+Details:
+{
+ "container_id": "abc123...",
+ "status": "running",
+ "ports": ["8000:8000"],
+ "created": "2025-01-20 10:00:00",
+ "health": "healthy"
+}✅ Runtime ID: r-xxxxxx
+✅ Running status: Ready
+🌐 Access URL: http://xxx.apigateway-cn-beijing.volceapi.com
+
+Details:
+{
+ "runtime_id": "r-xxxxxx",
+ "runtime_name": "my-agent-20250120-abc123",
+ "status": "Ready",
+ "endpoint": "http://xxx.apigateway-cn-beijing.volceapi.com",
+ "image": "xxx.cr.volces.com/agentkit/my-agent:latest",
+ "created_at": "2025-01-20 10:00:00"
+}Local Mode Status:
running - Running normallystopped - Stoppedrestarting - Restartingerror - Error occurredCloud Mode Status:
Ready - Ready to receive requestsReleasing - DeployingError - Runtime errorFailed - Deployment failed# Example 1: View current status
+agentkit status
+
+# Example 2: View production environment status
+agentkit status --config-file ./prod.yamlStop and delete the Agent instance, releasing resources. ⚠️ This operation is irreversible!
agentkit destroy [options]--force Force delete
--config-file Configuration file path
agentkit.yamlBy default, you will be asked to confirm the operation:
🗑️ Preparing to destroy running Agent...
+⚠️ This operation cannot be undone!
+Are you sure you want to continue? [y/N]: ySkip confirmation (not recommended):
agentkit destroy --force🗑️ Starting to destroy Agent resources...
+✅ Stopped Runtime: r-xxxxxx
+✅ Runtime deleted successfully
+✅ Resources cleaned up
+
+Tip: Configuration file and images are retained, can redeploy anytime.# Example 1: Safe deletion (recommended)
+agentkit destroy
+
+# Example 2: Force deletion
+agentkit destroy --force
+
+# Example 3: Delete specified environment
+agentkit destroy --config-file ./dev.yamlagentkit.yaml file will not be deletedagentkit deployAll commands support these options:
View detailed descriptions and parameters for any command:
# View help for a specific command
+agentkit invoke --help
+agentkit build --help
+
+# View list of all commands
+agentkit --helpDisplay CLI version information:
agentkit --version
+# or
+agentkit -vAgentKit CLI provides rich platform service management commands for managing Memory, Knowledge, Tools, and Runtime resources.
agentkit memory Manage AgentKit Memory collections, supporting create, view, update, and delete operations.
# Create memory collection (default provider-type: MEM0)
+agentkit memory create --name my-memory --description "My memory collection"
+
+# Add external memory collection
+agentkit memory add --provider-collection-id <id> --provider-type VIKINGDB_MEMORY --name my-external-memory
+
+# List all memory collections (supports pagination and filtering)
+agentkit memory list
+agentkit memory list --name-contains "my" --limit 10
+
+# View memory collection details
+agentkit memory show -m <id>
+
+# Update memory collection
+agentkit memory update -m <id> --description "Updated description"
+
+# Delete memory collection
+agentkit memory delete -m <id>
+
+# Get connection information
+agentkit memory conn -m <id>
+
+# View supported Provider types
+agentkit memory provider-typesagentkit knowledge Manage AgentKit Knowledge bases, supporting CRUD operations.
# Add knowledge base (connect external knowledge base)
+agentkit knowledge add --name my-kb --provider-knowledge-id <id> --provider-type VIKINGDB_KNOWLEDGE
+
+# List all knowledge bases (supports pagination and filtering)
+agentkit knowledge list
+agentkit knowledge list --status Ready
+
+# View knowledge base details
+agentkit knowledge show -k <id>
+
+# Update knowledge base
+agentkit knowledge update -k <id> --description "Updated description"
+
+# Delete knowledge base
+agentkit knowledge delete -k <id>
+
+# Get connection information
+agentkit knowledge conn -k <id>
+
+# View supported Provider types
+agentkit knowledge provider-typesagentkit tools Manage AgentKit Tools and Sessions, including tool lifecycle management and session operations.
# Tool management
+# Create tool (needs to specify tool-type)
+agentkit tools create --name my-tool --tool-type <type> --description "My tool"
+# List tools (supports pagination and filtering)
+agentkit tools list
+# View tool details
+agentkit tools show -t <id>
+# Update tool
+agentkit tools update -t <id> --description "New description"
+# Delete tool
+agentkit tools delete -t <id>
+
+# Session management
+# Create session
+agentkit tools session create -t <id> --name my-session --ttl 30 --ttl-unit minute
+# List sessions
+agentkit tools session list -t <id>
+# View session details
+agentkit tools session show -t <id> -s <session_id>
+# Get session logs
+agentkit tools session logs -t <id> -s <session_id>
+# Set session TTL
+agentkit tools session set-ttl -t <id> -s <session_id> --ttl 60 --ttl-unit minute
+# Delete session
+agentkit tools session delete -t <id> -s <session_id>agentkit runtime Manage AgentKit Runtime instances, supporting runtime create, update, delete, and version management.
# Create runtime (needs to specify artifact info)
+agentkit runtime create \\
+ --name my-runtime \\
+ --role-name <role> \\
+ --artifact-type DockerImage \\
+ --artifact-url <url> \\
+ --description "My runtime"
+
+# Create runtime and associate resources
+agentkit runtime create \\
+ --name my-runtime \\
+ --role-name <role> \\
+ --artifact-type DockerImage \\
+ --artifact-url <url> \\
+ --memory-id mem-xxx \\
+ --knowledge-id kb-xxx \\
+ --tool-id tool-xxx \\
+ --mcp-toolset-id mcp-ts-xxx
+
+# Create runtime with private network access (VPC)
+agentkit runtime create \\
+ --name my-runtime \\
+ --role-name <role> \\
+ --artifact-type DockerImage \\
+ --artifact-url <url> \\
+ --vpc-id vpc-xxxxxxxx \\
+ --subnet-ids subnet-aaaaaaaa \\
+ --enable-private-network \\
+ --enable-public-network false
+
+# List all runtimes (supports pagination and filtering)
+agentkit runtime list
+
+# View runtime details
+agentkit runtime get -r <id>
+
+# Update runtime
+agentkit runtime update -r <id> --description "New description"
+
+> 💡 Tip: \`agentkit runtime update\` currently only supports updating artifact/description/env/tags and resource binding fields (\`memory-id/knowledge-id/tool-id/mcp-toolset-id\`), network configuration cannot be modified.
+
+# Delete runtime
+agentkit runtime delete -r <id>
+
+# Release new version
+agentkit runtime release -r <id> --version-number <version>
+
+# View specific version details
+agentkit runtime version -r <id> --version-number <version>
+
+# List all versions
+agentkit runtime versions -r <id>Complete steps from zero to production:
# 1️⃣ Create project
+agentkit init weather_agent --template basic
+cd weather_agent
+
+# 2️⃣ Configure app
+agentkit config
+
+# 3️⃣ One-click deploy
+agentkit launch
+
+# 4️⃣ Test functionality
+agentkit invoke "How's the weather in Hangzhou?"
+
+# 5️⃣ Check status
+agentkit statusQuickly deploy an existing Agent:
# 1️⃣ Wrap existing Agent file
+agentkit init --from-agent ~/my_projects/weather_agent.py
+
+# 2️⃣ Enter project directory
+cd agentkit-weather_agent
+
+# 3️⃣ (Optional) Configure app
+agentkit config
+
+# 4️⃣ One-click deploy
+agentkit launch
+
+# 5️⃣ Test functionality
+agentkit invoke "How's the weather today?"
+
+# 6️⃣ Check status
+agentkit statusUpdate workflow after code changes:
# Method 1: Step-by-step (recommended for debugging)
+agentkit build # Rebuild
+agentkit deploy # Redeploy
+agentkit invoke "test" # Test validation
+
+# Method 2: One-click update (recommended for daily development)
+agentkit launch # Auto build+deploy
+agentkit invoke "test" # Test validationSwitch between dev, test, and production environments:
# Development environment
+agentkit launch --config-file agentkit.dev.yaml
+agentkit invoke "test" --config-file agentkit.dev.yaml
+
+# Production environment
+agentkit launch --config-file agentkit.prod.yaml
+agentkit invoke "test" --config-file agentkit.prod.yamlDon't panic when you encounter errors, here are solutions!
Error: Configuration file not found: agentkit.yamlCause: No configuration file in current directory
Solution:
# If new project
+agentkit init my_agent
+
+# If existing project
+agentkit configError: Docker daemon not runningCause: Docker service not started
Solution:
sudo systemctl start dockerError: VOLC_ACCESSKEY or VOLC_SECRETKEY not setCause: Volcengine AK/SK not set
Solution:
# Recommended: Use secure global config
+agentkit config --global --init
+agentkit config --global --set volcengine.access_key="your AccessKey"
+agentkit config --global --set volcengine.secret_key="your SecretKey"
+
+# Or: Temporary environment variables (for dev/debugging)
+export VOLC_ACCESSKEY="your AccessKey"
+export VOLC_SECRETKEY="your SecretKey"❌ Build failed: ...Possible causes and solutions:
requirements.txt is correct1. View detailed logs
# Set verbose log level
+export LOG_LEVEL=DEBUG
+agentkit build2. Verify configuration file
# Check if configuration is correct
+cat agentkit.yaml3. Execute step by step
# Execute separately, easier to locate issues
+agentkit build # Build first
+agentkit deploy # Then deploy
+# Instead of using launch directly4. Check running status
# Check if Agent is running normally
+agentkit statusagentkit.yaml is the core configuration file for your Agent. It contains all runtime parameters. This document explains what each configuration field does.
AgentKit uses a two-level configuration architecture:
| Config file | Location | Purpose |
|---|---|---|
| Project config | ./agentkit.yaml | Project-level config. Each Agent project is independent. |
| Global config | ~/.agentkit/config.yaml | User-level config shared across projects (for example, Volcengine credentials). |
Precedence:
Environment variables > Project config > Global config > DefaultsThe project config file has three sections:
common:
+ # Base config (shared by all launch types)
+ agent_name: my_agent
+ entry_point: my_agent.py
+ language: Python
+ launch_type: cloud
+ runtime_envs: {} # App-level environment variables
+
+launch_types:
+ local:
+ # Local-only settings
+ hybrid:
+ # Hybrid-only settings
+ cloud:
+ # Cloud-only settings
+
+docker_build:
+ # Docker build config (optional)
+ base_image: python:3.12-slim
+ build_script: scripts/setup.shThe three sections:
common Base configuration required by all deployment modes.
common:
+ agent_name: my_weather_agent # Agent name (required)
+ entry_point: my_weather_agent.py # Entry file (required)
+ description: Weather query agent # Description (optional)
+ language: Python # Programming language
+ language_version: '3.12' # Language version
+ dependencies_file: requirements.txt # Dependency file
+ launch_type: cloud # Launch type
+ runtime_envs: # App-level env vars (shared by all launch types)
+ LOG_LEVEL: infoagent_name (required) The Agent name
_, and -Examples:
agent_name: weather_agent # Recommended: simple and clear
+agent_name: financial-analyzer-v2 # OK: includes a version
+agent_name: customer_support_bot # OK: descriptiveentry_point (required) The entry file for your Agent code
.py, .go, or .shExamples:
# Python project
+entry_point: app.py
+entry_point: server.py
+
+# Go project
+entry_point: main.go
+entry_point: cmd/server/main.go
+
+# Custom startup script
+entry_point: start.shdescription (optional) A description of the Agent
Examples:
description: "Weather query agent for major cities nationwide"
+description: "Customer support assistant for common questions"language (optional) Programming language
Python, GolangPythonExamples:
language: Python # Python project
+language: Golang # Go projectlanguage_version (optional) Language runtime version
3.10, 3.11, 3.12, 3.131.243.12, Golang 1.24Examples:
# Python project
+language: Python
+language_version: '3.12'
+
+# Go project
+language: Golang
+language_version: '1.24'⚠️ Note:
python_versionis deprecated. Uselanguage_versioninstead.
dependencies_file (optional) Dependency list file
requirements.txt for Python projects; go.mod for Go projectsExamples:
# Python project
+dependencies_file: requirements.txt
+dependencies_file: requirements/prod.txt
+
+# Go project
+dependencies_file: go.modlaunch_type (required) Deployment and runtime mode
local, hybrid, cloud| Mode | Best for | Build location | Run location |
|---|---|---|---|
local | local development & debugging | your machine | your machine |
hybrid | transition phase | your machine | cloud platform |
cloud | production | cloud platform | cloud platform |
Examples:
launch_type: local # local development
+launch_type: hybrid # build locally + deploy to cloud
+launch_type: cloud # production (recommended)cloud_provider (optional) Cloud provider (platform service provider)
volcengine, byteplusvolcenginedocker_build.base_image is not explicitly set)Precedence (highest to lowest):
Environment variables > Project config (agentkit.yaml) > Global config (~/.agentkit/config.yaml) > DefaultsHow to configure:
# 1) Project config (recommended: put it in agentkit.yaml)
+common:
+ cloud_provider: byteplus# 1.1) Project config (write to agentkit.yaml via non-interactive command)
+agentkit config --cloud_provider byteplus# 2) Global config (applies across projects)
+defaults:
+ cloud_provider: byteplus# 3) Environment variables (temporary override)
+export CLOUD_PROVIDER=byteplusruntime_envs (optional) App-level environment variables
runtime_envs override variables with the same name defined at the app levelExample:
common:
+ runtime_envs:
+ LOG_LEVEL: info
+ APP_ENV: productionBuild and run on local Docker. Best for development and debugging.
launch_types:
+ local:
+ image_tag: latest # Image tag
+ invoke_port: 8000 # App port
+ container_name: my_agent # Container name (optional)
+ runtime_envs: # Policy-level env vars
+ MODEL_AGENT_API_KEY: xxx
+ ports: # Port mappings
+ - "8000:8000"
+ restart_policy: unless-stopped # Restart policy
+ memory_limit: 1g # Memory limit
+ cpu_limit: '1' # CPU limitimage_tag Image version tag
latestlatest, v1.0, devinvoke_port The port your Agent listens on
8000container_name Docker container name
agent_nameruntime_envs Policy-level runtime environment variables
Environment variables passed into the container, such as API keys and configuration parameters. They are merged with common.runtime_envs; variables with the same name override the app-level ones.
runtime_envs:
+ MODEL_AGENT_API_KEY: your_api_key # Model API key
+ DEBUG: 'true' # Enable debugging
+ LOG_LEVEL: debug # Override LOG_LEVEL from commonports Port mappings
Maps container ports to host ports using host_port:container_port.
ports:
+ - "8080:8000" # Host 8080 maps to container 8000
+ - "9090:9090" # Monitoring portvolumes Volume mounts
Mounts host directories into the container using host_path:container_path.
volumes:
+ - "./data:/app/data" # Data directory
+ - "./logs:/app/logs" # Log directoryrestart_policy Container restart policy
unless-stoppedno - do not restarton-failure - restart on failuresalways - always restartunless-stopped - restart unless manually stoppedmemory_limit / cpu_limit Resource limits
Limits the resources a container can use, preventing it from consuming too much.
memory_limit: 2g # Limit to 2GB memory
+cpu_limit: '1' # Limit to 1 CPU coreThe following fields are generated and managed by the CLI; you do not need to set them manually:
| Field | Description |
|---|---|
container_id | Container ID after deployment |
image_id | Image ID after build |
build_timestamp | Build time |
deploy_timestamp | Deployment time |
full_image_name | Full image name (e.g. my-agent:latest) |
Build and run on Volcengine. Best for production.
launch_types:
+ cloud:
+ region: cn-beijing # Region
+ image_tag: "{{timestamp}}" # Image tag (template variables supported)
+
+ # TOS (object storage) settings
+ tos_bucket: Auto # Auto-create bucket
+
+ # Container Registry settings
+ cr_instance_name: Auto # CR instance name (Auto = auto-create)
+ cr_namespace_name: agentkit # CR namespace
+ cr_repo_name: "" # CR repo name (empty = use agent_name)
+
+ # Runtime settings
+ runtime_name: Auto # Runtime name
+ runtime_role_name: Auto # IAM role name
+ runtime_apikey_name: Auto # API key secret name
+
+ # Environment variables
+ runtime_envs:
+ MODEL_AGENT_API_KEY: xxx # Model API key
+ MODEL_AGENT_NAME: ep-xxx # Model endpointCloud mode supports template variables, rendered automatically during build/deploy:
`,114)),s("table",r,[i[4]||(i[4]=s("thead",null,[s("tr",null,[s("th",null,"Variable"),s("th",null,"Description"),s("th",null,"Example value")])],-1)),s("tbody",null,[s("tr",null,[s("td",null,[s("code",null,e(n.timestamp),1)]),i[0]||(i[0]=s("td",null,"Current timestamp (YYYYMMDDHHmmss)",-1)),i[1]||(i[1]=s("td",null,[s("code",null,"20251128153042")],-1))]),s("tr",null,[s("td",null,[s("code",null,e(n.account_id),1)]),i[2]||(i[2]=s("td",null,"Volcengine account ID",-1)),i[3]||(i[3]=s("td",null,[s("code",null,"2100123456")],-1))])])]),i[38]||(i[38]=t('Examples:
image_tag: "{{timestamp}}" # Unique tag for each build\ncr_instance_name: "agentkit-platform-{{account_id}}" # Account-isolated CR instance\ntos_bucket: "agentkit-platform-{{account_id}}" # Account-isolated bucketAuto keyword When a value is Auto, the CLI will automatically create or manage the corresponding resource:
region Volcengine region
cn-beijingcn-beijing (currently only Beijing is supported)💡 Tip: choose the region closest to your users to reduce latency.
image_tag Image version tag
',7)),s("ul",null,[s("li",null,[i[13]||(i[13]=a("Default: ",-1)),s("code",null,e(n.timestamp),1),i[14]||(i[14]=a(" (generates a unique tag each build)",-1))]),i[20]||(i[20]=s("li",null,"Purpose: distinguishes different versions",-1)),s("li",null,[i[15]||(i[15]=a("Examples: ",-1)),s("code",null,e(n.timestamp),1),i[16]||(i[16]=a(", ",-1)),i[17]||(i[17]=s("code",null,"latest",-1)),i[18]||(i[18]=a(", ",-1)),i[19]||(i[19]=s("code",null,"v1.0.0",-1))])]),i[40]||(i[40]=t(`# Option 1: use a timestamp (recommended; ensures uniqueness)
+image_tag: "{{timestamp}}"
+
+# Option 2: fixed version
+image_tag: v1.0.0
+
+# Option 3: use latest (not recommended for production)
+image_tag: latesttos_bucket Object storage bucket
Auto (auto-create)tos_bucket must belong to your current account. If you set another person's bucket name (e.g. a public read-write bucket), the CLI will block uploads and ask you to change it.# Auto-create (recommended)
+tos_bucket: Auto
+
+# Use an existing bucket
+tos_bucket: my-existing-bucketcr_instance_name Container Registry instance name
Auto (auto-create)# Auto-create
+cr_instance_name: Auto
+
+# Use an existing instance
+cr_instance_name: my-existing-crcr_namespace_name CR namespace
agentkitcr_repo_name CR repository name
agent_name)runtime_name / runtime_role_name / runtime_apikey_name Runtime-related settings
Auto (auto-create)runtime_name: Auto # Runtime name
+runtime_role_name: Auto # IAM role
+runtime_apikey_name: Auto # API key secret nameruntime_envs Policy-level runtime environment variables
Configuration required by the Agent at runtime. The most important values are model API credentials. They are merged with common.runtime_envs.
Required:
runtime_envs:
+ MODEL_AGENT_API_KEY: xxx # Volcano Ark API key
+ MODEL_AGENT_NAME: ep-xxx # Volcano Ark endpoint IDOptional (enhanced capabilities):
runtime_envs:
+ # Base settings
+ MODEL_AGENT_API_KEY: xxx
+ MODEL_AGENT_NAME: ep-xxx
+
+ # Observability (logs, metrics, tracing)
+ OBSERVABILITY_OPENTELEMETRY_APMPLUS_API_KEY: xxx
+ OBSERVABILITY_OPENTELEMETRY_APMPLUS_ENDPOINT: http://apmplus-cn-beijing.volces.com:4317
+ OBSERVABILITY_OPENTELEMETRY_APMPLUS_SERVICE_NAME: my_agent
+
+ # Other settings
+ DEBUG: 'true' # Enable debug mode
+ LOG_LEVEL: info # Set log levelbuild_timeout Build timeout
3600 (seconds)The following fields are generated and managed by the CLI; you do not need to set them manually:
TOS storage-related
| Field | Description |
|---|---|
tos_prefix | Object storage prefix (default agentkit-builds) |
tos_region | TOS region |
tos_object_key | Storage path for the code package |
tos_object_url | URL for the code package |
Code Pipeline build-related
| Field | Description |
|---|---|
cp_workspace_name | Build workspace name |
cp_pipeline_name | Build pipeline name |
cp_pipeline_id | Pipeline ID |
Image-related
| Field | Description |
|---|---|
cr_region | Image registry region |
cr_image_full_url | Full image URL |
Runtime-related
| Field | Description |
|---|---|
runtime_id | Runtime instance ID |
runtime_endpoint | Application access URL |
runtime_apikey | Runtime API key |
build_timestamp | Build time |
deploy_timestamp | Deployment time |
Build locally and run in the cloud. This is useful during development and debugging: you can build images quickly on your machine and then run them on the cloud.
launch_types:
+ hybrid:
+ region: cn-beijing # Cloud region
+ image_tag: "{{timestamp}}" # Image tag (template variables supported)
+
+ # Container Registry settings
+ cr_instance_name: Auto # CR instance name
+ cr_namespace_name: agentkit # CR namespace
+ cr_repo_name: "" # CR repo name
+
+ # Runtime settings
+ runtime_name: Auto # Runtime name
+ runtime_role_name: Auto # IAM role name
+ runtime_apikey_name: Auto # API key secret name
+
+ # Environment variables
+ runtime_envs:
+ MODEL_AGENT_API_KEY: xxx # Model API key
+ MODEL_AGENT_NAME: ep-xxx # Model endpoint| Item | Hybrid | Cloud |
|---|---|---|
| Build location | Local Docker | Cloud Code Pipeline |
| TOS settings | Not required | Required (stores the code package) |
| Build speed | Fast (local) | Slower (upload + cloud build) |
| Best for | Development & debugging | Production |
Hybrid mode is largely the same as Cloud mode, but does not require TOS-related settings (because local builds do not upload a source archive).
region Volcengine region
cn-beijingimage_tag Image version tag
`,53)),s("ul",null,[s("li",null,[i[21]||(i[21]=a("Default: ",-1)),s("code",null,e(n.timestamp),1)]),i[22]||(i[22]=s("li",null,"Purpose: distinguishes different image versions",-1)),i[23]||(i[23]=s("li",null,"Template variables supported",-1))]),i[41]||(i[41]=t(`cr_instance_name / cr_namespace_name / cr_repo_name Container Registry settings
Same as Cloud mode. Used to store the locally built image.
cr_instance_name: Auto # Auto-create CR instance
+cr_namespace_name: agentkit # Namespace
+cr_repo_name: "" # Repo name (empty = use agent_name)runtime_name / runtime_role_name / runtime_apikey_name Runtime settings
Same as Cloud mode. Used to manage the cloud runtime instance.
runtime_envs Policy-level runtime environment variables
Same as Cloud mode. Environment variables passed to the cloud runtime.
The following fields are generated and managed by the CLI; you do not need to set them manually:
| Field | Description |
|---|---|
image_id | Image ID built locally |
build_timestamp | Build time |
full_image_name | Full image name |
cr_image_full_url | Full image URL in CR |
runtime_id | Runtime instance ID |
runtime_endpoint | Application access URL |
runtime_apikey | Runtime API key |
docker_build Customize the Docker build process. Supports custom base images, build scripts, and more.
docker_build:
+ # Python project - string form
+ base_image: "python:3.12-slim"
+
+ # Custom build script
+ build_script: "scripts/setup.sh"
+
+ # Force regenerate Dockerfile
+ regenerate_dockerfile: false
+
+ # Target platform (cross-platform builds)
+ platform: "linux/amd64"Multi-stage build for Go projects:
docker_build:
+ base_image:
+ builder: "golang:1.24-alpine" # Builder stage image
+ runtime: "alpine:latest" # Runtime stage image
+ build_script: "scripts/install_certs.sh"base_image Custom base image
common.cloud_provideragentkit-prod-public-cn-beijing.cr.volces.com/base/py-simple:python<version>-bookworm-slim-latestagentkit-prod-public-ap-southeast-1.cr.bytepluses.com/base/py-simple:python<version>-bookworm-slim-latestagentkit-cn-beijing.cr.volces.com/base/compile_basego:1.24 (build) + agentkit-cn-beijing.cr.volces.com/base/runtime_basego:latest (runtime)# Python project - string
+base_image: "python:3.12-alpine"
+
+# Go project - mapping (multi-stage build)
+base_image:
+ builder: "golang:1.24-alpine"
+ runtime: "alpine:latest"build_script Custom build script
Typical use cases:
build_script: "scripts/setup.sh"
+build_script: "docker/install_deps.sh"regenerate_dockerfile Force regenerate Dockerfile
false--regenerate-dockerfileplatform Target CPU architecture
--platformplatform: "linux/amd64" # x86_64
+platform: "linux/arm64" # ARM (e.g. Apple Silicon)Global configuration is stored in ~/.agentkit/config.yaml and shared across projects.
~/.agentkit/config.yaml# Volcengine credentials
+volcengine:
+ access_key: "AKLTxxxxxxxx"
+ secret_key: "xxxxxxxx"
+ region: "cn-beijing"
+
+# Default Container Registry settings
+cr:
+ instance_name: "my-team-cr-instance"
+ namespace_name: "my-team"
+
+# Default TOS settings
+tos:
+ bucket: "my-team-bucket"
+ prefix: "agentkit-builds"
+ region: "cn-beijing"When a project config value is empty or set to Auto, AgentKit will automatically fall back to global config:
1. Explicit values in project config (highest)
+2. Global config (~/.agentkit/config.yaml)
+3. Defaults (lowest)Shared team configuration
Teammates can share the same CR instance and TOS bucket:
# ~/.agentkit/config.yaml
+cr:
+ instance_name: "team-shared-cr"
+ namespace_name: "team-agents"
+
+tos:
+ bucket: "team-shared-bucket"Then in the project config, set the fields to Auto to reuse the team settings:
# agentkit.yaml
+launch_types:
+ cloud:
+ cr_instance_name: Auto # Uses team-shared-cr from global config
+ tos_bucket: Auto # Uses team-shared-bucket from global configCreate separate config files for different environments:
agentkit.dev.yaml # Development (local)
+agentkit.test.yaml # Testing (hybrid)
+agentkit.prod.yaml # Production (cloud)Usage:
# Development
+agentkit launch --config-file agentkit.dev.yaml
+
+# Production
+agentkit launch --config-file agentkit.prod.yaml❌ Bad practice (hard-coding):
runtime_envs:
+ MODEL_AGENT_API_KEY: c05d49af-1234-5678-abcd-xxxx # Don't do this!✅ Recommended approaches:
Option 1: interactive configuration
agentkit config # Enter sensitive values interactivelyOption 2: use .gitignore
# .gitignore
+agentkit.local.yaml # Don't commit local config
+agentkit.prod.yaml # Don't commit prod config
+*.secret.yaml # Any config file containing secretsOption 3: create a config template
# agentkit.yaml.template (commit to Git)
+runtime_envs:
+ MODEL_AGENT_API_KEY: <fill in your API key>
+ MODEL_AGENT_NAME: <fill in the endpoint ID>Make config easier for teammates to understand:
common:
+ agent_name: weather_agent
+ entry_point: app.py
+ launch_type: cloud # Use cloud deployment for production
+
+launch_types:
+ cloud:
+ region: cn-beijing # Beijing region, closest to users
+ runtime_envs:
+ # Volcano Ark model access credentials
+ MODEL_AGENT_API_KEY: xxx
+ MODEL_AGENT_NAME: ep-xxxKeep your config valid:
# Option 1: run the config command to validate
+agentkit config
+
+# Option 2: inspect the config file
+cat agentkit.yaml
+
+# Option 3: try building (without deploying)
+agentkit buildGood for rapid iteration and debugging:
common:
+ agent_name: dev_weather_agent
+ entry_point: app.py
+ description: Weather query agent for development
+ language: Python
+ language_version: '3.12'
+ launch_type: local
+ runtime_envs:
+ APP_ENV: development
+
+launch_types:
+ local:
+ image_tag: dev
+ invoke_port: 8000
+ runtime_envs:
+ MODEL_AGENT_API_KEY: xxx
+ DEBUG: 'true' # Enable debugging
+ LOG_LEVEL: debug # Verbose logs
+ ports:
+ - "8000:8000"
+ memory_limit: 512m # Lower limits for dev
+ cpu_limit: '0.5'An example configuration for a Go Agent:
common:
+ agent_name: go_agent
+ entry_point: main.go
+ description: Golang agent
+ language: Golang
+ language_version: '1.24'
+ dependencies_file: go.mod
+ launch_type: hybrid
+
+launch_types:
+ hybrid:
+ region: cn-beijing
+ image_tag: "{{timestamp}}"
+ cr_instance_name: Auto
+ cr_namespace_name: agentkit
+ runtime_envs:
+ MODEL_AGENT_API_KEY: xxx
+
+docker_build:
+ base_image:
+ builder: "golang:1.24-alpine"
+ runtime: "alpine:latest"Suitable for going live:
common:
+ agent_name: prod_weather_agent
+ entry_point: server.py
+ description: Weather query agent for production
+ language: Python
+ language_version: '3.12'
+ launch_type: cloud
+ runtime_envs:
+ APP_ENV: production
+ LOG_LEVEL: info
+
+launch_types:
+ cloud:
+ region: cn-beijing
+ image_tag: "{{timestamp}}" # Use a timestamp to ensure uniqueness
+
+ # CR settings
+ cr_instance_name: Auto
+ cr_namespace_name: production
+ cr_repo_name: weather_agent
+
+ # TOS settings
+ tos_bucket: Auto
+
+ # Runtime settings
+ runtime_name: Auto
+ runtime_role_name: Auto
+ runtime_apikey_name: Auto
+
+ runtime_envs:
+ # Base settings
+ MODEL_AGENT_API_KEY: xxx
+ MODEL_AGENT_NAME: ep-xxx
+
+ # Observability (recommended in production)
+ OBSERVABILITY_OPENTELEMETRY_APMPLUS_API_KEY: xxx
+ OBSERVABILITY_OPENTELEMETRY_APMPLUS_ENDPOINT: http://apmplus-cn-beijing.volces.com:4317
+ OBSERVABILITY_OPENTELEMETRY_APMPLUS_SERVICE_NAME: prod_weather_agent
+
+docker_build:
+ base_image: "python:3.12-slim"Local mode (minimal):
common:
+ agent_name: simple-agent
+ entry_point: agent.py
+ launch_type: localCloud mode (minimal):
common:
+ agent_name: cloud-agent
+ entry_point: main.py
+ launch_type: cloud
+
+launch_types:
+ cloud:
+ region: cn-beijing
+ runtime_envs:
+ MODEL_AGENT_API_KEY: xxxError: Configuration file not foundFix:
agentkit init my_agent # Create a new project
+# or
+agentkit config # Create configError: Invalid YAML formatChecklist:
`,102)),s("ul",null,[i[25]||(i[25]=s("li",null,"✅ Use spaces for indentation (do not use tabs)",-1)),i[26]||(i[26]=s("li",null,[a("✅ Ensure there is a space after "),s("code",null,":")],-1)),i[27]||(i[27]=s("li",null,"✅ Quote strings containing special characters",-1)),s("li",null,[i[24]||(i[24]=a("✅ Quote template variables: ",-1)),s("code",null,'"'+e(n.timestamp)+'"',1)])]),i[42]||(i[42]=t(`Error: agent_name is requiredFix:
agentkit config # Reconfigure and fill required fieldsError: Config field 'cr_instance_name' template variables were not fully renderedPossible causes:
Fix:
# Check environment variables
+echo $VOLC_ACCESSKEY
+echo $VOLC_SECRETKEY
+
+# Or check global config
+cat ~/.agentkit/config.yamlPossible causes:
common.runtime_envs with policy-level runtime_envsFix:
# 1) Check config
+cat agentkit.yaml
+
+# 2) Confirm env var placement
+# common.runtime_envs - shared by all modes
+# launch_types.<mode>.runtime_envs - specific to the chosen mode
+
+# 3) Redeploy
+agentkit deployIf your config uses legacy field names (for example ve_cr_instance_name or python_version), update them to the new names:
| Legacy field | New field |
|---|---|
python_version | language_version |
ve_cr_instance_name | cr_instance_name |
ve_cr_namespace_name | cr_namespace_name |
ve_cr_repo_name | cr_repo_name |
ve_runtime_id | runtime_id |
ve_runtime_name | runtime_name |
ve_runtime_endpoint | runtime_endpoint |
💡 Tip: the CLI still supports legacy field names (via aliases), but migration is recommended.
common fields | Field | Required | Default | Description |
|---|---|---|---|
agent_name | ✅ | - | Agent name |
entry_point | ✅ | - | Entry file |
description | ❌ | empty | Description |
language | ❌ | Python | Programming language |
language_version | ❌ | 3.12/1.24 | Language version |
dependencies_file | ❌ | auto-detected | Dependency file |
launch_type | ❌ | local | Launch type |
runtime_envs | ❌ | {} | App-level environment variables |
docker_build fields | Field | Default | Description |
|---|---|---|
base_image | auto-selected | Base image |
build_script | none | Build script |
regenerate_dockerfile | false | Force regenerate |
platform | current arch | Target platform |
AgentKit CLI comes with a flexible built-in logging system to help you understand command execution, debug issues, and track runtime status.
AgentKit defaults to the following:
# By default, commands run with no log output
+agentkit status
+
+# If you need logs, enable them via environment variables (see below)Log example:
[2025-11-20 14:56:09] [INFO] [agentkit.toolkit.executors] Loading configuration...
+[2025-11-20 14:56:09] [INFO] [agentkit.toolkit.executors] Using launch_type: cloud
+[2025-11-20 14:56:09] [INFO] [agentkit.toolkit.executors] Querying status with cloud strategy...
+[2025-11-20 14:56:09] [INFO] [agentkit.toolkit.executors] Status query completed: runningIf you want to save logs to a file:
# Enable file logging (default INFO level)
+export AGENTKIT_FILE_ENABLED=true
+
+# Run a command
+agentkit deploy
+
+# View the generated log file
+cat .agentkit/logs/agentkit-$(date +%Y%m%d).logIf you want to view logs in real time in the console:
# Enable console logging
+export AGENTKIT_LOG_CONSOLE=true
+
+# Run a command; now you can see logs in the console
+agentkit status# Enable both console and file logging
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_FILE_ENABLED=true
+
+# Run a command
+agentkit buildWhen you need detailed logs to investigate an issue:
# Enable DEBUG-level logging (enable console and file output)
+export AGENTKIT_LOG_LEVEL=DEBUG
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_FILE_ENABLED=true
+
+# Run a command to view detailed debug information
+agentkit buildWith environment variables, you can fully customize logging behavior.
| Environment Variable | Description | Default | Example |
|---|---|---|---|
AGENTKIT_LOG_CONSOLE | Whether to display logs in the console | false | true / false |
AGENTKIT_FILE_ENABLED | Whether to save logs to a file | false | true / false |
AGENTKIT_LOG_LEVEL | Log level (console and file) | INFO | DEBUG / INFO / WARNING / ERROR |
AGENTKIT_LOG_FILE | Log file path (takes effect when file logging is enabled) | .agentkit/logs/agentkit-YYYYMMDD.log | /tmp/my-agent.log |
Control log levels for console and file separately:
| Environment Variable | Description | Default |
|---|---|---|
AGENTKIT_CONSOLE_LOG_LEVEL | Console log level | INFO |
AGENTKIT_FILE_LOG_LEVEL | File log level | INFO |
Example:
# Show only important errors in the console, but record everything to a file
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_CONSOLE_LOG_LEVEL=ERROR
+export AGENTKIT_FILE_LOG_LEVEL=DEBUG
+
+agentkit launchAgentKit supports 5 log levels. The higher the level, the fewer messages you see:
| Level | Description | Typical Use Cases |
|---|---|---|
DEBUG | Detailed debugging information | Troubleshooting, development/debugging |
INFO | General operational information (default) | Understanding command execution flow |
WARNING | Warning messages | Tracking potential issues |
ERROR | Error messages | Focusing on failed operations |
CRITICAL | Critical errors | Seeing only fatal failures |
Suitable for day-to-day use: no log output to protect sensitive information.
# No configuration needed; just use it
+agentkit status
+agentkit deployEffect:
Enable file logging to help trace operational history:
# Enable file logging
+export AGENTKIT_FILE_ENABLED=true
+
+# Run a command
+agentkit deployEffect:
.agentkit/logs/ at INFO level by defaultWhen encountering errors or abnormal behavior, enable detailed logs:
# Enable DEBUG logs for both console and file
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_FILE_ENABLED=true
+export AGENTKIT_LOG_LEVEL=DEBUG
+
+# Run a command
+agentkit buildEffect:
In CI, you typically want logs in the console and also keep a full record:
# Set in your CI configuration file
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_FILE_ENABLED=true
+export AGENTKIT_CONSOLE_LOG_LEVEL=INFO
+export AGENTKIT_FILE_LOG_LEVEL=DEBUG
+export AGENTKIT_LOG_FILE=/var/log/agentkit/build-\${BUILD_ID}.log
+
+# Run the build
+agentkit launchEffect:
In production, record only warnings and errors to a file:
export AGENTKIT_FILE_ENABLED=true
+export AGENTKIT_FILE_LOG_LEVEL=WARNING
+export AGENTKIT_LOG_FILE=/var/log/agentkit/production.log
+
+# Run a command
+agentkit deployEffect:
When you don’t need any logs (default behavior):
# Default configuration is fully silent; no environment variables needed
+agentkit status
+
+# Or set explicitly (to ensure previous env vars do not affect)
+unset AGENTKIT_LOG_CONSOLE
+unset AGENTKIT_FILE_ENABLEDEffect:
When file logging is enabled (AGENTKIT_FILE_ENABLED=true), logs are stored under .agentkit/logs/ in the project root:
your-project/
+├── .agentkit/
+│ └── logs/
+│ ├── agentkit-20251120.log # Today's logs
+│ ├── agentkit-20251119.log # Yesterday's logs
+│ └── agentkit-20251118.log # The day before yesterday's logs
+├── agentkit.yaml
+└── my_agent.pyLog files accumulate over time; it’s recommended to clean them up periodically:
# Delete logs older than 7 days
+find .agentkit/logs -name "agentkit-*.log" -mtime +7 -delete
+
+# Or delete manually
+rm .agentkit/logs/agentkit-20251101.log# Save to a specific location
+export AGENTKIT_LOG_FILE=/tmp/my-custom-agent.log
+
+# Or save to a user directory
+export AGENTKIT_LOG_FILE=$HOME/.agentkit-logs/agent.log
+
+agentkit deployWhen multiple configuration methods are present, the precedence is (high to low):
AGENTKIT_CONSOLE_LOG_LEVELAGENTKIT_LOG_LEVELINFOExample:
# Set the general level to INFO
+export AGENTKIT_LOG_LEVEL=INFO
+
+# Set a dedicated console level to WARNING (higher priority)
+export AGENTKIT_CONSOLE_LOG_LEVEL=WARNING
+
+# Result: console shows WARNING, file records INFO
+agentkit statusPossible causes:
How to fix:
# 1. Check whether file logging is disabled
+echo $AGENTKIT_FILE_ENABLED # should be true or empty
+
+# 2. Check directory permissions
+ls -la .agentkit/logs/
+
+# 3. Create the directory manually
+mkdir -p .agentkit/logs
+
+# 4. Ensure environment variables are correct
+unset AGENTKIT_FILE_ENABLED # reset to defaultPossible causes:
How to fix:
# 1. Enable console logging
+export AGENTKIT_LOG_CONSOLE=true
+
+# 2. Set an appropriate log level
+export AGENTKIT_CONSOLE_LOG_LEVEL=INFO
+
+# 3. Run a command
+agentkit statusAdjust the log level:
# Too many logs - show only important information
+export AGENTKIT_LOG_LEVEL=WARNING
+
+# Too few logs - view detailed information
+export AGENTKIT_LOG_LEVEL=DEBUGOptionally add to your .bashrc or .zshrc:
# AgentKit development environment configuration (choose as needed)
+# Option 1: Enable console logs only
+export AGENTKIT_LOG_CONSOLE=true
+
+# Option 2: Enable both console and file logs
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_FILE_ENABLED=true
+export AGENTKIT_CONSOLE_LOG_LEVEL=INFO
+export AGENTKIT_FILE_LOG_LEVEL=DEBUGRecommendations:
Create a .env.example file in the project root:
# AgentKit logging configuration example
+# Copy to .env and modify as needed
+
+# === Recommended dev configuration ===
+# Enable console logs (for real-time viewing)
+AGENTKIT_LOG_CONSOLE=true
+
+# Enable file logging (optional; useful for tracing issues)
+# AGENTKIT_FILE_ENABLED=true
+
+# Set log level
+AGENTKIT_LOG_LEVEL=INFO
+
+# Custom log path (optional)
+# AGENTKIT_LOG_FILE=./logs/my-agent.logReminder:
.env should be in .gitignore to avoid committing personal configuration# Production configuration
+export AGENTKIT_LOG_CONSOLE=false # Disable console
+export AGENTKIT_FILE_ENABLED=true # Enable file logging
+export AGENTKIT_FILE_LOG_LEVEL=WARNING # Record warnings and errors only
+export AGENTKIT_LOG_FILE=/var/log/agentkit/prod.log # Unified pathBenefits:
AgentKit logging system design principles:
Quick reference:
# 1. Enable file logging
+export AGENTKIT_FILE_ENABLED=true
+
+# 2. Enable console debugging
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_FILE_ENABLED=true
+export AGENTKIT_LOG_LEVEL=DEBUG
+
+# 3. View log file (file logging must be enabled first)
+cat .agentkit/logs/agentkit-$(date +%Y%m%d).log
+
+# 4. Use different levels for console and file
+export AGENTKIT_LOG_CONSOLE=true
+export AGENTKIT_FILE_ENABLED=true
+export AGENTKIT_CONSOLE_LOG_LEVEL=ERROR
+export AGENTKIT_FILE_LOG_LEVEL=DEBUGIf you run into issues, refer to the Troubleshooting section or contact technical support.
`,130)])])}const c=i(t,[["render",l]]);export{g as __pageData,c as default}; diff --git a/assets/en_content_2.agentkit-cli_4.logging.md.CKu1hSf7.lean.js b/assets/en_content_2.agentkit-cli_4.logging.md.CKu1hSf7.lean.js new file mode 100644 index 0000000..4eb57df --- /dev/null +++ b/assets/en_content_2.agentkit-cli_4.logging.md.CKu1hSf7.lean.js @@ -0,0 +1 @@ +import{_ as i,c as a,o as n,ag as e}from"./chunks/framework.CA4hJK0u.js";const g=JSON.parse('{"title":"Logging System","description":"","frontmatter":{},"headers":[],"relativePath":"en/content/2.agentkit-cli/4.logging.md","filePath":"en/content/2.agentkit-cli/4.logging.md","lastUpdated":1770735100000}'),t={name:"en/content/2.agentkit-cli/4.logging.md"};function l(h,s,p,o,k,r){return n(),a("div",null,[...s[0]||(s[0]=[e("",130)])])}const c=i(t,[["render",l]]);export{g as __pageData,c as default}; diff --git a/assets/en_content_3.agentkit-sdk_1.overview.md.BdtJKqB6.js b/assets/en_content_3.agentkit-sdk_1.overview.md.BdtJKqB6.js new file mode 100644 index 0000000..ec47f75 --- /dev/null +++ b/assets/en_content_3.agentkit-sdk_1.overview.md.BdtJKqB6.js @@ -0,0 +1,67 @@ +import{_ as i,c as a,o as n,ag as e}from"./chunks/framework.CA4hJK0u.js";const c=JSON.parse('{"title":"AgentKit SDK Overview","description":"","frontmatter":{},"headers":[],"relativePath":"en/content/3.agentkit-sdk/1.overview.md","filePath":"en/content/3.agentkit-sdk/1.overview.md","lastUpdated":1770735100000}'),t={name:"en/content/3.agentkit-sdk/1.overview.md"};function l(p,s,h,r,o,k){return n(),a("div",null,[...s[0]||(s[0]=[e(`AgentKit SDK is a Python development toolkit for rapidly building Agent applications that comply with AgentKit Platform standards. The SDK provides a concise set of decorators and client interfaces, allowing developers to focus on implementing Agent business logic.
AgentKit SDK adopts a modular design, consisting of the following primary modules:
Provides multiple application patterns, encapsulating user code into HTTP services that comply with Platform standards:
The most commonly used application framework, suitable for standard Agent applications.
Core Decorators:
@app.entrypoint - Defines the main entry function for the Agent@app.ping - Defines the health check function@app.async_task - Defines asynchronous tasks (planned)Standard Routes:
/invoke - Agent invocation endpoint/ping - Health check/health, /readiness, /liveness - Kubernetes readiness probesAn application framework based on the MCP (Model Context Protocol) protocol, used to encapsulate tools as MCP services.
Core Decorators:
@app.tool - Registers a function as an MCP tool@app.agent_as_a_tool - Encapsulates an Agent as an MCP toolAn application framework based on the A2A (Agent-to-Agent) protocol, used to build Agents that can communicate with each other.
Core Decorators:
@app.agent_executor - Registers an Agent executor@app.task_store - Registers task storage (optional)Provides convenient client interfaces for accessing various services of the AgentKit Platform.
Memory service client for managing long-term and short-term memory of Agents.
Main Functions:
create_memory_collection() - Creates a memory collectionlist_memory_collections() - Lists memory collectionsget_memory_collection() - Gets memory collection detailsupdate_memory_collection() - Updates memory collection configurationdelete_memory_collection() - Deletes a memory collectionget_memory_connection_info() - Gets connection informationDesign Philosophy: Decoupling of control plane and data plane
Knowledge base service client for managing vectorized knowledge bases of Agents.
Main Functions:
list_knowledge_bases() - Lists knowledge basesadd_knowledge_base() - Adds a knowledge baseget_knowledge_connection_info() - Gets knowledge base connection informationdelete_knowledge_base() - Deletes a knowledge baseUse Cases:
MCP Gateway client for managing and routing a large number of MCP tools.
Main Functions:
Runtime management client for managing Agent runtime environments.
Main Functions:
Base class for all clients, providing unified configuration and HTTP request capabilities.
Configuration Items:
Uses contextvars to manage context information for each request, including:
AgentKit SDK
+│
+├── Runtime Apps (Application Framework Layer)
+│ ├── AgentkitSimpleApp
+│ ├── AgentkitMCPApp
+│ ├── AgentkitA2aApp
+│ └── AgentkitAgentServerApp
+│
+├── Platform Clients (Service Client Layer)
+│ ├── AgentkitMemory
+│ ├── AgentkitKnowledge
+│ ├── AgentkitMCP
+│ └── AgentkitRuntime
+│
+└── Infrastructure (Infrastructure Layer)
+ ├── BaseAgentkitClient
+ ├── Context
+ └── Telemetry (Observability)Uses Python decorators to simplify application development; developers only need to focus on business logic:
from agentkit.apps import AgentkitSimpleApp
+
+app = AgentkitSimpleApp()
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ # Business logic
+ return responseThe SDK does not restrict the use of specific Agent frameworks; it supports:
Built-in OpenTelemetry support, automatically collects:
Provides complete production environment support:
Full Python type annotations provide:
pip install agentkit-sdk-pythonfrom agentkit.apps import AgentkitSimpleApp
+from veadk import Agent, Runner
+from veadk.tools.demo_tools import get_city_weather
+
+app = AgentkitSimpleApp()
+agent = Agent(tools=[get_city_weather])
+runner = Runner(agent=agent)
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ prompt = payload["prompt"]
+ user_id = headers["user_id"]
+ session_id = headers["session_id"]
+
+ response = await runner.run(
+ messages=prompt,
+ user_id=user_id,
+ session_id=session_id
+ )
+ return response
+
+@app.ping
+def ping() -> str:
+ return "pong!"
+
+if __name__ == "__main__":
+ app.run(host="0.0.0.0", port=8000)from agentkit.sdk.memory import AgentkitMemory
+from agentkit.base_client import ApiConfig
+
+# Initialize client
+config = ApiConfig(
+ access_key="your_ak",
+ secret_key="your_sk"
+)
+memory_client = AgentkitMemory(config)
+
+# Create memory collection
+response = memory_client.create_memory_collection(
+ name="my-memory",
+ short_term_configuration={...},
+ long_term_configuration={...}
+)
+print(f"Memory ID: {response.id}")samples/ directoryAgentKit SDK provides a concise set of decorators (annotations) for rapidly building different types of Agent applications. This document details the usage and best practices for various annotations.
AgentkitSimpleApp is the most commonly used application framework, providing standard HTTP service endpoints.
Defines the main entry function for the Agent, handling invocation requests from the Platform.
@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ passpayload (dict): Request body, containing user input and configuration
prompt (str): User input promptheaders (dict): Request headers, containing context information
user_id (str): User IDsession_id (str): Session IDrequest_id (str): Request trace IDReturn Value (str): Agent's response result
from agentkit.apps import AgentkitSimpleApp
+from veadk import Agent, Runner
+from veadk.tools.demo_tools import get_city_weather
+
+app = AgentkitSimpleApp()
+agent = Agent(tools=[get_city_weather])
+runner = Runner(agent=agent)
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ """Agent main entry function"""
+ # 1. Extract input parameters
+ prompt = payload.get("prompt", "")
+ user_id = headers.get("user_id", "anonymous")
+ session_id = headers.get("session_id", "default")
+
+ # 2. Invoke Agent execution
+ response = await runner.run(
+ messages=prompt,
+ user_id=user_id,
+ session_id=session_id
+ )
+
+ # 3. Return result
+ return responseasync def to defineimport logging
+
+logger = logging.getLogger(__name__)
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ try:
+ prompt = payload["prompt"]
+ response = await runner.run(messages=prompt)
+ return response
+ except KeyError as e:
+ logger.error(f"Missing required field: {e}")
+ return f"Error: Missing required field {e}"
+ except Exception as e:
+ logger.error(f"Agent execution failed: {e}")
+ return f"Error: {str(e)}"Defines the health check function, used for Platform and Kubernetes health probes.
@app.ping
+def ping() -> str:
+ pass@app.ping
+def ping() -> str:
+ """Health check"""
+ return "pong!"import redis
+from sqlalchemy import create_engine
+
+# Initialize dependencies
+redis_client = redis.Redis(host='localhost', port=6379)
+db_engine = create_engine('postgresql://...')
+
+@app.ping
+def ping() -> str:
+ """Health check, including dependency service detection"""
+ try:
+ # Check Redis connection
+ redis_client.ping()
+
+ # Check database connection
+ with db_engine.connect() as conn:
+ conn.execute("SELECT 1")
+
+ return "ok - all services healthy"
+ except Exception as e:
+ logger.error(f"Health check failed: {e}")
+ return f"degraded - {str(e)}"def ping() -> str:def rather than async defHealth check functions are automatically registered to the following endpoints:
GET /ping - Basic health checkGET /health - Health statusGET /readiness - Kubernetes readiness probeGET /liveness - Kubernetes liveness probeUsed to define asynchronous tasks, supporting long-running operations.
@app.async_task
+async def process_long_task(task_id: str, data: dict) -> dict:
+ """Process long-running tasks"""
+ # Long-running logic
+ result = await heavy_computation(data)
+ return resultNote: This feature is planned and not yet implemented.
AgentkitMCPApp is used to build MCP (Model Context Protocol) services, encapsulating functions as standard MCP tools.
Registers a function as an MCP tool for LLM invocation.
@app.tool
+def tool_name(param1: str, param2: int) -> dict:
+ passfrom agentkit.apps import AgentkitMCPApp
+
+mcp_app = AgentkitMCPApp()
+
+@mcp_app.tool
+def get_city_weather(city: str) -> dict[str, str]:
+ """Get city weather information
+
+ Args:
+ city: City name (must be in English)
+
+ Returns:
+ Dictionary containing weather conditions and temperature
+ """
+ weather_data = {
+ "beijing": {"condition": "Sunny", "temperature": 25},
+ "shanghai": {"condition": "Cloudy", "temperature": 22},
+ }
+
+ city = city.lower().strip()
+ if city in weather_data:
+ info = weather_data[city]
+ return {"result": f"{info['condition']}, {info['temperature']}°C"}
+ else:
+ return {"result": f"Weather information not found for {city}"}import aiohttp
+
+@mcp_app.tool
+async def fetch_web_content(url: str) -> dict:
+ """Fetch web page content
+
+ Args:
+ url: Web page URL
+
+ Returns:
+ Dictionary containing web page content
+ """
+ async with aiohttp.ClientSession() as session:
+ async with session.get(url) as response:
+ content = await response.text()
+ return {
+ "status": response.status,
+ "content": content[:1000] # Extract first 1000 characters
+ }def and async deffrom typing import List, Optional
+from pydantic import BaseModel
+
+class SearchQuery(BaseModel):
+ keywords: List[str]
+ max_results: int = 10
+ filters: Optional[dict] = None
+
+@mcp_app.tool
+def search_documents(query: SearchQuery) -> dict:
+ """Search documents
+
+ Args:
+ query: Search query object, containing keywords, result count, and filter conditions
+
+ Returns:
+ Search results list
+ """
+ # Implement search logic
+ results = perform_search(
+ keywords=query.keywords,
+ max_results=query.max_results,
+ filters=query.filters
+ )
+ return {"results": results, "count": len(results)}Encapsulates the entire Agent as an MCP tool, enabling Agent composition and collaboration.
@app.agent_as_a_tool
+async def agent_tool(prompt: str) -> str:
+ passfrom veadk import Agent, Runner
+from veadk.tools.demo_tools import get_city_weather
+
+# Create a dedicated weather Agent
+weather_agent = Agent(tools=[get_city_weather])
+weather_runner = Runner(agent=weather_agent)
+
+mcp_app = AgentkitMCPApp()
+
+@mcp_app.agent_as_a_tool
+async def weather_assistant(prompt: str) -> str:
+ """Weather assistant Agent
+
+ An Agent specifically designed to handle weather-related queries, capable of querying weather information for cities worldwide.
+
+ Args:
+ prompt: User's weather query
+
+ Returns:
+ Weather query result
+ """
+ response = await weather_runner.run(messages=prompt)
+ return response# Create multiple dedicated Agents
+weather_agent = Agent(tools=[get_city_weather])
+news_agent = Agent(tools=[get_latest_news])
+calendar_agent = Agent(tools=[check_schedule])
+
+@mcp_app.agent_as_a_tool
+async def weather_assistant(query: str) -> str:
+ """Weather assistant"""
+ return await Runner(agent=weather_agent).run(messages=query)
+
+@mcp_app.agent_as_a_tool
+async def news_assistant(query: str) -> str:
+ """News assistant"""
+ return await Runner(agent=news_agent).run(messages=query)
+
+@mcp_app.agent_as_a_tool
+async def calendar_assistant(query: str) -> str:
+ """Calendar assistant"""
+ return await Runner(agent=calendar_agent).run(messages=query)AgentkitA2aApp is used to build A2A (Agent-to-Agent) applications, supporting communication and collaboration between Agents.
Registers an Agent executor, defining the Agent's execution logic.
@app.agent_executor(runner=runner, **kwargs)
+class MyAgentExecutor(A2aAgentExecutor):
+ passfrom agentkit.apps import AgentkitA2aApp
+from google.adk.a2a.executor.a2a_agent_executor import A2aAgentExecutor
+from veadk import Agent, Runner
+from veadk.a2a.agent_card import get_agent_card
+from veadk.tools.demo_tools import get_city_weather
+
+# Create A2A application
+a2a_app = AgentkitA2aApp()
+
+# Create Agent
+agent = Agent(tools=[get_city_weather])
+runner = Runner(agent=agent)
+
+# Register executor
+@a2a_app.agent_executor(runner=runner)
+class WeatherAgentExecutor(A2aAgentExecutor):
+ """Weather query Agent executor"""
+ pass
+
+# Run application
+if __name__ == "__main__":
+ a2a_app.run(
+ agent_card=get_agent_card(agent=agent, url="http://127.0.0.1:8000"),
+ host="127.0.0.1",
+ port=8000,
+ )from a2a.server.agent_execution import AgentExecutor
+from a2a.server.agent_execution.context import RequestContext
+from a2a.server.events.event_queue import EventQueue
+
+@a2a_app.agent_executor(runner=runner)
+class CustomAgentExecutor(AgentExecutor):
+ """Custom Agent executor"""
+
+ async def execute(
+ self,
+ context: RequestContext,
+ event_queue: EventQueue
+ ) -> str:
+ """Execute Agent logic
+
+ Args:
+ context: Request context, containing input messages and history
+ event_queue: Event queue, used for sending intermediate results
+
+ Returns:
+ Agent's response result
+ """
+ # Extract input from context
+ user_message = context.current_input
+
+ # Send intermediate events (optional)
+ await event_queue.put({
+ "type": "thinking",
+ "content": "Thinking..."
+ })
+
+ # Execute Agent
+ response = await self.runner.run(messages=user_message)
+
+ return responseAgentExecutor or its subclassesexecute methodRegisters task storage for persisting A2A task states.
@app.task_store(**kwargs)
+class MyTaskStore(TaskStore):
+ pass# Without specifying task_store, in-memory storage (InMemoryTaskStore) will be used
+a2a_app = AgentkitA2aApp()
+
+@a2a_app.agent_executor(runner=runner)
+class MyExecutor(A2aAgentExecutor):
+ passfrom a2a.server.tasks.task_store import TaskStore
+from a2a.types import Task
+import redis
+
+@a2a_app.task_store(redis_url="redis://localhost:6379")
+class RedisTaskStore(TaskStore):
+ """Redis-based task storage"""
+
+ def __init__(self, redis_url: str):
+ self.redis_client = redis.from_url(redis_url)
+
+ async def save_task(self, task: Task) -> None:
+ """Save task"""
+ task_data = task.model_dump_json()
+ self.redis_client.set(f"task:{task.id}", task_data)
+
+ async def get_task(self, task_id: str) -> Task | None:
+ """Get task"""
+ task_data = self.redis_client.get(f"task:{task_id}")
+ if task_data:
+ return Task.model_validate_json(task_data)
+ return None
+
+ async def delete_task(self, task_id: str) -> None:
+ """Delete task"""
+ self.redis_client.delete(f"task:{task_id}")TaskStoresave_task, get_task, delete_task, and other methodsAll decorated functions should have good error handling:
import logging
+
+logger = logging.getLogger(__name__)
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ try:
+ # Business logic
+ result = await process(payload)
+ return result
+ except ValueError as e:
+ logger.warning(f"Invalid input: {e}")
+ return f"Invalid input: {str(e)}"
+ except Exception as e:
+ logger.error(f"Unexpected error: {e}", exc_info=True)
+ return "An error occurred. Please try again later."Add appropriate logs for problem tracking:
@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ request_id = headers.get("request_id", "unknown")
+ logger.info(f"[{request_id}] Processing request: {payload}")
+
+ try:
+ response = await runner.run(messages=payload["prompt"])
+ logger.info(f"[{request_id}] Request completed successfully")
+ return response
+ except Exception as e:
+ logger.error(f"[{request_id}] Request failed: {e}")
+ raiseUse complete type annotations to improve code quality:
from typing import Dict, Any
+
+@app.entrypoint
+async def run(payload: Dict[str, Any], headers: Dict[str, str]) -> str:
+ prompt: str = payload["prompt"]
+ user_id: str = headers.get("user_id", "anonymous")
+ # ...Add detailed docstrings for all functions:
@mcp_app.tool
+def calculate_distance(lat1: float, lon1: float, lat2: float, lon2: float) -> dict:
+ """Calculate the distance between two geographic coordinates
+
+ Uses the Haversine formula to calculate the great-circle distance between two points on the Earth's surface.
+
+ Args:
+ lat1: Starting latitude (degrees)
+ lon1: Starting longitude (degrees)
+ lat2: Ending latitude (degrees)
+ lon2: Ending longitude (degrees)
+
+ Returns:
+ Dictionary containing distance information, distance unit is kilometers
+
+ Example:
+ >>> calculate_distance(39.9, 116.4, 31.2, 121.5)
+ {"distance_km": 1067.5}
+ """
+ # Implementation logicAvoid performing time-consuming initialization in decorated functions:
# ❌ Bad practice
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ agent = Agent(tools=[...]) # Created on every request
+ runner = Runner(agent=agent)
+ return await runner.run(messages=payload["prompt"])
+
+# ✅ Good practice
+agent = Agent(tools=[...]) # Created only once
+runner = Runner(agent=agent)
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ return await runner.run(messages=payload["prompt"])samples/ directoryAgentKit Runtime is a unified, managed Agent execution environment designed to provide you with a secure, efficient, and scalable serverless platform, allowing you to focus on Agent business logic rather than tedious infrastructure operations.
AgentKit Runtime systematically addresses all these problems by providing a serverless managed environment.
This guide will walk you through the complete process from environment configuration and local development debugging to ultimately deploying your Agent to a production environment.
Before starting, please ensure you have:
Note: Please ensure your AccessKey has
AgentKitFullAccesspermissions.
We recommend using
uvorpython3 -m venvto manage your Python virtual environment. The following examples will useuv.For
uvinstallation instructions, please refer to: uv installation
1. Create and Activate Virtual Environment
mkdir agentkit-runtime-quickstart
+cd agentkit-runtime-quickstart
+uv venv --python 3.12.0
+source .venv/bin/activate2. Install Core Dependencies
You can specify a mirror source via the
--indexparameter to speed up installation.
uv add veadk-python
+uv add agentkit-sdk-pythonWe strongly recommend using agentkit-cli to quickly bootstrap your project. The init command creates a well-structured Agent project with streaming support from a template.
# Use agentkit-cli to create project from template
+agentkit initThis automatically generates a project structure containing simple_agent.py and requirements.txt, allowing you to start development immediately.
The core code of simple_agent.py generated using the basic_stream template is shown below. It demonstrates how to wrap a veADK Agent with AgentkitSimpleApp, execute it through Runner, and return results as SSE (Server-Sent Events) streams.
# 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 json
+import logging
+
+from google.adk.agents import RunConfig
+from google.adk.agents.run_config import StreamingMode
+from google.genai.types import Content, Part
+from veadk import Agent, Runner
+
+from agentkit.apps import AgentkitSimpleApp
+from veadk.prompts.agent_default_prompt import DEFAULT_DESCRIPTION, DEFAULT_INSTRUCTION
+
+logger = logging.getLogger(__name__)
+logger.setLevel(logging.INFO)
+
+app = AgentkitSimpleApp()
+
+app_name = "simple_streamable_app"
+
+agent_name = "Agent"
+description = DEFAULT_DESCRIPTION
+system_prompt = DEFAULT_INSTRUCTION
+
+
+tools = []
+
+# from veadk.tools.builtin_tools.web_search import web_search
+# tools.append(web_search)
+
+
+agent = Agent(
+ name=agent_name,
+ description=description,
+ instruction=system_prompt,
+ tools=tools,
+)
+agent.model._additional_args["stream_options"] = {"include_usage": True}
+runner = Runner(agent=agent, app_name=app_name)
+
+
+@app.entrypoint
+async def run(payload: dict, headers: dict):
+ prompt = payload["prompt"]
+ user_id = headers["user_id"]
+ session_id = headers["session_id"]
+
+ logger.info(
+ f"Running agent with prompt: {prompt}, user_id: {user_id}, session_id: {session_id}"
+ )
+
+ session_service = runner.short_term_memory.session_service # type: ignore
+
+ # prevent session recreation
+ session = await session_service.get_session(
+ app_name=app_name, user_id=user_id, session_id=session_id
+ )
+ if not session:
+ await session_service.create_session(
+ app_name=app_name, user_id=user_id, session_id=session_id
+ )
+
+ new_message = Content(role="user", parts=[Part(text=prompt)])
+ try:
+ async for event in runner.run_async(
+ user_id=user_id,
+ session_id=session_id,
+ new_message=new_message,
+ run_config=RunConfig(streaming_mode=StreamingMode.SSE),
+ ):
+ # Format as SSE data
+ sse_event = event.model_dump_json(exclude_none=True, by_alias=True)
+ logger.debug("Generated event in agent run streaming: %s", sse_event)
+ yield sse_event
+ except Exception as e:
+ logger.exception("Error in event_generator: %s", e)
+ # You might want to yield an error event here
+ error_data = json.dumps({"error": str(e)})
+ yield error_data
+
+
+@app.ping
+def ping() -> str:
+ return "pong!"
+
+
+if __name__ == "__main__":
+ app.run(host="0.0.0.0", port=8000)Code Highlights:
AgentkitSimpleApp.Before starting the Agent service, you need to configure Volcengine access credentials:
# Required: Configure your Volcengine access credentials
+export VOLCENGINE_ACCESS_KEY=your_ak
+export VOLCENGINE_SECRET_KEY=your_skImportant: Please replace
your_akandyour_skwith your actual credentials.
Once everything is ready, run the following command to start the Agent service:
python simple_agent.pyThe service will listen on http://0.0.0.0:8000. Now, open another terminal and test your Agent using curl:
curl --location 'http://localhost:8000/invoke' \\
+ --header 'Content-Type: application/json' \\
+ --header 'user_id: test' \\
+ --header 'session_id: local_session' \\
+ --data '{"prompt": "Tell me a joke!"}'Parameter Reference:
user_id: User identifiersession_id: Session identifierprompt: User's natural language requestSample Execution Log:
After successful invocation, the console will output detailed execution logs:
INFO: Started server process [38120]
+INFO: Waiting for application startup.
+INFO: Application startup complete.
+INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
+INFO: 127.0.0.1:60807 - "POST /invoke HTTP/1.1" 200 OK
+INFO:__main__:Running agent with prompt: Tell me a joke!, user_id: test, session_id: local_session
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: Why
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: did
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: the
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: AI
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: apply
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: for
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: a
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: job
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: at
+2025-12-01 20:12:50 | DEBUG | runner.py:151 - Event output: the
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: bakery
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: ?
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: Because
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: it
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: wanted
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: to
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: work
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: on
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: its
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: **
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: d
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: ough
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: **
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: processing
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: skills
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: !
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: 😄
+2025-12-01 20:12:51 | DEBUG | runner.py:151 - Event output: Why did the AI apply for a job at the bakery?
+
+Because it wanted to work on its **dough** processing skills! 😄After completing local development and testing, you can deploy your agent to the AgentKit platform:
requirements.txt. The code generated using the template already includes all necessary dependencies.agentkit config and agentkit launch commands to configure and deploy your application.agentkit invoke "Tell me a joke!"You have now successfully completed the entire process from local development to cloud deployment!
`,53)])])}const c=i(t,[["render",l]]);export{g as __pageData,c as default}; diff --git a/assets/en_content_4.runtime_1.runtime_quickstart.md.CFRmDDBm.lean.js b/assets/en_content_4.runtime_1.runtime_quickstart.md.CFRmDDBm.lean.js new file mode 100644 index 0000000..831a0c2 --- /dev/null +++ b/assets/en_content_4.runtime_1.runtime_quickstart.md.CFRmDDBm.lean.js @@ -0,0 +1 @@ +import{_ as i,c as n,o as a,ag as e}from"./chunks/framework.CA4hJK0u.js";const g=JSON.parse('{"title":"AgentKit Runtime: From Local Development to Cloud Deployment","description":"","frontmatter":{},"headers":[],"relativePath":"en/content/4.runtime/1.runtime_quickstart.md","filePath":"en/content/4.runtime/1.runtime_quickstart.md","lastUpdated":1770735100000}'),t={name:"en/content/4.runtime/1.runtime_quickstart.md"};function l(p,s,h,r,k,o){return a(),n("div",null,[...s[0]||(s[0]=[e("",53)])])}const c=i(t,[["render",l]]);export{g as __pageData,c as default}; diff --git a/assets/en_content_5.tools_1.sandbox_quickstart.md.CMivIjEK.js b/assets/en_content_5.tools_1.sandbox_quickstart.md.CMivIjEK.js new file mode 100644 index 0000000..4746e96 --- /dev/null +++ b/assets/en_content_5.tools_1.sandbox_quickstart.md.CMivIjEK.js @@ -0,0 +1,63 @@ +import{_ as i,c as n,o as a,ag as e}from"./chunks/framework.CA4hJK0u.js";const k=JSON.parse('{"title":"AgentKit Built-in Tools Quick Start Guide","description":"","frontmatter":{},"headers":[],"relativePath":"en/content/5.tools/1.sandbox_quickstart.md","filePath":"en/content/5.tools/1.sandbox_quickstart.md","lastUpdated":1770735100000}'),t={name:"en/content/5.tools/1.sandbox_quickstart.md"};function l(o,s,p,r,h,d){return a(),n("div",null,[...s[0]||(s[0]=[e(`Built-in Tools provide Agents with standardized sandbox runtime environments and tool interfaces. The all-in-one sandbox image integrates core capabilities including code execution, browser automation, and terminal operations, supporting standardized integration and API calls.
This document provides detailed instructions on how to integrate and use Built-in Tools in your Agent code, with a focus on the code execution sandbox functionality. By following this guide, you will learn how to create, configure, and invoke sandbox tools.
Before writing code, you need to create a sandbox tool instance in the Volcengine console:
TOOL_ID for use in subsequent configurationThe following code demonstrates how to use VeADK to build an Agent with code execution capabilities. By integrating the Built-in Tools run_code tool, your Agent will be able to execute code safely within a sandbox environment.
We recommend using agentkit-cli to create a project from the Basic Agent template. After the template is created, you need to make the following modifications:
run_code to your AgentAGENTKIT_TOOL_ID with your sandbox tool instance IDYour final code file should look like this:
Save the code as simple_agent_tool.py:
from veadk import Agent, Runner
+from veadk.tools.builtin_tools.run_code import run_code
+from agentkit.apps import AgentkitSimpleApp
+
+app = AgentkitSimpleApp()
+agent: Agent = Agent(
+ tools=[run_code],
+)
+runner = Runner(agent=agent)
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ prompt = payload["prompt"]
+ user_id = headers["user_id"]
+ session_id = headers["session_id"]
+
+ response = await runner.run(
+ messages=prompt,
+ user_id=user_id,
+ session_id=session_id
+ )
+ return response
+
+@app.ping
+def ping() -> str:
+ return "pong!"
+
+if __name__ == "__main__":
+ app.run(host="0.0.0.0", port=8000)run_code Tool: Provides a secure code execution environment supporting multiple programming languages including Python and JavaScriptsession_id: Used to identify user sessions; requests with the same session_id will share the same sandbox instanceasync/await syntax to support high-concurrency requestsYou can install veadk-python directly using the Python package manager pip from the PyPI platform:
pip install veadk-pythonNote: The veadk-python version that supports calling built-in tools is 0.2.15 and above.
Before starting the Agent, you need to configure the following environment variables:
# Required: Sandbox tool ID (obtained from the console)
+export AGENTKIT_TOOL_ID=t-ye7fhfmghsc1kdxxxxxx
+
+# Required: Volcengine access credentials
+export VOLCENGINE_ACCESS_KEY=your_ak
+export VOLCENGINE_SECRET_KEY=your_sk📝 Important Notes:
your_ak, your_sk with your actual configuration valuesAGENTKIT_TOOL_ID is obtained after creating the sandbox tool in the Volcengine consoleAfter configuring the environment variables, run the following command to start the Agent:
python simple_agent_tool.pyOnce the service starts successfully, it will listen on http://0.0.0.0:8000, and you can invoke the Agent through this address.
Tool instances support intelligent session-based scheduling management:
session_id to invoke, the system will automatically create the corresponding sandbox session instancesession_id will share the same sandbox instance, maintaining continuity of code execution contextsession_id values use independent sandbox environments with no interference between themUse the following curl command to test the Agent's code execution capability:
curl --location 'http://localhost:8000/invoke' \\
+ --header 'Content-Type: application/json' \\
+ --header 'user_id: veadk-test' \\
+ --header 'session_id: local_session' \\
+ --data '{"prompt": "Give me a random prime number between 50 and 100"}'Parameter Description:
user_id: User identifiersession_id: Session identifier, used to associate with the sandbox instanceprompt: User's natural language requestAfter a successful invocation, the console will output detailed execution logs:
2025-11-23 21:10:24 | DEBUG | runner.py:578 - Function call: id='call_jwrcwdayjj8xnlgalyzzcoqq' args={'code': 'import random\\n\\ndef is_prime(n):\\n if n <= 1:\\n return False\\n if n == 2:\\n return True\\n if n % 2 == 0:\\n return False\\n for i in range(3, int(n**0.5) + 1, 2):\\n if n % i == 0:\\n return False\\n return True\\n\\nprimes_between = [p for p in range(50, 101) if is_prime(p)]\\nrandom_prime = random.choice(primes_between)\\nprint(random_prime)', 'language': 'python3'} name='run_code'
+2025-11-23 21:10:24 | DEBUG | run_code.py:48 - tools endpoint: agentkit.cn-beijing.volces.com
+2025-11-23 21:10:24 | DEBUG | run_code.py:54 - tool_user_session_id: veAgent_veadk-test_local_session
+2025-11-23 21:10:24 | DEBUG | run_code.py:56 - Running code in language: python3, session_id=local_session, code=import random
+
+def is_prime(n):
+ if n <= 1:
+ return False
+ if n == 2:
+ return True
+ if n % 2 == 0:
+ return False
+ for i in range(3, int(n**0.5) + 1, 2):
+ if n % i == 0:
+ return False
+ return True
+
+primes_between = [p for p in range(50, 101) if is_prime(p)]
+random_prime = random.choice(primes_between)
+print(random_prime), tool_id=t-ye7yhff668o2eybtfvr0, host=agentkit.cn-beijing.volces.com, service=agentkit, region=cn-beijing
+2025-11-23 21:10:24 | DEBUG | run_code.py:65 - Get AK/SK from tool context failed.
+2025-11-23 21:10:24 | DEBUG | run_code.py:77 - Successfully get AK/SK from environment variables.
+2025-11-23 21:10:25 | DEBUG | run_code.py:103 - Invoke run code response: {'ResponseMetadata': {'RequestId': '****', 'Action': 'InvokeTool', 'Version': '2025-10-30', 'Service': 'agentkit', 'Region': 'cn-beijing'}, 'Result': {'ToolId': 't-****', 'UserSessionId': '****', 'SessionId': 's-****', 'Endpoint': '', 'InternalEndpoint': '', 'Result': '{\\n "success": true,\\n "message": "Code executed successfully",\\n "data": {\\n "kernel_name": "python3",\\n "session_id": "****",\\n "status": "ok",\\n "execution_count": 1,\\n "outputs": [\\n {\\n "output_type": "stream",\\n "name": "stdout",\\n "text": "67\\\\n",\\n "data": null,\\n "metadata": {},\\n "execution_count": null,\\n "ename": null,\\n "evalue": null,\\n "traceback": null\\n }\\n ],\\n "code": "import random\\\\n\\\\ndef is_prime(n):\\\\n if n \\\\u003c= 1:\\\\n return False\\\\n if n == 2:\\\\n return True\\\\n if n % 2 == 0:\\\\n return False\\\\n for i in range(3, int(n**0.5) + 1, 2):\\\\n if n % i == 0:\\\\n return False\\\\n return True\\\\n\\\\nprimes_between = [p for p in range(50, 101) if is_prime(p)]\\\\nrandom_prime = random.choice(primes_between)\\\\nprint(random_prime)",\\n "msg_id": "****"\\n }\\n}'}}
+2025-11-23 21:10:38 | DEBUG | runner.py:586 - Event output: The random prime number between 50 and 100 is: 67
+2025-11-23 21:10:38 | WARNING | runner.py:652 - No tracer is configured in the agent, no trace id provided.
+INFO: 127.0.0.1:52785 - "POST /invoke HTTP/1.1" 200 OKAfter completing local development and testing, you can deploy your Agent to the AgentKit platform:
requirements.txtagentkit init command in the project root directory to initialize the project, which will generate the agentkit.yaml file (skip this step if already executed)agentkit.yaml file is configured with the application entry point set to your working application code simple_agent_tool.py:entry_point: simple_agent_tool.pyrequirements.txtagentkit config and agentkit launch commands to configure and deploy the applicationagentkit invoke "Give me a random prime number between 50 and 100"AI Agents face increasingly complex multi-turn tasks and context window limitations during operation. They require memory capabilities for context retention and personalization. AgentKit Memory provides a unified memory store interface and integrates with mainstream frameworks, offering cross-session, context-aware, and personalized interactions for Agents, enabling continuous learning and evolution. This chapter guides you through installing dependencies and implementing long-term memory functionality.
The following example demonstrates how to use AgentKit Memory to implement long-term memory functionality.
Steps:
Create a memory store for your agent through the Volcano Engine Console: Agentkit-Memory
On the Memory Details - Integration Code page, obtain the connection information.
DATABASE_MEM0_BASE_URL="https://mem0-your-mem-url.mem0.volces.com:8000"
+DATABASE_MEM0_API_KEY="xxxxxx-xxxxxxx"DATABASE_VIKINGMEM_COLLECTION=<collection_name of your vikingdb memory> #index
+DATABASE_VIKINGMEM_MEMORY_TYPE=memory_summary_04uyfx # memory type, separate multiple by comma, e.g. event_v1,event_v2VeADK is an open-source agent development framework that provides development, execution, and debugging capabilities for agents, maintained by the Volcano Engine team. The following example demonstrates how to use VeADK to build an agent with long-term memory capabilities, using mem0 as the memory store backend. The agent can store user preferences, conversation summaries, and other personalized interaction information using long-term memory based on user input.
You don't need to build a VeADK project from scratch. We recommend using agentkit-cli to create a project from the Basic Agent App template (the template uses the VeADK framework). After the template is created, you need to make the following modifications:
LongTermMemory to the Agentagentkit.yamlmem0ai==0.1.118 to requirements.txtrunner.save_session_to_long_term_memory after each round of conversation to save the dialogue results to long-term memoryFinally, your code file should look like this:
'''
+**simple agent demo app**
+
+Before running, the user must set the following environment variables; otherwise, runtime exceptions will inevitably occur:
+- MODEL_AGENT_NAME # model id in Volcano Engine Ark platform
+- MODEL_AGENT_API_KEY # model api key in Volcano Engine Ark platform
+
+MODEL_AGENT_NAME and MODEL_AGENT_API_KEY are used to access the model service of the Volcano Engine Ark platform.
+'''
+import logging
+import os
+
+from veadk import Agent, Runner
+from veadk.memory.long_term_memory import LongTermMemory
+
+
+from agentkit.apps import AgentkitSimpleApp
+
+logger = logging.getLogger(__name__)
+
+index = "simple_app" # required for viking backend, arbitrary for mem0 backend
+
+backend = "mem0" # one of "mem0", "viking_mem"
+if backend == "viking_mem":
+ collection_name = os.getenv("DATABASE_VIKINGMEM_COLLECTION")
+ if not collection_name:
+ raise ValueError("DATABASE_VIKINGMEM_COLLECTION environment variable is not set")
+ index = collection_name
+
+app = AgentkitSimpleApp()
+long_term_memory = LongTermMemory(
+ backend=backend,
+ index=index
+)
+
+agent = Agent(
+ name="simple_app_agent",
+ instruction="You are a helpful assistant.",
+ long_term_memory=long_term_memory
+)
+runner = Runner(agent=agent)
+
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ prompt = payload["prompt"]
+ user_id = headers["user_id"]
+ session_id = headers["session_id"]
+
+ logger.info(
+ f"Running agent with prompt: {prompt}, user_id: {user_id}, session_id: {session_id}"
+ )
+ response = await runner.run(messages=prompt, user_id=user_id, session_id=session_id)
+
+ logger.info(f"Run response: {response}")
+
+ # save the teaching prompt and answer in long term memory
+ await runner.save_session_to_long_term_memory(session_id=session_id, user_id=user_id)
+
+ return response
+
+
+@app.ping
+def ping() -> str:
+ return "pong!"
+
+
+if __name__ == "__main__":
+ app.run(host="0.0.0.0", port=8000)Please add the following configuration to your agentkit.yaml file:
# When the long-term memory backend is mem0, add the following configuration
+launch_types:
+ cloud:
+ runtime_envs:
+ DATABASE_MEM0_BASE_URL: <your mem0 url>
+ DATABASE_MEM0_API_KEY: <your mem0 api key>
+
+# When the long-term memory backend is VikingDB, add the following configuration
+launch_types:
+ cloud:
+ runtime_envs:
+ DATABASE_VIKINGMEM_COLLECTION: <your vikingdb collection name>
+ DATABASE_VIKINGMEM_MEMORY_TYPE: <your vikingdb memory type, defaults to "event_v1", separate multiple by comma, e.g. event_v1,event_v2>Run agentkit launch. The Runtime connection information will be automatically saved to the agentkit.yaml file.
Execute the following command to invoke:
agentkit invoke "My secret is 0xabcd"This will automatically use user_id="agentkit_user", session_id="agentkit_sample_session" to invoke the agent.
In the first invocation, you saved the password. We need to change the session_id to verify whether the Agent can correctly read information from the memory store. We recommend waiting approximately 1 minute for the long-term memory extraction to complete before invoking again.
agentkit invoke \\
+ --payload '{"prompt": "What is my secret?"}' \\
+ --headers '{"user_id": "agentkit_user", "session_id": "s123"}'You will see that the Agent successfully reads information from the memory store and tells you the password is 0xabcd.
AgentKit Knowledge provides one-click configuration and import capabilities for mainstream knowledge bases, enabling easy association with knowledge bases on the AgentKit platform. It offers unified knowledge base interfaces and framework integration, enhancing the convenience of using different knowledge bases for Agents.
The steps are as follows:
Through the Volcano Engine Console, create a knowledge base for your agent using VikingDB-Knowledge, and add the following content as qa.md to the customer_support knowledge base.
# Intelligent Customer Service Knowledge Base
+
+## 1. Company Introduction
+
+VE Technology is a high-tech company specializing in intelligent customer service and knowledge management. Our core product is the **Intelligent Customer Service System**, which provides efficient and intelligent automated customer service solutions for enterprise clients through natural language processing and knowledge base retrieval.
+
+## 2. Product Features
+
+- **Automatic Q&A**: Quickly respond to common questions based on the knowledge base.
+- **Multi-channel Access**: Support for web, App, WeChat, Feishu, and other channels.
+- **Intelligent Recommendations**: Recommend relevant answers based on context.
+- **Data Analytics**: Provide user question statistics and customer service performance reports.
+- **Self-service Knowledge Base Management**: Support for non-technical personnel to quickly edit knowledge content.
+
+---
+
+## 3. Frequently Asked Questions (FAQ)
+
+### Q1: What languages does the Intelligent Customer Service System support?
+
+A1: Currently supports **Chinese** and **English**, with Japanese, Korean, and other multi-language support to be added gradually.
+
+### Q2: Can the system integrate with existing CRMs?
+
+A2: Yes. Our system supports seamless integration with mainstream CRM systems (such as Salesforce, Zoho, Kingdee) through APIs.
+
+### Q3: What happens if the bot cannot answer a user's question?
+
+A3: The system will automatically transfer the question to a human customer service agent and record the question in the backend for administrators to add to the knowledge base.
+
+### Q4: How often is the knowledge base content updated?
+
+A4: The knowledge base supports **real-time updates**, taking effect immediately after administrators submit changes.
+
+## 4. Contact Us
+
+- Website: [https://www.example.com](https://www.example.com)
+- Support Email: support@volcengine.com
+- Service Hotline: 400-123-4567Through the Volcano Engine Console, import the knowledge base for your agent using Agentkit-Knowledge
On the memory details - integration code page, obtain the connection information.
export DATABASE_VIKING_COLLECTION=customer_support
+export DATABASE_VIKING_PROJECT=default
+export DATABASE_VIKING_REGION=cn-beijingVeADK is an open-source agent development framework that provides development, runtime, and debugging capabilities for agents, maintained by the Volcano Engine team.
The following example demonstrates how to use VeADK to build an agent with knowledge base capabilities, using VikingDB Knowledge as the knowledge base backend. The agent can answer user questions based on the knowledge base according to user input.
You don't need to build a veadk project from scratch. It is recommended to use agentkit-cli to create a project from the Basic Agent App template (the template uses the VeADK framework). After the template is created, you need to make the following modifications:
Knowledgebase to the Agentagentkit.yamlFinally, your code file should look like this:
'''
+**simple agent demo app**
+
+Before running, the user must set the following environment variables; otherwise, runtime exceptions will inevitably occur:
+- MODEL_AGENT_NAME # model id in Volcano Engine Ark platform
+- MODEL_AGENT_API_KEY # model api key in Volcano Engine Ark platform
+
+MODEL_AGENT_NAME and MODEL_AGENT_API_KEY are used to access the model service of the Volcano Engine Ark platform.
+'''
+import logging
+import os
+
+from veadk import Agent, Runner
+from veadk.knowledgebase import KnowledgeBase
+
+
+from agentkit.apps import AgentkitSimpleApp
+
+logger = logging.getLogger(__name__)
+
+collection_name = os.getenv("DATABASE_VIKING_COLLECTION")
+if not collection_name:
+ raise ValueError("DATABASE_VIKING_COLLECTION environment variable is not set")
+
+model_name = "doubao-seed-1-6-250615"
+
+app = AgentkitSimpleApp()
+knowledgebase = KnowledgeBase(backend="viking", index=collection_name)
+
+
+agent = Agent(
+ instruction="Answer customer's questions according to your knowledgebase.",
+ model_name=model_name,
+ knowledgebase=knowledgebase
+)
+runner = Runner(agent=agent)
+
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ prompt = payload["prompt"]
+ user_id = headers["user_id"]
+ session_id = headers["session_id"]
+
+ logger.info(
+ f"Running agent with prompt: {prompt}, user_id: {user_id}, session_id: {session_id}"
+ )
+ response = await runner.run(messages=prompt, user_id=user_id, session_id=session_id)
+
+ logger.info(f"Run response: {response}")
+ return response
+
+
+@app.ping
+def ping() -> str:
+ return "pong!"
+
+
+if __name__ == "__main__":
+ app.run(host="0.0.0.0", port=8000)Please add the following configuration to your agentkit.yaml file:
launch_types:
+ cloud:
+ runtime_envs:
+ DATABASE_VIKING_COLLECTION: <your viking collection name>Run agentkit launch. The built Runtime connection information will be automatically saved in the agentkit.yaml file.
Execute the following to initiate a call:
agentkit invoke "What products do you have?"You will see the Agent successfully retrieve information from the knowledge base and reorganize the language from qa.md to answer you.
AgentKit MCP provides a unified MCP gateway and tool governance hub. Through shared instances, pre-built authentication plugins, and automatic search capabilities, it lowers the barrier to entry, reduces token costs, improves tool hit rates and reliability—allowing teams to focus on business logic and user experience refinement.
Core Positioning: Unified entry point, low-barrier access, and a governable tool ecosystem. It handles MCP access and session persistence, combined with OAuth2 and API-Key authentication plugins, as well as cross-tool semantic search capabilities, forming an engineering backbone that is "easy to integrate, governable, and low-cost."
AgentKit MCP mainly includes MCP Services and MCP Toolsets.
Supports quickly bringing enterprise existing Web/HTTP services and third-party interfaces into Agents. AgentKit supports two paths:
Applicable Scenarios:
As the number of tools grows or when clients have tool limits (e.g., Trae supports up to 50 tools), automatic search condenses the exposure of the "full tool set" to the LLM into two encapsulated tools: search and use. Vector retrieval selects high-match tools, reducing context redundancy and latency while improving call accuracy.
Applicable Scenarios:
search and use, to the LLMAgentKit MCP authentication primarily adopts the OAuth2 Client Credentials pattern, suitable for frontend applications accessing Agent runtime, server-side tasks accessing Agent runtime, and Agents accessing MCP Servers. It also provides API-Key as a low-dependency alternative, with rotation and hosting planned for future releases.
Authentication Mode Distinctions:
Before you begin, you need to prepare:
AccessKey & SecretKey from a Volcengine account with AgentKit enabled
Tip: Make sure the AccessKey has
AgentKitFullAccesspermission.
MCP Service (can be deployed on VeFaaS or publicly accessible locations)
Python 3.10+ installed
Ark API Key
You can use
uvorpython3 -m venvfor virtual environment management. Below we'll useuvas an example.
uvinstallation reference: uv install
Virtual Environment Setup
mkdir agentkit-mcp-quickstart
+cd agentkit-mcp-quickstart
+uv venv --python 3.12.0
+source .venv/bin/activateInstall Dependencies
You can specify a mirror source with
--indexto speed up installation.
uv pip install veadk-python
+uv pip install google-adk
+pip install agentkit-sdk-pythonLog in to the AgentKit Console on Volcengine.
Create an MCP Service for your prepared backend.
Obtain the MCP Service Endpoint and ApiKey after creation. You will see output similar to:
httpUrlis the MCP Service Endpoint,Authorizationis the ApiKey.
{
+ "mcpServers": {
+ "create-http-334df4": {
+ "httpUrl": "https://sd4fc6lpoh486npgcaav0.apigateway-cn-beijing.volceapi.com/mcp/create-http-334df4",
+ "headers": {
+ "Authorization": "Bearer P66l-rpaLbxxxxxxxxxxxxxxo2PQ"
+ }
+ }
+ }
+}Environment Variable Configuration
export MCP_ENDPOINT={{Endpoint obtained in Step 2}}
+export MCP_AUTH_KEY={{ApiKey obtained in Step 2}}
+export API_KEY={{Ark API Key}}Code Example
In the code example below, we use the VeADK framework to create a simple agent for calling MCP services.
import logging
+
+from veadk import Agent, Runner
+from veadk.config import getenv
+from agentkit.apps import AgentkitSimpleApp
+from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, StreamableHTTPConnectionParams
+
+logger = logging.getLogger(__name__)
+
+
+url = getenv("MCP_ENDPOINT")
+mcp_auth_key = getenv("MCP_AUTH_KEY")
+apikey = getenv("API_KEY")
+
+mcp_ecs_toolset = MCPToolset(
+ connection_params=StreamableHTTPConnectionParams(
+ url=url,
+ headers={"Authorization": f"Bearer {mcp_auth_key}"}
+ ),
+)
+
+app = AgentkitSimpleApp()
+
+root_agent = Agent(
+ name="ecs_helper",
+ model_name="doubao-1-5-pro-256k-250115",
+ instruction='''
+ Help user find ECS instances and their details.
+ ''',
+ description="ECS Helper Agent",
+ tools=[mcp_ecs_toolset]
+)
+
+runner = Runner(agent=root_agent)
+
+
+@app.entrypoint
+async def run(payload: dict, headers: dict) -> str:
+ prompt = payload["prompt"]
+ user_id = headers["user_id"]
+ session_id = headers["session_id"]
+
+ logger.info(
+ f"Running agent with prompt: {prompt}, user_id: {user_id}, session_id: {session_id}"
+ )
+
+ # Run agent, automatically handling tool calls
+ response = await runner.run(
+ messages=prompt,
+ user_id=user_id,
+ session_id=session_id
+ )
+
+ logger.info(f"Run response: {response}")
+ return response
+
+@app.ping
+def ping() -> str:
+ """Health check endpoint"""
+ return "pong!"
+
+if __name__ == "__main__":
+ # Start local development server
+ app.run(host="0.0.0.0", port=8000)Execute Request
curl --location 'http://localhost:8000/invoke' \\
+ --header 'Content-Type: application/json' \\
+ --header 'user_id: veadk-test' \\
+ --header 'session_id: local_session' \\
+ --data '{"prompt": "Analyze my ECS instances"}'Execution Result
2025-10-24 20:17:33 | INFO | ark_veauth.py:25 - Fetching ARK token...
+2025-10-24 20:17:33 | INFO | agent.py:118 - Model extra config: {'extra_headers': {'x-is-encrypted': 'true', 'veadk-source': 'veadk', 'veadk-version': '0.2.13', 'User-Agent': 'VeADK/0.2.13', 'X-Client-Request-Id': 'veadk/0.2.13'}, 'extra_body': {'caching': {'type': 'enabled'}, 'expire_at': 1761311852}}
+2025-10-24 20:17:33 | DEBUG | agent.py:127 - LiteLLM client created with config: {'extra_headers': {'x-is-encrypted': 'true', 'veadk-source': 'veadk', 'veadk-version': '0.2.13', 'User-Agent': 'VeADK/0.2.13', 'X-Client-Request-Id': 'veadk/0.2.13'}, 'extra_body': {'caching': {'type': 'enabled'}, 'expire_at': 1761311852}}
+2025-10-24 20:17:33 | INFO | agent.py:153 - VeADK version: 0.2.13
+2025-10-24 20:17:33 | INFO | agent.py:155 - Agent \`ecs_helper\` init done.
+2025-10-24 20:17:33 | DEBUG | agent.py:156 - Agent: {'name': 'ecs_helper', 'tools': [<google.adk.tools.mcp_tool.mcp_toolset.MCPToolset object at 0x7f8b4f24b9b0>], 'model_name': 'doubao-1-5-pro-256k-250115', 'model_api_base': 'https://ark.cn-beijing.volces.com/api/v3/'}
+2025-10-24 20:17:33 | WARNING | runner.py:198 - No short term memory or session service provided, use an in-memory one instead.
+2025-10-24 20:17:33 | INFO | runner.py:217 - No long term memory provided.
+INFO: Started server process [1330124]
+INFO: Waiting for application startup.
+INFO: Application startup complete.
+INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
+2025-10-24 20:18:35 | INFO | runner.py:250 - Run config: speech_config=None response_modalities=None save_input_blobs_as_artifacts=False support_cfc=False streaming_mode=<StreamingMode.NONE: None> output_audio_transcription=AudioTranscriptionConfig() input_audio_transcription=AudioTranscriptionConfig() realtime_input_config=None enable_affective_dialog=None proactivity=None session_resumption=None context_window_compression=None save_live_audio=False max_llm_calls=100
+2025-10-24 20:18:35 | DEBUG | runner.py:265 - Auto create session: local_session, user_id: veadk-test, app_name: veadk_default_app
+2025-10-24 20:18:38 | DEBUG | runner.py:280 - Function call: id='call_xbyfcvc86wc26mbxz39vst12' args={'region': 'cn-beijing', 'needNum': 10} name='describe_instances'
+2025-10-24 20:19:14 | DEBUG | runner.py:288 - Event output: Here are your ECS instance details:
+1. **Instance 1**:
+ - **Instance ID**: i-ye7irm2sqobw80cqxd40
+ - **Creation Time**: 2025-10-23T21:36:31+08:00
+ - **Billing Method**: PostPaid (Pay-as-you-go)
+ - **Instance Type**: ecs.e-c1m2.xlarge
+ - **CPU**: 4 cores (2 cores, 2 threads per core)
+ - **Memory**: 8192MB
+ - **OS**: Windows Server 2022 Datacenter Edition 64-bit Chinese
+ - **Image ID**: image-ye5907jc6ikhx1exow93
+ - **Status**: RUNNING
+ - **Availability Zone**: cn-beijing-a
+2. **Instance 2**:
+ - **Instance ID**: i-ye7ipm0dtsqc6imh310d
+ - **Creation Time**: 2025-10-23T21:05:44+08:00
+ - **Billing Method**: PostPaid (Pay-as-you-go)
+ - **Instance Type**: ecs.e-c1m2.xlarge
+ - **CPU**: 4 cores (2 cores, 2 threads per core)
+ - **Memory**: 8192MB
+ - **OS**: Debian 12 64 bit
+ - **Image ID**: image-ydzwsvy72n46nmxzvafi
+ - **Status**: RUNNING
+ - **Availability Zone**: cn-beijing-a
+3. **Instance 3**:
+ - **Instance ID**: i-ye7ilsbbpcbw80ca2ymj
+ - **Creation Time**: 2025-10-23T20:06:54+08:00
+ - **Billing Method**: PostPaid (Pay-as-you-go)
+ - **Instance Type**: ecs.e-c1m2.xlarge
+ - **CPU**: 4 cores (2 cores, 2 threads per core)
+ - **Memory**: 8192MB
+ - **OS**: Windows Server 2022 Datacenter Edition 64-bit Chinese
+ - **Image ID**: image-ye5907jc6ikhx1exow93
+ - **Status**: RUNNING
+ - **Availability Zone**: cn-beijing-a
+4. **Instance 4**:
+ - **Instance ID**: i-ye7fg1hgqoxjd1utrfy3
+ - **Creation Time**: 2025-10-22T14:57:49+08:00
+ - **Billing Method**: PostPaid (Pay-as-you-go)
+ - **Instance Type**: ecs.e-c1m2.xlarge
+ - **CPU**: 4 cores (2 cores, 2 threads per core)
+ - **Memory**: 8192MB
+ - **OS**: Windows Server 2022 Datacenter Edition 64-bit Chinese
+ - **Image ID**: image-ye5907jc6ikhx1exow93
+ - **Status**: RUNNING
+ - **Availability Zone**: cn-beijing-a
+5. **Instance 5**:
+ - **Instance ID**: i-ye5ejwoow0cva4fqydfc
+ - **Creation Time**: 2025-09-24T14:25:37+08:00
+ - **Billing Method**: PostPaid (Pay-as-you-go)
+ - **Instance Type**: ecs.e-c1m2.xlarge
+ - **CPU**: 4 cores (2 cores, 2 threads per core)
+ - **Memory**: 8192MB
+ - **OS**: Windows Server 2022 Datacenter Edition 64-bit Chinese
+ - **Image ID**: image-ye5907jc6ikhx1exow93
+ - **Status**: RUNNING
+ - **Availability Zone**: cn-beijing-a
+6. **Instance 6**:
+ - **Instance ID**: i-ye5ejub08wbw80bpd7hr
+ - **Creation Time**: 2025-09-24T14:24:35+08:00
+ - **Billing Method**: PostPaid (Pay-as-you-go)
+ - **Instance Type**: ecs.e-c1m2.xlarge
+ - **CPU**: 4 cores (2 cores, 2 threads per core)
+ - **Memory**: 8192MB
+ - **OS**: Windows Server 2022 Datacenter Edition 64-bit Chinese
+ - **Image ID**: image-ye5907jc6ikhx1exow93
+ - **Status**: RUNNING
+ - **Availability Zone**: cn-beijing-a
+7. **Instance 7**:
+ - **Instance ID**: i-ye5e5jyq68bw80c889i5
+ - **Creation Time**: 2025-09-24T10:44:54+08:00
+ - **Billing Method**: PostPaid (Pay-as-you-go)
+ - **Instance Type**: ecs.e-c1m2.xlarge
+ - **CPU**: 4 cores (2 cores, 2 threads per core)
+ - **Memory**: 8192MB
+ - **OS**: Windows Server 2022 Datacenter Edition 64-bit Chinese
+ - **Image ID**: image-ye5907jc6ikhx1exow93
+ - **Status**: RUNNING
+ - **Availability Zone**: cn-beijing-a
+8. **Instance 8**:
+ - **Instance ID**: i-ye5c4jbx8gqc6ily6b30
+ - **Creation Time**: 2025-09-23T16:02:05+08:00
+ - **Billing Method**: PostPaid (Pay-as-you-go)
+ - **Instance Type**: ecs.e-c1m2.xlarge
+ - **CPU**: 4 cores (2 cores, 2 threads per core)
+ - **Memory**: 8192MB
+ - **OS**: Windows Server 2022 Datacenter Edition 64-bit Chinese
+ - **Image ID**: image-ye5907jc6ikhx1exow93
+ - **Status**: RUNNING
+ - **Availability Zone**: cn-beijing-a
+9. **Instance 9**:
+ - **Instance ID**: i-ye5c4end34xjd1umbfns
+ - **Creation Time**: 2025-09-23T16:00:05+08:00
+ - **Billing Method**: PostPaid (Pay-as-you-go)
+ - **Instance Type**: ecs.e-c1m2.xlarge
+ - **CPU**: 4 cores (2 cores, 2 threads per core)
+ - **Memory**: 8192MB
+ - **OS**: Debian 12 64 bit
+ - **Image ID**: image-ydzwsvfxhokhx11pdmlv
+ - **Status**: RUNNING
+ - **Availability Zone**: cn-beijing-a
+10. **Instance 10**:
+ - **Instance ID**: i-ye5blj0xdsxjd1tk1vfh
+ - **Creation Time**: 2025-09-23T11:09:46+08:00
+ - **Billing Method**: PostPaid (Pay-as-you-go)
+ - **Instance Type**: ecs.e-c1m2.xlarge
+ - **CPU**: 4 cores (2 cores, 2 threads per core)
+ - **Memory**: 8192MB
+ - **OS**: Debian 12 64 bit
+ - **Image ID**: image-ydzwsvfxhokhx11pdmlv
+ - **Status**: RUNNING
+ - **Availability Zone**: cn-beijing-a
+
+All 10 instances are pay-as-you-go with type ecs.e-c1m2.xlarge. Most use Windows Server 2022 Datacenter Edition 64-bit Chinese, with a few using Debian 12 64-bit. All are currently running in availability zone cn-beijing-a. If you need further analysis or have other operation requirements, feel free to ask.{agent_name}:{image_tag}
-- **镜像信息**:自动保存到配置文件
-- **构建记录**:包含时间戳、镜像 ID 等
-
-### 使用示例
-
-```bash
-# 示例 1:使用默认配置
-agentkit build
-
-# 示例 2:指定配置文件
-agentkit build --config-file ./prod.yaml
-
-# 示例 3:强制重新生成 Dockerfile
-agentkit build --regenerate-dockerfile
-
-# 示例 4:配置更新后强制刷新
-agentkit build --config-file ./prod.yaml --regenerate-dockerfile
-```
-
-#### 自定义构建示例
-
-**示例 5:使用 Alpine 基础镜像**
-
-1. 修改 `agentkit.yaml`:
-```yaml
-docker_build:
- base_image: "python:3.12-alpine"
- build_script: "scripts/alpine-setup.sh"
-```
-
-2. 创建 `scripts/alpine-setup.sh`:
-```bash
-#!/bin/sh
-apk add --no-cache gcc musl-dev postgresql-dev
-```
-
-3. 构建:
-```bash
-agentkit build
-```
-
-**示例 6:安装系统依赖(C 扩展)**
-
-1. 修改 `agentkit.yaml`:
-```yaml
-docker_build:
- build_script: "scripts/install-deps.sh"
-```
-
-2. 创建 `scripts/install-deps.sh`:
-```bash
-#!/bin/bash
-apt-get update && apt-get install -y \
- gcc g++ \
- libpq-dev \
- libxml2-dev \
- libxslt1-dev
-```
-
-3. 构建:
-```bash
-agentkit build
-```
-
-**示例 7:Golang 多阶段构建**
-
-修改 `agentkit.yaml`:
-```yaml
-docker_build:
- base_image:
- builder: "golang:1.23-alpine"
- runtime: "alpine:3.19"
- build_script: "scripts/install-certs.sh"
-```
-
-构建:
-```bash
-agentkit build
-```
-
-### 注意事项
-
-**Local 模式前提**:
-- ✅ 确保 Docker 已安装并运行
-- ✅ Docker daemon 可正常访问
-
-**Cloud 模式前提**:
-- ✅ 设置 AK/SK 环境变量
-- ✅ 确保网络能访问火山引擎
-
-**Docker 构建自定义**:
-- ✅ 构建脚本的路径,请填写相对于项目根目录的相对路径
-- ✅ 脚本会自动获得执行权限
-- ✅ 构建脚本不存在会记录警告但不会中断构建
-- ✅ Dockerfile 自动生成,配置变化时自动更新
-- ✅ 旧版本 Dockerfile 会备份到 `.agentkit/dockerfile_backups/`
-- ✅ 删除 Dockerfile 元数据头后不再自动管理
-
-**提示**:构建信息会自动更新到配置文件,供 `deploy` 命令使用
-
----
-
-## agentkit deploy
-
-将构建好的镜像启动运行,让 Agent 对外提供服务。
-
-### 使用方法
-
-```bash
-agentkit deploy [选项]
-```
-
-### 参数说明
-
-`--config-file` 配置文件路径
-- 指定配置文件位置
-- 默认:`agentkit.yaml`
-
-### 部署过程
-
-根据配置的 `launch_type` 自动选择部署目标:
-
-#### 🏠 Local 模式(本地部署)
-在你的电脑上启动容器:
-```
-🚀 开始部署到本地 Docker...
-[1/3] 停止旧版本容器...
-[2/3] 启动新容器...
-[3/3] 验证容器状态...
-✅ 部署成功!容器正在运行
-🌐 访问地址: http://localhost:8000
-```
-预计耗时:10-30 秒
-
-#### ☁️ Cloud 模式(云端部署)
-在火山引擎上创建 Runtime:
-```
-🚀 开始部署到云端平台...
-✅ 生成 Runtime 名称: my-agent-20250120-abc123
-✅ 创建 Runtime: r-xxxxxx
-⏳ 等待 Runtime 就绪...
-✅ Runtime 已就绪!
-🌐 访问地址: http://xxx.apigateway-cn-beijing.volceapi.com
-```
-预计耗时:1-2 分钟
-
-### 使用示例
-
-```bash
-# 示例 1:部署到默认环境
-agentkit deploy
-
-# 示例 2:部署到生产环境
-agentkit deploy --config-file ./prod.yaml
-```
-
-### 部署完成后
-
-**Local 模式**:
-- ✅ 容器在本地运行
-- ✅ 可通过 `localhost:端口` 访问
-- ✅ 自动进行健康检查
-
-**Cloud 模式**:
-- ✅ Runtime 在云端运行
-- ✅ 获得一个公网可访问的 URL
-- ✅ 自动验证 Runtime 状态
-
----
-
-## agentkit launch
-
-构建 + 部署,一步完成!相当于自动执行 `build` 再执行 `deploy`。
-
-### 使用方法
-
-```bash
-agentkit launch [选项]
-```
-
-### 参数说明
-
-`--config-file` 配置文件路径
-- 指定配置文件位置
-- 默认:`agentkit.yaml`
-
-### 执行流程
-
-```
-🚀 开始启动 Agent...
-
-━━━ 第一步:构建镜像 ━━━
-🔨 读取配置: agentkit.yaml
-🔨 开始构建...
-✅ 构建完成
-
-━━━ 第二步:部署应用 ━━━
-🚀 开始部署...
-✅ 部署完成
-
-✨ Agent 已成功启动!
-```
-
-### 使用示例
-
-```bash
-# 示例 1:一键启动
-agentkit launch
-
-# 示例 2:启动到生产环境
-agentkit launch --config-file ./prod.yaml
-```
-
-### 为什么用 launch
-
-- ⚡ **省时省力** - 一个命令代替两个
-- 🔒 **版本一致** - 确保构建和部署使用同一配置
-- 🚀 **快速迭代** - 改完代码立即测试
-
----
-
-## agentkit invoke
-
-向已部署的 Agent 发送测试请求,验证功能是否正常。
-
-### 使用方法
-
-```bash
-agentkit invoke [消息内容] [选项]
-```
-
-⚠️ **重要**:必须提供消息内容或 `--payload` 选项之一,**两者不能同时使用**
-
-### 参数说明
-
-**消息内容**
-- 直接在命令后面输入要发送的文字,不需要加任何选项标记
-- 会自动包装成 {"prompt": "你的消息"}
-- 不能和 `--payload` 同时使用
-- 示例:`agentkit invoke "你好"` 或 `agentkit invoke "今天天气怎么样?"`
-
-**选项**
-
-`--payload, -p` 自定义请求数据
-- 用 JSON 格式指定完整的请求内容
-- 不能和消息内容同时使用
-- 示例:--payload '{"prompt": "你好", "context": "greeting"}'
-
-`--headers, -h` 自定义请求头
-- 用 JSON 格式指定 HTTP 请求头
-- 默认会自动添加 `user_id` 和 `session_id`
-- 示例:--headers '{"user_id": "test123"}'
-
-`--apikey, -ak` API 密钥
-- 云端部署(Cloud 模式)时可能需要
-- 用于身份验证
-- 可选参数
-
-`--config-file` 配置文件路径
-- 指定配置文件位置
-- 默认:当前目录的 `agentkit.yaml`
-
-### 使用示例
-
-#### 示例 1:直接发送消息(最简单)
-
-```bash
-agentkit invoke "今天杭州天气如何?"
-```
-
-等同于发送以下 JSON:
-```json
-{
- "prompt": "今天杭州天气如何?"
-}
-```
-
-#### 示例 2:自定义请求内容
-
-```bash
-agentkit invoke --payload '{"prompt": "杭州天气?", "user_location": "杭州"}'
-```
-
-#### 示例 3:带请求头
-
-```bash
-agentkit invoke \
- --payload '{"prompt": "杭州天气?"}' \
- --headers '{"user_id": "user123", "session_id": "sess456"}'
-```
-
-#### 示例 4:云端部署(带 API Key)
-
-```bash
-agentkit invoke "你好" --apikey your_api_key_here
-```
-
-### 运行效果
-
-```
-💬 正在调用 Agent...
-✅ Runtime ID: r-xxxxxx
-🌐 调用地址: http://xxx.apigateway-cn-beijing.volceapi.com
-✅ 调用成功!
-
-📡 Agent 响应:
-杭州今天天气晴,温度 22°C,适合出行。
-```
-
-### 注意事项
-
-- ⚠️ 消息内容和 `--payload` 只能选一个
-- ⚠️ 云端部署可能需要 API Key
-- ⚠️ 调用前确保 Agent 已部署(用 `agentkit status` 检查)
-
----
-
-## agentkit status
-
-查看 Agent 的运行状态,包括是否在线、访问地址等信息。
-
-### 使用方法
-
-```bash
-agentkit status [选项]
-```
-
-### 参数说明
-
-`--config-file` 配置文件路径
-- 指定配置文件位置
-- 默认:`agentkit.yaml`
-
-### 输出示例
-
-#### 🏠 Local 模式
-
-```
-✅ 容器名称: my-agent
-✅ 运行状态: running
-🌐 访问地址: http://localhost:8000
-
-详细信息:
-{
- "container_id": "abc123...",
- "status": "running",
- "ports": ["8000:8000"],
- "created": "2025-01-20 10:00:00",
- "health": "healthy"
-}
-```
-
-#### ☁️ Cloud 模式
-
-```
-✅ Runtime ID: r-xxxxxx
-✅ 运行状态: Ready
-🌐 访问地址: http://xxx.apigateway-cn-beijing.volceapi.com
-
-详细信息:
-{
- "runtime_id": "r-xxxxxx",
- "runtime_name": "my-agent-20250120-abc123",
- "status": "Ready",
- "endpoint": "http://xxx.apigateway-cn-beijing.volceapi.com",
- "image": "xxx.cr.volces.com/agentkit/my-agent:latest",
- "created_at": "2025-01-20 10:00:00"
-}
-```
-
-### 状态说明
-
-**Local 模式状态**:
-- ✅ `running` - 正常运行中
-- ⏸️ `stopped` - 已停止
-- 🔄 `restarting` - 重启中
-- ❌ `error` - 出现错误
-
-**Cloud 模式状态**:
-- ✅ `Ready` - 就绪,可接收请求
-- 🔄 `Releasing` - 正在部署
-- ❌ `Error` - 运行错误
-- ❌ `Failed` - 部署失败
-
-### 使用示例
-
-```bash
-# 示例 1:查看当前状态
-agentkit status
-
-# 示例 2:查看生产环境状态
-agentkit status --config-file ./prod.yaml
-```
-
----
-
-## agentkit destroy
-
-停止并删除 Agent 实例,释放资源。⚠️ 这是不可逆操作!
-
-### 使用方法
-
-```bash
-agentkit destroy [选项]
-```
-
-### 参数说明
-
-`--force` 强制删除
-- 跳过确认提示,直接删除
-- 默认不开启(会要求确认)
-- 谨慎使用!
-
-`--config-file` 配置文件路径
-- 指定配置文件位置
-- 默认:`agentkit.yaml`
-
-### 安全确认
-
-默认会要求你确认操作:
-
-```
-🗑️ 准备销毁运行中的 Agent...
-⚠️ 此操作不可恢复!
-确定要继续吗?[y/N]: y
-```
-
-跳过确认(不推荐):
-```bash
-agentkit destroy --force
-```
-
-### 会删除什么
-
-#### 🏠 Local 模式
-- ✅ 停止 Docker 容器
-- ✅ 删除容器实例
-- ⚠️ 镜像会保留(可手动删除)
-
-#### ☁️ Cloud 模式
-- ✅ 删除 Runtime 实例
-- ✅ 释放云端资源
-- ⚠️ 镜像会保留(可在 CR 中手动删除)
-
-### 运行效果
-
-```
-🗑️ 开始销毁 Agent 资源...
-✅ 停止 Runtime: r-xxxxxx
-✅ 删除 Runtime 成功
-✅ 资源已清理完成
-
-提示:配置文件和镜像已保留,可随时重新部署。
-```
-
-### 使用示例
-
-```bash
-# 示例 1:安全删除(推荐)
-agentkit destroy
-
-# 示例 2:强制删除
-agentkit destroy --force
-
-# 示例 3:删除指定环境
-agentkit destroy --config-file ./dev.yaml
-```
-
-### 重要提示
-
-- ⚠️ **不可恢复**:删除后无法撤销,数据将永久丢失
-- ✅ **配置保留**:`agentkit.yaml` 文件不会被删除
-- ✅ **镜像保留**:Docker 镜像不会被删除,可重新部署
-- 💡 **重新部署**:随时可以用 `agentkit deploy` 重新部署
-
----
-
-## 通用选项
-
-所有命令都支持这些选项:
-
-### --help 查看帮助
-
-查看任何命令的详细说明和参数:
-
-```bash
-# 查看某个命令的帮助
-agentkit invoke --help
-agentkit build --help
-
-# 查看所有命令列表
-agentkit --help
-```
-
-### --version 查看版本
-
-显示 CLI 版本信息:
-
-```bash
-agentkit --version
-# 或
-agentkit -v
-```
-
----
-
-## 常用工作流
-
-### 📝 完整开发流程(模板模式)
-
-从零开始到上线的完整步骤:
-
-```bash
-# 1️⃣ 创建项目
-agentkit init weather_agent --template basic
-cd weather_agent
-
-# 2️⃣ 配置应用
-agentkit config
-
-# 3️⃣ 一键部署
-agentkit launch
-
-# 4️⃣ 测试功能
-agentkit invoke "杭州天气怎么样?"
-
-# 5️⃣ 查看状态
-agentkit status
-```
-
-### 🔄 快速部署已有 Agent(包装模式)🆕
-
-将现有的 Agent 快速部署上线:
-
-```bash
-# 1️⃣ 包装现有 Agent 文件
-agentkit init --from-agent ~/my_projects/weather_agent.py
-
-# 2️⃣ 进入项目目录
-cd agentkit-weather_agent
-
-# 3️⃣ (可选)配置应用
-agentkit config
-
-# 4️⃣ 一键部署
-agentkit launch
-
-# 5️⃣ 测试功能
-agentkit invoke "今天天气如何?"
-
-# 6️⃣ 查看状态
-agentkit status
-```
-
-### 🔄 快速迭代流程
-
-修改代码后的更新流程:
-
-```bash
-# 方式 1:分步执行(推荐调试时使用)
-agentkit build # 重新构建
-agentkit deploy # 重新部署
-agentkit invoke "测试" # 测试验证
-
-# 方式 2:一键更新(推荐日常开发)
-agentkit launch # 自动构建+部署
-agentkit invoke "测试" # 测试验证
-```
-
-### 🌍 多环境管理
-
-在开发、测试、生产环境间切换:
-
-```bash
-# 开发环境
-agentkit launch --config-file agentkit.dev.yaml
-agentkit invoke "测试" --config-file agentkit.dev.yaml
-
-# 生产环境
-agentkit launch --config-file agentkit.prod.yaml
-agentkit invoke "测试" --config-file agentkit.prod.yaml
-```
-
----
-
-## 常见问题
-
-遇到错误不要慌,这里有解决方案!
-
-### ❌ 配置文件找不到
-
-```
-Error: Configuration file not found: agentkit.yaml
-```
-
-**原因**:当前目录没有配置文件
-
-**解决**:
-```bash
-# 如果是新项目
-agentkit init my_agent
-
-# 如果已有项目
-agentkit config
-```
-
-### ❌ Docker 没有运行(Local 模式)
-
-```
-Error: Docker daemon not running
-```
-
-**原因**:Docker 服务未启动
-
-**解决**:
-- Windows/Mac:打开 Docker Desktop
-- Linux:`sudo systemctl start docker`
-
-### ❌ 云端凭证未配置(Cloud 模式)
-
-```
-Error: VOLC_ACCESSKEY or VOLC_SECRETKEY not set
-```
-
-**原因**:没有设置火山引擎 AK/SK
-
-**解决**:
-```bash
-export VOLC_ACCESSKEY="你的AccessKey"
-export VOLC_SECRETKEY="你的SecretKey"
-```
-
-### ❌ 构建失败
-
-```
-❌ 构建失败: ...
-```
-
-**可能原因和解决方案**:
-1. **依赖问题** - 检查 `requirements.txt` 是否正确
-2. **代码错误** - 检查 Python 代码是否有语法错误
-3. **网络问题** - 检查网络连接,重试构建
-4. **权限问题** - 确保有 Docker/云端的操作权限
-
-### 💡 调试技巧
-
-**1. 查看详细日志**
-```bash
-# 设置详细日志级别
-export LOG_LEVEL=DEBUG
-agentkit build
-```
-
-**2. 验证配置文件**
-```bash
-# 检查配置是否正确
-cat agentkit.yaml
-```
-
-**3. 分步执行**
-```bash
-# 分开执行,更容易定位问题
-agentkit build # 先构建
-agentkit deploy # 再部署
-# 而不是直接用 launch
-```
-
-**4. 检查运行状态**
-```bash
-# 查看 Agent 是否正常运行
-agentkit status
-```
-
----
-
-## 下一步
-
-- 📖 [配置文件说明](./3.configurations.md) - 深入了解每个配置项
-- 🚀 [快速开始](../1.introduction/3.quickstart.md) - 跟随教程实践
-- ❓ [问题排查](../1.introduction/4.troubleshooting.md) - 更多疑难问题解答
diff --git a/docs/content/2.agentkit-cli/3.configurations.md b/docs/content/2.agentkit-cli/3.configurations.md
deleted file mode 100644
index 48d8251..0000000
--- a/docs/content/2.agentkit-cli/3.configurations.md
+++ /dev/null
@@ -1,637 +0,0 @@
-# 配置文件详解
-
-`agentkit.yaml` 是配置 Agent 的核心文件,包含了所有运行参数。本文档帮你理解每个配置项的作用。
-
-## 文件结构
-
-配置文件由两部分组成:
-
-```yaml
-common:
- # 基础配置(所有模式通用)
- agent_name: my_agent
- entry_point: my_agent.py
- launch_type: cloud
-
-launch_types:
- local:
- # Local 模式的专属配置
- hybrid:
- # Hybrid 模式的专属配置
- cloud:
- # Cloud 模式的专属配置
-```
-
-**两个部分**:
-- **common** - 通用配置,适用于所有部署模式
-- **launch_types** - 针对不同部署模式的特定配置
-
----
-
-## common 配置
-
-所有部署模式都需要的基础配置。
-
-### 配置示例
-
-```yaml
-common:
- agent_name: my_weather_agent # Agent 名称
- entry_point: my_weather_agent.py # 入口文件
- description: 天气查询 Agent # 描述(可选)
- python_version: '3.12' # Python 版本
- dependencies_file: requirements.txt # 依赖文件
- launch_type: cloud # 部署模式
-```
-
-### 配置项详解
-
-#### agent_name(必填)
-
-**Agent 的名字**
-
-- 📝 **作用**:给你的 Agent 起个名字
-- ✅ **规则**:只能用字母、数字、`_`、`-` 和 `.`
-- 🎯 **用途**:
- - Docker 镜像的名字
- - 云端 Runtime 的名字前缀
- - 默认的镜像仓库名
-
-**示例**:
-```yaml
-agent_name: weather_agent # 推荐:简单清晰
-agent_name: financial-analyzer-v2 # 可以:带版本号
-agent_name: customer_support_bot # 可以:描述性强
-```
-
-#### entry_point(必填)
-
-**Agent 代码的入口文件**
-
-- 📝 **作用**:指定运行哪个 Python 文件
-- ✅ **规则**:必须是 `.py` 结尾
-- 🎯 **用途**:容器启动时运行这个文件
-
-**示例**:
-```yaml
-entry_point: app.py # 常用
-entry_point: server.py # 常用
-entry_point: main.py # 常用
-```
-
-#### description(可选)
-
-**Agent 的描述信息**
-
-- 📝 **作用**:简单描述 Agent 是做什么的
-- ✅ **规则**:任意文字
-- 🎯 **用途**:帮助团队成员理解用途
-
-**示例**:
-```yaml
-description: "天气查询 Agent,支持全国主要城市"
-description: "客服助手,处理常见问题"
-```
-
-#### python_version(可选)
-
-**Python 运行版本**
-
-- 📝 **作用**:指定 Python 版本
-- ✅ **默认**:`'3.12'`
-- ⚠️ **注意**:目前只支持 3.12
-
-**示例**:
-```yaml
-python_version: '3.12' # 当前唯一支持的版本
-```
-
-#### dependencies_file(可选)
-
-**依赖包列表文件**
-
-- 📝 **作用**:指定依赖文件位置
-- ✅ **默认**:`requirements.txt`
-- 🎯 **用途**:构建时安装这些依赖
-
-**示例**:
-```yaml
-dependencies_file: requirements.txt # 默认
-dependencies_file: requirements/prod.txt # 自定义路径
-```
-
-#### launch_type(必填)
-
-**部署和运行模式**
-
-- 📝 **作用**:选择在哪里构建和运行
-- ✅ **选项**:`local`、`hybrid`、`cloud`
-
-| 模式 | 适合场景 | 构建位置 | 运行位置 |
-|------|---------|---------|---------|
-| `local` | 本地开发调试 | 本地电脑 | 本地电脑 |
-| `hybrid` | 过渡阶段 | 本地电脑 | 云端平台 |
-| `cloud` | 生产环境 | 云端平台 | 云端平台 |
-
-**示例**:
-```yaml
-launch_type: local # 本地开发
-launch_type: cloud # 生产环境(推荐)
-```
-
----
-
-## Local 模式配置
-
-在本地 Docker 上构建和运行,适合开发调试。
-
-### 配置示例
-
-```yaml
-launch_types:
- local:
- image_tag: latest # 镜像标签
- invoke_port: 8000 # 应用端口
- container_name: my_agent # 容器名称
- runtime_envs: # 环境变量
- MODEL_AGENT_API_KEY: xxx
- ports: # 端口映射
- - "8000:8000"
- restart_policy: unless-stopped # 重启策略
- memory_limit: 1g # 内存限制
- cpu_limit: '1' # CPU 限制
-```
-
-### 配置项详解
-
-#### image_tag
-
-**镜像版本标签**
-
-- 默认:`latest`
-- 作用:区分不同版本的镜像
-- 示例:`latest`、`v1.0`、`dev`
-
-#### invoke_port
-
-**Agent 监听的端口**
-
-- 默认:`8000`
-- 作用:指定应用监听哪个端口
-- ❗ 必须与代码中的端口一致
-
-#### container_name
-
-**Docker 容器名称**
-
-- 默认:使用 `agent_name`
-- 作用:给容器起个名字
-- 可以留空,自动生成
-
-#### runtime_envs
-
-**运行时环境变量**
-
-传递给容器的环境变量,如 API Key、配置参数等。
-
-```yaml
-runtime_envs:
- MODEL_AGENT_API_KEY: your_api_key # 模型 API Key
- DEBUG: 'true' # 开启调试
- LOG_LEVEL: info # 日志级别
-```
-
-#### ports
-
-**端口映射**
-
-将容器内部端口映射到主机端口,格式:`主机端口:容器端口`
-
-```yaml
-ports:
- - "8080:8000" # 主机 8080 映射到容器 8000
- - "9090:9090" # 监控端口
-```
-
-#### restart_policy
-
-**容器重启策略**
-
-- 默认:`unless-stopped`
-- 选项:
- - `no` - 不重启
- - `on-failure` - 失败时重启
- - `always` - 总是重启
- - `unless-stopped` - 除非手动停止,否则重启
-
-#### memory_limit / cpu_limit
-
-**资源限制**
-
-限制容器使用的资源,防止占用过多。
-
-```yaml
-memory_limit: 2g # 限制 2GB 内存
-cpu_limit: '1' # 限制 1 个 CPU 核
-```
-
-### 自动管理的字段
-
-以下字段由 CLI 自动生成和管理,不需要手动配置:
-
-- `container_id` - 容器 ID
-- `image_id` - 镜像 ID
-- `build_timestamp` - 构建时间
-- `deploy_timestamp` - 部署时间
-- `full_image_name` - 完整镜像名
-
----
-
-## Cloud 模式配置
-
-在火山引擎上构建和运行,适合生产环境。
-
-### 配置示例
-
-```yaml
-launch_types:
- cloud:
- region: cn-beijing # 区域
- image_tag: latest # 镜像标签
- ve_cr_instance_name: agentkit-center # CR 实例名
- ve_cr_namespace_name: agentkit # CR 命名空间
- ve_cr_repo_name: my_agent # CR 仓库名
- runtime_envs: # 环境变量
- MODEL_AGENT_API_KEY: xxx # 必填:模型 API Key
- MODEL_AGENT_NAME: ep-xxx # 必填:模型接入点
- tos_bucket: agentkit-20250120-xxx # 对象存储桶(自动创建)
-```
-
-### 配置项详解
-
-#### region
-
-**火山引擎区域**
-
-- 默认:`cn-beijing`
-- 作用:选择服务运行的地理位置
-- 可选:`cn-beijing`、`cn-shanghai`、`cn-guangzhou`
-
-💡 **建议**:选择离用户最近的区域,降低延迟
-
-#### image_tag
-
-**镜像版本标签**
-
-- 默认:`latest`
-- 作用:区分不同版本
-- 示例:`latest`、`v1.0.0`、`prod-2025`
-
-#### ve_cr_instance_name
-
-**CR 镜像仓库实例名**
-
-- 默认:自动创建
-- 作用:Docker 镜像存储在哪个 CR 实例
-
-**使用方式**:
-```yaml
-# 方式 1:使用已有实例
-ve_cr_instance_name: my-existing-cr
-
-# 方式 2:让 CLI 自动创建
-ve_cr_instance_name: Auto
-```
-
-#### ve_cr_namespace_name
-
-**CR 命名空间**
-
-- 默认:`agentkit`
-- 作用:组织和管理镜像
-- 自动创建:不存在时自动创建
-
-#### ve_cr_repo_name
-
-**CR 仓库名称**
-
-- 默认:使用 `agent_name`
-- 作用:存储镜像的仓库
-- 自动创建:不存在时自动创建
-
-#### runtime_envs
-
-**运行时环境变量**
-
-Agent 运行时需要的配置,最重要的是模型 API 凭证。
-
-**必须配置**:
-```yaml
-runtime_envs:
- MODEL_AGENT_API_KEY: xxx # 火山方舟 API Key
- MODEL_AGENT_NAME: ep-xxx # 火山方舟接入点 ID
-```
-
-**可选配置**(增强功能):
-```yaml
-runtime_envs:
- # 基础配置
- MODEL_AGENT_API_KEY: xxx
- MODEL_AGENT_NAME: ep-xxx
-
- # 可观测性(日志、监控、链路追踪)
- OBSERVABILITY_OPENTELEMETRY_APMPLUS_API_KEY: xxx
- OBSERVABILITY_OPENTELEMETRY_APMPLUS_ENDPOINT: http://apmplus-cn-beijing.volces.com:4317
- OBSERVABILITY_OPENTELEMETRY_APMPLUS_SERVICE_NAME: my_agent
-
- # 其他配置
- DEBUG: 'true' # 开启调试模式
- LOG_LEVEL: info # 设置日志级别
-```
-
-#### tos_bucket
-
-**对象存储桶**
-
-- 默认:自动创建
-- 作用:存储代码压缩包(用于云端构建)
-- 自动管理:CLI 会自动创建和管理
-
-### 自动管理的字段
-
-以下字段由 CLI 自动生成和管理,不需要手动配置:
-
-**存储相关**
-- `tos_prefix` - 对象存储前缀
-- `tos_object_key` - 代码包的存储路径
-- `tos_object_url` - 代码包的访问地址
-
-**构建相关**
-- `cp_workspace_name` - 构建工作区名称
-- `cp_pipeline_name` - 构建流水线名称
-- `cp_pipeline_id` - 流水线 ID
-- `build_timeout` - 构建超时时间(默认 3600 秒)
-
-**镜像相关**
-- `ve_cr_region` - 镜像仓库区域
-- `ve_cr_image_full_url` - 完整的镜像 URL
-
-**运行时相关**
-- `ve_runtime_id` - Runtime 实例 ID
-- `ve_runtime_name` - Runtime 名称
-- `ve_runtime_endpoint` - 访问地址
-- `ve_runtime_apikey` - API 密钥
-- `build_timestamp` - 构建时间
-- `deploy_timestamp` - 部署时间
-
----
-
-## Hybrid 模式配置
-
-本地构建,云端运行。结合了 Local 和 Cloud 的配置项。
-
-### 配置示例
-
-```yaml
-launch_types:
- hybrid:
- # Local 模式的配置(构建相关)
- image_tag: latest # 镜像标签
- invoke_port: 8000 # 应用端口
-
- # Cloud 模式的配置(部署相关)
- region: cn-beijing # 云端区域
- ve_cr_instance_name: my-cr # CR 实例
- ve_cr_namespace_name: agentkit
- ve_cr_repo_name: my_agent
- runtime_envs:
- MODEL_AGENT_API_KEY: xxx
-```
-
-### 配置说明
-
-Hybrid 模式组合了两种模式的配置:
-
-**构建部分**(本地)
-- `image_tag` - 镜像标签
-- `invoke_port` - 应用端口
-
-**部署部分**(云端)
-- `region` - 运行区域
-- `ve_cr_*` - 镜像仓库配置
-- `runtime_envs` - 环境变量
-
-详细说明请参考上面的 Local 和 Cloud 模式配置。
-
----
-
-## 最佳实践
-
-### 🌍 多环境管理
-
-为不同环境创建独立配置文件:
-
-```bash
-agentkit.dev.yaml # 开发环境(local 模式)
-agentkit.test.yaml # 测试环境(hybrid 模式)
-agentkit.prod.yaml # 生产环境(cloud 模式)
-```
-
-**使用方式**:
-```bash
-# 开发
-agentkit launch --config-file agentkit.dev.yaml
-
-# 生产
-agentkit launch --config-file agentkit.prod.yaml
-```
-
-### 🔐 安全管理敏感信息
-
-**❌ 错误做法**(硬编码):
-```yaml
-runtime_envs:
- MODEL_AGENT_API_KEY: c05d49af-1234-5678-abcd-xxxx # 不要这样!
-```
-
-**✅ 正确做法**:
-
-**方案 1**:交互式配置
-```bash
-agentkit config # 运行时输入敏感信息
-```
-
-**方案 2**:使用 .gitignore
-```bash
-# .gitignore 文件
-agentkit.local.yaml # 本地配置不提交
-agentkit.prod.yaml # 生产配置不提交
-*.secret.yaml # 所有包含密钥的配置
-```
-
-**方案 3**:创建配置模板
-```yaml
-# agentkit.yaml.template (提交到 Git)
-runtime_envs:
- MODEL_AGENT_API_KEY: <请填写你的 API Key>
- MODEL_AGENT_NAME: <请填写接入点 ID>
-```
-
-### 📝 添加配置注释
-
-让团队成员更容易理解配置:
-
-```yaml
-common:
- agent_name: weather_agent
- entry_point: app.py
- launch_type: cloud # 生产环境使用云端部署
-
-launch_types:
- cloud:
- region: cn-beijing # 北京区域,离用户最近
- runtime_envs:
- # 火山方舟的模型访问凭证
- MODEL_AGENT_API_KEY: xxx
- MODEL_AGENT_NAME: ep-xxx
-```
-
-### ✅ 定期验证配置
-
-确保配置文件始终有效:
-
-```bash
-# 方式 1:运行配置命令检查
-agentkit config
-
-# 方式 2:查看配置内容
-cat agentkit.yaml
-
-# 方式 3:尝试构建(不部署)
-agentkit build
-```
-
----
-
-## 完整示例
-
-### 📱 本地开发配置
-
-适合快速开发和调试:
-
-```yaml
-common:
- agent_name: dev_weather_agent
- entry_point: app.py
- description: 开发环境的天气查询 Agent
- python_version: '3.12'
- launch_type: local
-
-launch_types:
- local:
- image_tag: dev
- invoke_port: 8000
- runtime_envs:
- MODEL_AGENT_API_KEY: xxx
- DEBUG: 'true' # 开启调试
- LOG_LEVEL: debug # 详细日志
- ports:
- - "8000:8000"
- memory_limit: 512m # 开发环境资源限制小一些
- cpu_limit: '0.5'
-```
-
-### 🚀 生产环境配置
-
-适合正式上线:
-
-```yaml
-common:
- agent_name: prod_weather_agent
- entry_point: server.py
- description: 生产环境的天气查询 Agent
- python_version: '3.12'
- launch_type: cloud
-
-launch_types:
- cloud:
- region: cn-beijing
- image_tag: v1.0.0 # 使用具体版本号
- ve_cr_namespace_name: production
- ve_cr_repo_name: weather_agent
- runtime_envs:
- # 基础配置
- MODEL_AGENT_API_KEY: xxx
- MODEL_AGENT_NAME: ep-xxx
-
- # 可观测性(生产环境推荐开启)
- OBSERVABILITY_OPENTELEMETRY_APMPLUS_API_KEY: xxx
- OBSERVABILITY_OPENTELEMETRY_APMPLUS_ENDPOINT: http://apmplus-cn-beijing.volces.com:4317
- OBSERVABILITY_OPENTELEMETRY_APMPLUS_SERVICE_NAME: prod_weather_agent
-
- # 日志配置
- LOG_LEVEL: info # 生产环境用 info 级别
-```
-
----
-
-## 常见问题
-
-### ❓ 配置文件找不到
-
-```
-Error: Configuration file not found
-```
-
-**解决**:
-```bash
-agentkit init my_agent # 创建新项目
-# 或
-agentkit config # 创建配置
-```
-
-### ❓ YAML 格式错误
-
-```
-Error: Invalid YAML format
-```
-
-**检查清单**:
-- ✅ 使用空格缩进(不要用 Tab)
-- ✅ 检查冒号后面有空格
-- ✅ 字符串包含特殊字符要加引号
-
-### ❓ 必填项缺失
-
-```
-Error: agent_name is required
-```
-
-**解决**:
-```bash
-agentkit config # 重新配置,填写必填项
-```
-
-### ❓ 环境变量不生效
-
-**可能原因**:
-1. 变量名拼写错误
-2. 配置没有保存
-3. 没有重新部署
-
-**解决方法**:
-```bash
-# 1. 检查配置
-cat agentkit.yaml
-
-# 2. 重新部署
-agentkit deploy
-```
-
----
-
-## 下一步
-
-- 📖 [CLI 概览](./1.overview.md) - 了解整体功能和特性
-- 🎮 [命令详解](./2.commands.md) - 学习每个命令的用法
-- 🚀 [快速开始](../1.introduction/3.quickstart.md) - 动手实践完整流程
diff --git a/docs/content/2.agentkit-cli/4.logging.md b/docs/content/2.agentkit-cli/4.logging.md
deleted file mode 100644
index c848bf4..0000000
--- a/docs/content/2.agentkit-cli/4.logging.md
+++ /dev/null
@@ -1,481 +0,0 @@
-# 日志系统
-
-AgentKit CLI 内置了灵活的日志系统,帮助你了解命令执行过程、调试问题和追踪运行状态。
-
-## 默认行为
-
-AgentKit 默认配置如下:
-
-- ✅ **控制台输出**:关闭(不显示日志)
-- ✅ **文件日志**:关闭(不记录日志)
-- 💡 **按需开启**:根据需要通过环境变量开启日志功能
-
-```bash
-# 默认情况下,命令运行时无任何日志输出
-agentkit status
-
-# 如需日志,请通过环境变量开启(见下文)
-```
-
-**日志示例**:
-
-```
-[2025-11-20 14:56:09] [INFO] [agentkit.toolkit.executors] Loading configuration...
-[2025-11-20 14:56:09] [INFO] [agentkit.toolkit.executors] Using launch_type: cloud
-[2025-11-20 14:56:09] [INFO] [agentkit.toolkit.executors] Querying status with cloud strategy...
-[2025-11-20 14:56:09] [INFO] [agentkit.toolkit.executors] Status query completed: running
-```
-
----
-
-## 快速开始
-
-### 开启文件日志
-
-如果需要将日志保存到文件:
-
-```bash
-# 开启文件日志(默认 INFO 级别)
-export AGENTKIT_FILE_ENABLED=true
-
-# 运行命令
-agentkit deploy
-
-# 查看生成的日志文件
-cat .agentkit/logs/agentkit-$(date +%Y%m%d).log
-```
-
-### 开启控制台日志
-
-如果你想在控制台实时查看日志:
-
-```bash
-# 开启控制台日志
-export AGENTKIT_LOG_CONSOLE=true
-
-# 运行命令,现在可以在控制台看到日志了
-agentkit status
-```
-
-### 同时开启控制台和文件日志
-
-```bash
-# 同时开启控制台和文件日志
-export AGENTKIT_LOG_CONSOLE=true
-export AGENTKIT_FILE_ENABLED=true
-
-# 运行命令
-agentkit build
-```
-
-### 调试模式
-
-遇到问题需要详细日志时:
-
-```bash
-# 开启 DEBUG 级别日志(自动开启控制台和文件输出)
-export AGENTKIT_LOG_LEVEL=DEBUG
-export AGENTKIT_LOG_CONSOLE=true
-export AGENTKIT_FILE_ENABLED=true
-
-# 运行命令,查看详细的调试信息
-agentkit build
-```
-
----
-
-## 环境变量配置
-
-通过环境变量,你可以完全自定义日志行为。
-
-### 基础配置
-
-| 环境变量 | 说明 | 默认值 | 示例 |
-|----------|------|--------|------|
-| `AGENTKIT_LOG_CONSOLE` | 是否在控制台显示日志 | `false` | `true` / `false` |
-| `AGENTKIT_FILE_ENABLED` | 是否保存日志到文件 | `false` | `true` / `false` |
-| `AGENTKIT_LOG_LEVEL` | 日志级别(控制台和文件) | `INFO` | `DEBUG` / `INFO` / `WARNING` / `ERROR` |
-| `AGENTKIT_LOG_FILE` | 日志文件路径(开启文件日志时生效) | `.agentkit/logs/agentkit-YYYYMMDD.log` | `/tmp/my-agent.log` |
-
-### 高级配置
-
-分别控制控制台和文件的日志级别:
-
-| 环境变量 | 说明 | 默认值 |
-|----------|------|--------|
-| `AGENTKIT_CONSOLE_LOG_LEVEL` | 控制台日志级别 | `INFO` |
-| `AGENTKIT_FILE_LOG_LEVEL` | 文件日志级别 | `INFO` |
-
-**使用示例**:
-
-```bash
-# 控制台只看重要的错误,文件记录所有信息
-export AGENTKIT_LOG_CONSOLE=true
-export AGENTKIT_CONSOLE_LOG_LEVEL=ERROR
-export AGENTKIT_FILE_LOG_LEVEL=DEBUG
-
-agentkit launch
-```
-
----
-
-## 日志级别说明
-
-AgentKit 支持 5 种日志级别,级别越高,信息越少:
-
-| 级别 | 说明 | 适用场景 |
-|------|------|----------|
-| `DEBUG` | 详细的调试信息 | 问题排查、开发调试 |
-| `INFO` | 常规操作信息(默认) | 了解命令执行过程 |
-| `WARNING` | 警告信息 | 关注潜在问题 |
-| `ERROR` | 错误信息 | 只看失败的操作 |
-| `CRITICAL` | 严重错误 | 只看致命错误 |
-
----
-
-## 常用场景
-
-### 场景 1:正常使用(默认配置)
-
-适合日常使用,无日志输出,保护信息安全。
-
-```bash
-# 无需任何配置,直接使用
-agentkit status
-agentkit deploy
-```
-
-**效果**:
-- ✅ 控制台:干净整洁,无日志输出
-- ✅ 文件:无日志文件生成,保护信息安全
-
----
-
-### 场景 1.1:需要保存日志记录
-
-开启文件日志,便于追溯操作历史:
-
-```bash
-# 开启文件日志
-export AGENTKIT_FILE_ENABLED=true
-
-# 运行命令
-agentkit deploy
-```
-
-**效果**:
-- ✅ 控制台:干净整洁
-- ✅ 日志:自动保存到 `.agentkit/logs/`,默认 INFO 级别
-
----
-
-### 场景 2:调试问题
-
-遇到错误或异常行为时,开启详细日志:
-
-```bash
-# 开启控制台和文件的 DEBUG 日志
-export AGENTKIT_LOG_CONSOLE=true
-export AGENTKIT_FILE_ENABLED=true
-export AGENTKIT_LOG_LEVEL=DEBUG
-
-# 运行命令
-agentkit build
-```
-
-**效果**:
-- ✅ 控制台:显示详细的执行过程
-- ✅ 日志文件:保存完整 DEBUG 信息,便于事后分析
-
----
-
-### 场景 3:CI/CD 环境
-
-在持续集成环境中,需要在控制台看到日志,同时保存完整记录:
-
-```bash
-# 在 CI 配置文件中设置
-export AGENTKIT_LOG_CONSOLE=true
-export AGENTKIT_FILE_ENABLED=true
-export AGENTKIT_CONSOLE_LOG_LEVEL=INFO
-export AGENTKIT_FILE_LOG_LEVEL=DEBUG
-export AGENTKIT_LOG_FILE=/var/log/agentkit/build-${BUILD_ID}.log
-
-# 运行构建
-agentkit launch
-```
-
-**效果**:
-- ✅ 控制台:显示关键信息,便于查看 CI 日志
-- ✅ 日志文件:保存详细信息,便于事后分析
-
----
-
-### 场景 4:生产环境
-
-生产环境只记录警告和错误到文件:
-
-```bash
-export AGENTKIT_FILE_ENABLED=true
-export AGENTKIT_FILE_LOG_LEVEL=WARNING
-export AGENTKIT_LOG_FILE=/var/log/agentkit/production.log
-
-# 运行命令
-agentkit deploy
-```
-
-**效果**:
-- ✅ 控制台:无输出,保持清爽
-- ✅ 日志文件:只记录警告和错误,聚焦问题
-
----
-
-### 场景 5:完全静默
-
-不需要任何日志时(默认行为):
-
-```bash
-# 默认配置即为完全静默,无需设置环境变量
-agentkit status
-
-# 或者显式设置(确保之前的环境变量不影响)
-unset AGENTKIT_LOG_CONSOLE
-unset AGENTKIT_FILE_ENABLED
-```
-
-**效果**:
-- ✅ 控制台:无日志输出
-- ✅ 文件:无日志文件生成
-
----
-
-## 日志文件管理
-
-### 日志文件位置
-
-当开启文件日志后(`AGENTKIT_FILE_ENABLED=true`),日志保存在项目根目录的 `.agentkit/logs/` 文件夹中:
-
-```
-your-project/
-├── .agentkit/
-│ └── logs/
-│ ├── agentkit-20251120.log # 今天的日志
-│ ├── agentkit-20251119.log # 昨天的日志
-│ └── agentkit-20251118.log # 前天的日志
-├── agentkit.yaml
-└── my_agent.py
-```
-
-### 自动清理旧日志
-
-日志文件会随时间增多,建议定期清理:
-
-```bash
-# 删除 7 天前的日志
-find .agentkit/logs -name "agentkit-*.log" -mtime +7 -delete
-
-# 或者手动删除
-rm .agentkit/logs/agentkit-20251101.log
-```
-
-### 自定义日志路径
-
-```bash
-# 保存到指定位置
-export AGENTKIT_LOG_FILE=/tmp/my-custom-agent.log
-
-# 或保存到用户目录
-export AGENTKIT_LOG_FILE=$HOME/.agentkit-logs/agent.log
-
-agentkit deploy
-```
-
----
-
-## 配置优先级
-
-当多种配置方式同时存在时,优先级如下(从高到低):
-
-1. **专用环境变量** - `AGENTKIT_CONSOLE_LOG_LEVEL`
-2. **通用环境变量** - `AGENTKIT_LOG_LEVEL`
-3. **默认值** - `INFO`
-
-**示例**:
-
-```bash
-# 设置通用级别为 INFO
-export AGENTKIT_LOG_LEVEL=INFO
-
-# 设置控制台专用级别为 WARNING(优先级更高)
-export AGENTKIT_CONSOLE_LOG_LEVEL=WARNING
-
-# 结果:控制台显示 WARNING,文件记录 INFO
-agentkit status
-```
-
----
-
-## 故障排查
-
-### 日志文件没有创建
-
-**可能原因**:
-- 文件日志被禁用了
-- 目录权限不足
-
-**解决方法**:
-
-```bash
-# 1. 检查是否禁用了文件日志
-echo $AGENTKIT_FILE_ENABLED # 应该是 true 或为空
-
-# 2. 检查目录权限
-ls -la .agentkit/logs/
-
-# 3. 手动创建目录
-mkdir -p .agentkit/logs
-
-# 4. 确保环境变量正确
-unset AGENTKIT_FILE_ENABLED # 重置为默认值
-```
-
----
-
-### 控制台没有日志输出
-
-**可能原因**:
-- 控制台日志默认是关闭的
-- 日志级别设置过高
-
-**解决方法**:
-
-```bash
-# 1. 开启控制台日志
-export AGENTKIT_LOG_CONSOLE=true
-
-# 2. 设置合适的日志级别
-export AGENTKIT_CONSOLE_LOG_LEVEL=INFO
-
-# 3. 运行命令
-agentkit status
-```
-
----
-
-### 日志太多或太少
-
-**调整日志级别**:
-
-```bash
-# 日志太多 - 只看重要信息
-export AGENTKIT_LOG_LEVEL=WARNING
-
-# 日志太少 - 查看详细信息
-export AGENTKIT_LOG_LEVEL=DEBUG
-```
-
----
-
-## 最佳实践
-
-### 开发环境推荐配置
-
-在你的 `.bashrc` 或 `.zshrc` 中添加(可选):
-
-```bash
-# AgentKit 开发环境配置(根据需要选择)
-# 选项1:只开启控制台日志
-export AGENTKIT_LOG_CONSOLE=true
-
-# 选项2:同时开启控制台和文件日志
-export AGENTKIT_LOG_CONSOLE=true
-export AGENTKIT_FILE_ENABLED=true
-export AGENTKIT_CONSOLE_LOG_LEVEL=INFO
-export AGENTKIT_FILE_LOG_LEVEL=DEBUG
-```
-
-**推荐**:
-- 默认不配置,保持干净
-- 需要调试时临时开启
-- 避免敏感信息意外记录
-
----
-
-### 团队协作
-
-在项目根目录创建 `.env.example` 文件:
-
-```bash
-# AgentKit 日志配置示例
-# 根据需要复制到 .env 并修改
-
-# === 开发环境建议配置 ===
-# 开启控制台日志(便于实时查看)
-AGENTKIT_LOG_CONSOLE=true
-
-# 开启文件日志(便于问题追溯,可选)
-# AGENTKIT_FILE_ENABLED=true
-
-# 设置日志级别
-AGENTKIT_LOG_LEVEL=INFO
-
-# 自定义日志路径(可选)
-# AGENTKIT_LOG_FILE=./logs/my-agent.log
-```
-
-**提醒**:
-- 团队成员根据需求自行调整
-- `.env` 文件应该在 `.gitignore` 中,避免提交个人配置
-- 默认不开启文件日志,保护信息安全
-
----
-
-### 生产部署建议
-
-```bash
-# 生产环境配置
-export AGENTKIT_LOG_CONSOLE=false # 关闭控制台
-export AGENTKIT_FILE_ENABLED=true # 开启文件日志
-export AGENTKIT_FILE_LOG_LEVEL=WARNING # 只记录警告和错误
-export AGENTKIT_LOG_FILE=/var/log/agentkit/prod.log # 统一路径
-```
-
-**优点**:
-- 减少不必要的输出
-- 聚焦重要问题
-- 便于日志管理和监控
-
----
-
-## 总结
-
-AgentKit 的日志系统设计原则:
-
-- 🔒 **安全优先** - 默认不输出日志,避免信息泄露
-- 🎯 **按需启用** - 通过环境变量灵活开启
-- 🔧 **灵活配置** - 控制台和文件可独立控制
-- 📊 **分级控制** - 不同场景使用不同日志级别
-- 📁 **自动管理** - 开启后按日期分割,便于查找
-
-**快速参考**:
-
-```bash
-# 1. 开启文件日志
-export AGENTKIT_FILE_ENABLED=true
-
-# 2. 开启控制台调试
-export AGENTKIT_LOG_CONSOLE=true
-export AGENTKIT_FILE_ENABLED=true
-export AGENTKIT_LOG_LEVEL=DEBUG
-
-# 3. 查看日志文件(需要先开启文件日志)
-cat .agentkit/logs/agentkit-$(date +%Y%m%d).log
-
-# 4. 控制台和文件使用不同级别
-export AGENTKIT_LOG_CONSOLE=true
-export AGENTKIT_FILE_ENABLED=true
-export AGENTKIT_CONSOLE_LOG_LEVEL=ERROR
-export AGENTKIT_FILE_LOG_LEVEL=DEBUG
-```
-
-如有问题,请参考 [故障排查](#故障排查) 章节或联系技术支持。
diff --git a/docs/content/3.agentkit-sdk/1.overview.md b/docs/content/3.agentkit-sdk/1.overview.md
deleted file mode 100644
index 265b50c..0000000
--- a/docs/content/3.agentkit-sdk/1.overview.md
+++ /dev/null
@@ -1,238 +0,0 @@
-# AgentKit SDK 概览
-
-AgentKit SDK 是一个 Python 开发工具包,用于快速构建符合 AgentKit Platform 标准的 Agent 应用。SDK 提供了一套简洁的装饰器和客户端接口,帮助开发者专注于 Agent 业务逻辑的实现。
-
-## 核心架构
-
-AgentKit SDK 采用模块化设计,主要包含以下模块:
-
-### 1. Runtime 应用框架
-
-提供多种应用模式,将用户代码封装为符合 Platform 标准的 HTTP 服务:
-
-#### AgentkitSimpleApp
-最常用的应用框架,适用于标准的 Agent 应用。
-
-**核心装饰器**:
-- `@app.entrypoint` - 定义 Agent 的主入口函数
-- `@app.ping` - 定义健康检查函数
-- `@app.async_task` - 定义异步任务(规划中)
-
-**标准路由**:
-- `/invoke` - Agent 调用端点
-- `/ping` - 健康检查
-- `/health`、`/readiness`、`/liveness` - Kubernetes 就绪探针
-
-#### AgentkitMCPApp
-基于 MCP (Model Context Protocol) 协议的应用框架,用于将工具封装为 MCP 服务。
-
-**核心装饰器**:
-- `@app.tool` - 将函数注册为 MCP 工具
-- `@app.agent_as_a_tool` - 将 Agent 封装为 MCP 工具
-
-#### AgentkitA2aApp
-基于 A2A (Agent-to-Agent) 协议的应用框架,用于构建可互相通信的 Agent。
-
-**核心装饰器**:
-- `@app.agent_executor` - 注册 Agent 执行器
-- `@app.task_store` - 注册任务存储(可选)
-
-### 2. Platform 服务客户端
-
-提供便捷的客户端接口,用于访问 AgentKit Platform 的各项服务。
-
-#### AgentkitMemory
-记忆服务客户端,管理 Agent 的长期和短期记忆。
-
-**主要功能**:
-- `create_memory_collection()` - 创建记忆库
-- `list_memory_collections()` - 列举记忆库
-- `get_memory_collection()` - 获取记忆库详情
-- `update_memory_collection()` - 更新记忆库配置
-- `delete_memory_collection()` - 删除记忆库
-- `get_memory_connection_info()` - 获取连接信息
-
-**设计理念**:控制面和数据面解耦
-- **控制面**(SDK 提供):管理记忆库的创建、配置和获取连接信息
-- **数据面**(ADK 实现):通过 MemoryBase 或 Mem0 协议进行实际的记忆读写
-
-#### AgentkitKnowledge
-知识库服务客户端,管理 Agent 的向量化知识库。
-
-**主要功能**:
-- `list_knowledge_bases()` - 列举知识库
-- `add_knowledge_base()` - 添加知识库
-- `get_knowledge_connection_info()` - 获取知识库连接信息
-- `delete_knowledge_base()` - 删除知识库
-
-**使用场景**:
-- RAG(检索增强生成)应用
-- 文档问答系统
-- 知识图谱集成
-
-#### AgentkitMCP
-MCP Gateway 客户端,用于管理和路由大量 MCP 工具。
-
-**主要功能**:
-- 注册和管理 MCP 服务
-- 工具聚合和智能路由
-- 降低工具集成复杂度
-
-#### AgentkitRuntime
-Runtime 管理客户端,用于管理 Agent 的运行时环境。
-
-**主要功能**:
-- 创建和管理 Runtime 实例
-- 查询 Runtime 状态
-- 配置环境变量和资源
-
-### 3. 基础设施模块
-
-#### BaseAgentkitClient
-所有客户端的基类,提供统一的配置和 HTTP 请求能力。
-
-**配置项**:
-- API 端点配置
-- 认证凭证管理
-- 请求重试和超时
-- 日志和监控
-
-#### Context 管理
-使用 `contextvars` 管理每个请求的上下文信息,包括:
-- 用户身份
-- 会话 ID
-- 请求元数据
-- 链路追踪信息
-
-## 模块依赖关系
-
-```
-AgentKit SDK
-│
-├── Runtime Apps (应用框架层)
-│ ├── AgentkitSimpleApp
-│ ├── AgentkitMCPApp
-│ ├── AgentkitA2aApp
-│ └── AgentkitAgentServerApp
-│
-├── Platform Clients (服务客户端层)
-│ ├── AgentkitMemory
-│ ├── AgentkitKnowledge
-│ ├── AgentkitMCP
-│ └── AgentkitRuntime
-│
-└── Infrastructure (基础设施层)
- ├── BaseAgentkitClient
- ├── Context
- └── Telemetry (可观测性)
-```
-
-## 主要特性
-
-### 1. 装饰器驱动
-使用 Python 装饰器简化应用开发,开发者只需关注业务逻辑:
-
-```python
-from agentkit.apps import AgentkitSimpleApp
-
-app = AgentkitSimpleApp()
-
-@app.entrypoint
-async def run(payload: dict, headers: dict) -> str:
- # 业务逻辑
- return response
-```
-
-### 2. 框架无关
-SDK 不限制使用特定的 Agent 框架,支持:
-- Volcengine ADK (veadk)
-- Google ADK (gadk)
-- LangChain
-- 自定义框架
-
-### 3. 自动化的可观测性
-内置 OpenTelemetry 支持,自动收集:
-- 链路追踪(Tracing)
-- 性能指标(Metrics)
-- 日志(Logging)
-
-### 4. 生产就绪
-提供完整的生产环境支持:
-- 健康检查端点
-- 优雅关闭
-- 错误处理
-- 请求重试
-
-### 5. 类型安全
-完整的 Python 类型注解,提供:
-- IDE 自动补全
-- 类型检查
-- 更好的代码可维护性
-
-## 快速开始
-
-### 安装
-
-```bash
-pip install agentkit-sdk-python
-```
-
-### 创建一个简单的 Agent
-
-```python
-from agentkit.apps import AgentkitSimpleApp
-from veadk import Agent, Runner
-from veadk.tools.demo_tools import get_city_weather
-
-app = AgentkitSimpleApp()
-agent = Agent(tools=[get_city_weather])
-runner = Runner(agent=agent)
-
-@app.entrypoint
-async def run(payload: dict, headers: dict) -> str:
- prompt = payload["prompt"]
- user_id = headers["user_id"]
- session_id = headers["session_id"]
-
- response = await runner.run(
- messages=prompt,
- user_id=user_id,
- session_id=session_id
- )
- return response
-
-@app.ping
-def ping() -> str:
- return "pong!"
-
-if __name__ == "__main__":
- app.run(host="0.0.0.0", port=8000)
-```
-
-### 使用 Platform 服务
-
-```python
-from agentkit.memory import AgentkitMemory
-from agentkit.base_client import ApiConfig
-
-# 初始化客户端
-config = ApiConfig(
- access_key="your_ak",
- secret_key="your_sk"
-)
-memory_client = AgentkitMemory(config)
-
-# 创建记忆库
-response = memory_client.create_memory_collection(
- name="my-memory",
- short_term_configuration={...},
- long_term_configuration={...}
-)
-print(f"Memory ID: {response.id}")
-```
-
-## 下一步
-
-- 查看[注解使用文档](./2.annotation.md)了解各种装饰器的详细用法
-- 参考 `samples/` 目录下的完整示例
-- 阅读 Platform 服务客户端的 API 文档
diff --git a/docs/content/3.agentkit-sdk/2.annotation.md b/docs/content/3.agentkit-sdk/2.annotation.md
deleted file mode 100644
index e4e009a..0000000
--- a/docs/content/3.agentkit-sdk/2.annotation.md
+++ /dev/null
@@ -1,631 +0,0 @@
-# 注解使用指南
-
-AgentKit SDK 提供了一套简洁的装饰器(注解),用于快速构建不同类型的 Agent 应用。本文档详细介绍各种注解的使用方法和最佳实践。
-
-## Simple Agent 注解
-
-`AgentkitSimpleApp` 是最常用的应用框架,提供标准的 HTTP 服务端点。
-
-### @app.entrypoint
-
-定义 Agent 的主入口函数,处理来自 Platform 的调用请求。
-
-#### 函数签名
-
-```python
-@app.entrypoint
-async def run(payload: dict, headers: dict) -> str:
- pass
-```
-
-#### 参数说明
-
-- **payload** (dict): 请求体,包含用户输入和配置
- - `prompt` (str): 用户输入的提示词
- - 其他自定义字段
-
-- **headers** (dict): 请求头,包含上下文信息
- - `user_id` (str): 用户 ID
- - `session_id` (str): 会话 ID
- - `request_id` (str): 请求追踪 ID
- - 其他自定义头部
-
-- **返回值** (str): Agent 的响应结果
-
-#### 完整示例
-
-```python
-from agentkit.apps import AgentkitSimpleApp
-from veadk import Agent, Runner
-from veadk.tools.demo_tools import get_city_weather
-
-app = AgentkitSimpleApp()
-agent = Agent(tools=[get_city_weather])
-runner = Runner(agent=agent)
-
-@app.entrypoint
-async def run(payload: dict, headers: dict) -> str:
- """Agent 主入口函数"""
- # 1. 提取输入参数
- prompt = payload.get("prompt", "")
- user_id = headers.get("user_id", "anonymous")
- session_id = headers.get("session_id", "default")
-
- # 2. 调用 Agent 运行
- response = await runner.run(
- messages=prompt,
- user_id=user_id,
- session_id=session_id
- )
-
- # 3. 返回结果
- return response
-```
-
-#### 注意事项
-
-1. **必须是异步函数**:使用 `async def` 定义
-2. **参数顺序固定**:第一个参数是 payload,第二个是 headers
-3. **返回字符串**:返回值会被自动封装为 JSON 响应
-4. **错误处理**:建议在函数内部处理异常
-
-#### 错误处理示例
-
-```python
-import logging
-
-logger = logging.getLogger(__name__)
-
-@app.entrypoint
-async def run(payload: dict, headers: dict) -> str:
- try:
- prompt = payload["prompt"]
- response = await runner.run(messages=prompt)
- return response
- except KeyError as e:
- logger.error(f"Missing required field: {e}")
- return f"Error: Missing required field {e}"
- except Exception as e:
- logger.error(f"Agent execution failed: {e}")
- return f"Error: {str(e)}"
-```
-
-### @app.ping
-
-定义健康检查函数,用于 Platform 和 Kubernetes 的健康探测。
-
-#### 函数签名
-
-```python
-@app.ping
-def ping() -> str:
- pass
-```
-
-#### 参数说明
-
-- **无参数**:健康检查函数不接收任何参数
-- **返回值** (str): 健康状态信息,通常返回 "pong" 或 "ok"
-
-#### 基本示例
-
-```python
-@app.ping
-def ping() -> str:
- """健康检查"""
- return "pong!"
-```
-
-#### 高级示例:包含依赖检查
-
-```python
-import redis
-from sqlalchemy import create_engine
-
-# 初始化依赖
-redis_client = redis.Redis(host='localhost', port=6379)
-db_engine = create_engine('postgresql://...')
-
-@app.ping
-def ping() -> str:
- """健康检查,包含依赖服务检测"""
- try:
- # 检查 Redis 连接
- redis_client.ping()
-
- # 检查数据库连接
- with db_engine.connect() as conn:
- conn.execute("SELECT 1")
-
- return "ok - all services healthy"
- except Exception as e:
- logger.error(f"Health check failed: {e}")
- return f"degraded - {str(e)}"
-```
-
-#### 注意事项
-
-1. **无参数**:函数签名必须为 `def ping() -> str:`
-2. **同步函数**:使用 `def` 而非 `async def`
-3. **快速响应**:应在 1 秒内返回,避免超时
-4. **轻量级检查**:避免执行耗时操作
-
-#### 可用端点
-
-健康检查函数会自动注册到以下端点:
-- `GET /ping` - 基础健康检查
-- `GET /health` - 健康状态
-- `GET /readiness` - Kubernetes 就绪探针
-- `GET /liveness` - Kubernetes 存活探针
-
-### @app.async_task(规划中)
-
-用于定义异步任务,支持长时间运行的操作。
-
-```python
-@app.async_task
-async def process_long_task(task_id: str, data: dict) -> dict:
- """处理长时间运行的任务"""
- # 长时间运行的逻辑
- result = await heavy_computation(data)
- return result
-```
-
-> **注意**:此功能正在规划中,暂未实现。
-
-## MCP Agent 注解
-
-`AgentkitMCPApp` 用于构建 MCP (Model Context Protocol) 服务,将函数封装为标准的 MCP 工具。
-
-### @app.tool
-
-将函数注册为 MCP 工具,供 LLM 调用。
-
-#### 函数签名
-
-```python
-@app.tool
-def tool_name(param1: str, param2: int) -> dict:
- pass
-```
-
-#### 参数说明
-
-- **函数参数**:工具的输入参数,必须有类型注解
-- **返回值**:工具的执行结果,建议返回 dict 类型
-- **文档字符串**:会作为工具描述,供 LLM 理解工具用途
-
-#### 基本示例
-
-```python
-from agentkit.apps import AgentkitMCPApp
-
-mcp_app = AgentkitMCPApp()
-
-@mcp_app.tool
-def get_city_weather(city: str) -> dict[str, str]:
- """获取城市天气信息
-
- Args:
- city: 城市名称(必须为英文)
-
- Returns:
- 包含天气状况和温度的字典
- """
- weather_data = {
- "beijing": {"condition": "Sunny", "temperature": 25},
- "shanghai": {"condition": "Cloudy", "temperature": 22},
- }
-
- city = city.lower().strip()
- if city in weather_data:
- info = weather_data[city]
- return {"result": f"{info['condition']}, {info['temperature']}°C"}
- else:
- return {"result": f"Weather information not found for {city}"}
-```
-
-#### 异步工具示例
-
-```python
-import aiohttp
-
-@mcp_app.tool
-async def fetch_web_content(url: str) -> dict:
- """获取网页内容
-
- Args:
- url: 网页 URL
-
- Returns:
- 包含网页内容的字典
- """
- async with aiohttp.ClientSession() as session:
- async with session.get(url) as response:
- content = await response.text()
- return {
- "status": response.status,
- "content": content[:1000] # 截取前 1000 字符
- }
-```
-
-#### 注意事项
-
-1. **类型注解必需**:所有参数必须有类型注解,MCP 需要此信息生成工具模式
-2. **详细的文档字符串**:文档字符串会作为工具描述,帮助 LLM 理解工具用途
-3. **同步和异步均可**:支持 `def` 和 `async def`
-4. **返回结构化数据**:建议返回 dict 类型,便于 LLM 解析
-5. **错误处理**:在函数内部处理异常,避免工具调用失败
-
-#### 复杂参数示例
-
-```python
-from typing import List, Optional
-from pydantic import BaseModel
-
-class SearchQuery(BaseModel):
- keywords: List[str]
- max_results: int = 10
- filters: Optional[dict] = None
-
-@mcp_app.tool
-def search_documents(query: SearchQuery) -> dict:
- """搜索文档
-
- Args:
- query: 搜索查询对象,包含关键词、结果数量和过滤条件
-
- Returns:
- 搜索结果列表
- """
- # 实现搜索逻辑
- results = perform_search(
- keywords=query.keywords,
- max_results=query.max_results,
- filters=query.filters
- )
- return {"results": results, "count": len(results)}
-```
-
-### @app.agent_as_a_tool
-
-将整个 Agent 封装为 MCP 工具,实现 Agent 的组合和协作。
-
-#### 函数签名
-
-```python
-@app.agent_as_a_tool
-async def agent_tool(prompt: str) -> str:
- pass
-```
-
-#### 使用示例
-
-```python
-from veadk import Agent, Runner
-from veadk.tools.demo_tools import get_city_weather
-
-# 创建一个专门的天气 Agent
-weather_agent = Agent(tools=[get_city_weather])
-weather_runner = Runner(agent=weather_agent)
-
-mcp_app = AgentkitMCPApp()
-
-@mcp_app.agent_as_a_tool
-async def weather_assistant(prompt: str) -> str:
- """天气助手 Agent
-
- 专门处理天气相关查询的 Agent,可以查询全球城市的天气信息。
-
- Args:
- prompt: 用户的天气查询
-
- Returns:
- 天气查询结果
- """
- response = await weather_runner.run(messages=prompt)
- return response
-```
-
-#### 多 Agent 协作示例
-
-```python
-# 创建多个专门的 Agent
-weather_agent = Agent(tools=[get_city_weather])
-news_agent = Agent(tools=[get_latest_news])
-calendar_agent = Agent(tools=[check_schedule])
-
-@mcp_app.agent_as_a_tool
-async def weather_assistant(query: str) -> str:
- """天气助手"""
- return await Runner(agent=weather_agent).run(messages=query)
-
-@mcp_app.agent_as_a_tool
-async def news_assistant(query: str) -> str:
- """新闻助手"""
- return await Runner(agent=news_agent).run(messages=query)
-
-@mcp_app.agent_as_a_tool
-async def calendar_assistant(query: str) -> str:
- """日程助手"""
- return await Runner(agent=calendar_agent).run(messages=query)
-```
-
-#### 注意事项
-
-1. **Agent 职责单一**:每个 Agent 应专注于特定领域
-2. **清晰的描述**:文档字符串要明确 Agent 的能力边界
-3. **异步执行**:通常是异步函数
-4. **合理的超时**:设置合理的执行超时时间
-
-## A2A Agent 注解
-
-`AgentkitA2aApp` 用于构建 A2A (Agent-to-Agent) 应用,支持 Agent 之间的通信和协作。
-
-### @app.agent_executor
-
-注册 Agent 执行器,定义 Agent 的执行逻辑。
-
-#### 函数签名
-
-```python
-@app.agent_executor(runner=runner, **kwargs)
-class MyAgentExecutor(A2aAgentExecutor):
- pass
-```
-
-#### 参数说明
-
-- **runner**: Agent 的运行器实例
-- **kwargs**: 其他配置参数
-
-#### 基本示例
-
-```python
-from agentkit.apps import AgentkitA2aApp
-from google.adk.a2a.executor.a2a_agent_executor import A2aAgentExecutor
-from veadk import Agent, Runner
-from veadk.a2a.agent_card import get_agent_card
-from veadk.tools.demo_tools import get_city_weather
-
-# 创建 A2A 应用
-a2a_app = AgentkitA2aApp()
-
-# 创建 Agent
-agent = Agent(tools=[get_city_weather])
-runner = Runner(agent=agent)
-
-# 注册执行器
-@a2a_app.agent_executor(runner=runner)
-class WeatherAgentExecutor(A2aAgentExecutor):
- """天气查询 Agent 执行器"""
- pass
-
-# 运行应用
-if __name__ == "__main__":
- a2a_app.run(
- agent_card=get_agent_card(agent=agent, url="http://127.0.0.1:8000"),
- host="127.0.0.1",
- port=8000,
- )
-```
-
-#### 自定义执行器示例
-
-```python
-from a2a.server.agent_execution import AgentExecutor
-from a2a.server.agent_execution.context import RequestContext
-from a2a.server.events.event_queue import EventQueue
-
-@a2a_app.agent_executor(runner=runner)
-class CustomAgentExecutor(AgentExecutor):
- """自定义 Agent 执行器"""
-
- async def execute(
- self,
- context: RequestContext,
- event_queue: EventQueue
- ) -> str:
- """执行 Agent 逻辑
-
- Args:
- context: 请求上下文,包含输入消息和历史
- event_queue: 事件队列,用于发送中间结果
-
- Returns:
- Agent 的响应结果
- """
- # 从上下文提取输入
- user_message = context.current_input
-
- # 发送中间事件(可选)
- await event_queue.put({
- "type": "thinking",
- "content": "正在思考..."
- })
-
- # 执行 Agent
- response = await self.runner.run(messages=user_message)
-
- return response
-```
-
-#### 注意事项
-
-1. **继承 AgentExecutor**:必须继承自 `AgentExecutor` 或其子类
-2. **提供 runner**:必须通过参数传入 runner 实例
-3. **实现 execute 方法**:如需自定义逻辑,重写 `execute` 方法
-4. **使用 event_queue**:通过事件队列发送中间状态
-
-### @app.task_store
-
-注册任务存储,用于持久化 A2A 任务状态。
-
-#### 函数签名
-
-```python
-@app.task_store(**kwargs)
-class MyTaskStore(TaskStore):
- pass
-```
-
-#### 使用默认存储
-
-```python
-# 不指定 task_store,会使用内存存储(InMemoryTaskStore)
-a2a_app = AgentkitA2aApp()
-
-@a2a_app.agent_executor(runner=runner)
-class MyExecutor(A2aAgentExecutor):
- pass
-```
-
-#### 自定义任务存储示例
-
-```python
-from a2a.server.tasks.task_store import TaskStore
-from a2a.types import Task
-import redis
-
-@a2a_app.task_store(redis_url="redis://localhost:6379")
-class RedisTaskStore(TaskStore):
- """基于 Redis 的任务存储"""
-
- def __init__(self, redis_url: str):
- self.redis_client = redis.from_url(redis_url)
-
- async def save_task(self, task: Task) -> None:
- """保存任务"""
- task_data = task.model_dump_json()
- self.redis_client.set(f"task:{task.id}", task_data)
-
- async def get_task(self, task_id: str) -> Task | None:
- """获取任务"""
- task_data = self.redis_client.get(f"task:{task_id}")
- if task_data:
- return Task.model_validate_json(task_data)
- return None
-
- async def delete_task(self, task_id: str) -> None:
- """删除任务"""
- self.redis_client.delete(f"task:{task_id}")
-```
-
-#### 注意事项
-
-1. **可选装饰器**:如不指定,使用内存存储
-2. **继承 TaskStore**:必须继承自 `TaskStore`
-3. **实现必需方法**:实现 `save_task`、`get_task`、`delete_task` 等方法
-4. **持久化存储**:生产环境建议使用持久化存储(Redis、数据库等)
-
-## 最佳实践
-
-### 1. 错误处理
-
-所有装饰的函数都应该有良好的错误处理:
-
-```python
-import logging
-
-logger = logging.getLogger(__name__)
-
-@app.entrypoint
-async def run(payload: dict, headers: dict) -> str:
- try:
- # 业务逻辑
- result = await process(payload)
- return result
- except ValueError as e:
- logger.warning(f"Invalid input: {e}")
- return f"Invalid input: {str(e)}"
- except Exception as e:
- logger.error(f"Unexpected error: {e}", exc_info=True)
- return "An error occurred. Please try again later."
-```
-
-### 2. 日志记录
-
-添加适当的日志以便追踪问题:
-
-```python
-@app.entrypoint
-async def run(payload: dict, headers: dict) -> str:
- request_id = headers.get("request_id", "unknown")
- logger.info(f"[{request_id}] Processing request: {payload}")
-
- try:
- response = await runner.run(messages=payload["prompt"])
- logger.info(f"[{request_id}] Request completed successfully")
- return response
- except Exception as e:
- logger.error(f"[{request_id}] Request failed: {e}")
- raise
-```
-
-### 3. 类型注解
-
-使用完整的类型注解提高代码质量:
-
-```python
-from typing import Dict, Any
-
-@app.entrypoint
-async def run(payload: Dict[str, Any], headers: Dict[str, str]) -> str:
- prompt: str = payload["prompt"]
- user_id: str = headers.get("user_id", "anonymous")
- # ...
-```
-
-### 4. 文档字符串
-
-为所有函数添加详细的文档字符串:
-
-```python
-@mcp_app.tool
-def calculate_distance(lat1: float, lon1: float, lat2: float, lon2: float) -> dict:
- """计算两个地理坐标之间的距离
-
- 使用 Haversine 公式计算地球表面两点间的大圆距离。
-
- Args:
- lat1: 起点纬度(度)
- lon1: 起点经度(度)
- lat2: 终点纬度(度)
- lon2: 终点经度(度)
-
- Returns:
- 包含距离信息的字典,距离单位为公里
-
- Example:
- >>> calculate_distance(39.9, 116.4, 31.2, 121.5)
- {"distance_km": 1067.5}
- """
- # 实现逻辑
-```
-
-### 5. 性能优化
-
-避免在装饰的函数中执行耗时初始化:
-
-```python
-# ❌ 不好的做法
-@app.entrypoint
-async def run(payload: dict, headers: dict) -> str:
- agent = Agent(tools=[...]) # 每次请求都创建
- runner = Runner(agent=agent)
- return await runner.run(messages=payload["prompt"])
-
-# ✅ 好的做法
-agent = Agent(tools=[...]) # 只创建一次
-runner = Runner(agent=agent)
-
-@app.entrypoint
-async def run(payload: dict, headers: dict) -> str:
- return await runner.run(messages=payload["prompt"])
-```
-
-## 下一步
-
-- 查看 `samples/` 目录下的完整示例代码
-- 阅读 [SDK 概览](./1.overview.md) 了解整体架构
-- 部署应用到 AgentKit Platform
diff --git a/docs/content/4.runtime/1.overview.md b/docs/content/4.runtime/1.overview.md
deleted file mode 100644
index d082fe0..0000000
--- a/docs/content/4.runtime/1.overview.md
+++ /dev/null
@@ -1,26 +0,0 @@
-# AgentKit Runtime 概述
-
-用户基于传统的IaaS架构部署、运行AI Agent时往往会遇到如下问题:
- - IaaS运维工作量大:用户需自行搭建运行环境(计算资源、网络配置、依赖安装等),耗费大量人力用于配置、调试、维护、扩展以及问题排查和性能优化,效率较低。
- - 缺乏统一运行时平台:需要分别为Session或任务创建单独的运行环境,无法统一调度和管理Session。
- - 安全与隔离性差:不同用户或Agent之间的可能出现访问冲突,存在出现权限泄露或者越权访问的风险
- - 运维和监控的负担增加:没有内建的监控与日志管理,用户需要配置日志系统、指标收集和警报规则,难以针对Agent的特征实时监控Agent的运行状态,无法及时发现和解决问题
-
-AgentKit runtime 是一个统一的Agent运行时,负责管理Agent的运行、会话和资源调度,为AI Agent提供安全隔离的托管式运行环境,支持便捷且规模化的部署。
-
-## AgentKit Runtime核心能力
-
-### 提供Serverless runtime 解决 AI Agent 部署、运维、成本难题:
-- **Serverless运行时**:简化的环境管理和配置,无需关心底层基础设施,维护复杂的运行环境,实现弹性伸缩和运维成本优化
-- **统一运行时平台**:提供统一的运行时环境,可以在同一环境中运行多个Agent实例(Session),实现高效调度和实例管理,并提供统一的接入域名
-- **自动化生命周期管理与扩展**:根据需求从零自动扩展到大规模并发,用户无需再关注Agent的实际部署、扩缩容,运维便利
-- **按量付费,降低成本**:根据Agent流量自动创建销毁运行时资源,避免资源长期standby,节省云资源成本
-- **内建监控与日志管理**:提供实时监控和日志功能,用户可以轻松追踪Agent运行状态,及时发现并解决问题,减轻运维负担。
-
-### 解决多用户的安全问题:
-- 基于云厂商成熟的隔离技术保证安全隔离,不同的Agent runtime在隔离的受保护环境中运行,避免恶意Agent影响其他Agent安全
-- 与Identity & 网关鉴权协同,严格区分会话上下文与访问权限,降低数据泄露与串扰风险
-
-### 框架、模型无关,提供便捷快速的构建部署方式:
-- 深度融合veADK,同时支持主流基于python的Agent框架(其他非python框架本期先不支持),用户通过少量代码适配即可快速对接,且支持HTTP、MCP、A2A协议
-- 提供AgentKit SDK,支持configure和launch,支持一键协助客户从本地IDE部署至云上runtime
diff --git a/docs/content/5.tools/1.sandbox_quickstart.md b/docs/content/5.tools/1.sandbox_quickstart.md
deleted file mode 100644
index 0acbefc..0000000
--- a/docs/content/5.tools/1.sandbox_quickstart.md
+++ /dev/null
@@ -1,216 +0,0 @@
-# AgentKit Built-in Tools 快速开始指南
-
-Built-in Tools是AgentKit内置的All-in-one的工具,提供了多种Agent在执行任务中需要的运行环境工具,支持快速集成与便捷调用。
-
-## 核心能力
- - 提供code sandbox能力,让Agent安全地“运行代码”
- - 提供browser sandbox能力:让Agent“像人一样操作网页”
- - 提供terminal sandbox能力:让Agent“像人一样操作操作系统控制台(Terminal)”
- - 提供文件系统能力:让Agent上传、下载文件
-
-本文档将详细介绍如何在智能体代码中集成和使用 Built-in Tools,特别是代码执行沙箱功能。通过本指南,您将学会如何创建、配置和调用沙箱工具。
-
-## 前置准备:创建沙箱工具
-
-在开始编写代码之前,您需要先在火山引擎控制台创建一个沙箱工具实例:
-
-1. 访问 [Agentkit Built-in Tools 控制台](https://console.volcengine.com/agentkit-stg/region:agentkit-stg+cn-beijing/builtintools)
-2. 创建新的沙箱工具实例
-3. 记录生成的 `TOOL_ID`,后续配置中会用到
-
-## 智能体代码示例(使用VeADK框架)
-
-[VeADK](https://github.com/volcengine/veadk-python)是一个开源的智能体开发框架,提供了智能体的开发、运行、调试等功能,由火山引擎团队维护。
-以下示例代码会展示如何使用VeADK框架来快速构建一个具备代码执行能力的智能体,通过集成Built-in Tools中的`run_code`工具,实现智能体在沙箱环境中安全地执行代码。
-
-您无需从0-1构建veadk项目,推荐使用agentkit-cli,从Basic Agent App模版来创建项目(模板使用VeADK框架),在模版创建完成后,你需要做以下修改:
-- 为智能体添加代码执行工具 `run_code`
-- 配置环境变量 `AGENTKIT_TOOL_ID` 为您的沙箱工具实例 ID
-最终,您的代码文件应该如下:
-
-### 完整代码
-将代码保存为`simple_agent_tool.py`
-
-```python
-from veadk import Agent, Runner
-import logging
-from veadk.tools.builtin_tools.run_code import run_code
-from agentkit.apps import AgentkitSimpleApp
-
-logger = logging.getLogger(__name__)
-
-# 创建应用实例
-app = AgentkitSimpleApp()
-
-# 创建智能体,集成 run_code 工具
-agent: Agent = Agent(
- tools=[run_code], # 添加代码执行工具
-)
-
-# 创建运行器
-runner = Runner(agent=agent)
-
-@app.entrypoint
-async def run(payload: dict, headers: dict) -> str:
- """智能体入口函数,处理用户请求"""
- prompt = payload["prompt"]
- user_id = headers["user_id"]
- session_id = headers["session_id"]
-
- logger.info(
- f"Running agent with prompt: {prompt}, user_id: {user_id}, session_id: {session_id}"
- )
-
- # 运行智能体,自动处理工具调用
- response = await runner.run(
- messages=prompt,
- user_id=user_id,
- session_id=session_id
- )
-
- logger.info(f"Run response: {response}")
- return response
-
-@app.ping
-def ping() -> str:
- """健康检查接口"""
- return "pong!"
-
-if __name__ == "__main__":
- # 启动本地开发服务器
- app.run(host="0.0.0.0", port=8000)
-```
-
-### 代码说明
-
-- **run_code 工具**:提供安全的代码执行环境,支持 Python、JavaScript 等多种编程语言
-- **session_id**:用于标识用户会话,同一 session_id 的请求将共享沙箱实例
-- **异步处理**:使用 `async/await` 语法支持高并发请求
-## 本地调试
-### 1. 官方源安装VeADK
-
-您可以直接使用 Python 包管理工具 pip 从 PyPI 平台 来安装 [veadk-python](https://volcengine.github.io/veadk-python/introduction/installation):
-
-```bash
-# 正式环境源安装veADK
-pip install veadk-python
-
-# 支持调用tools的veadk官方源版本尚未发布(预计1030发布),请先使用git源码方式安装。
-pip install veadk-python@git+https://github.com/volcengine/veadk-python.git
-```
-> **说明**:支持调用built-in-tools的veadk-python版本为0.2.15及以上。
-
-### 2. 配置环境变量
-
-在启动智能体之前,需要配置以下环境变量:
-
-```bash
-# 必需配置:沙箱工具 ID(从控制台获取)
-export AGENTKIT_TOOL_ID=t-ye7fhfmghsc1kdxxxxxx
-
-# 必需配置:火山引擎访问凭证
-export VOLCENGINE_ACCESS_KEY=your_ak
-export VOLCENGINE_SECRET_KEY=your_sk
-
-# 必需配置:模型相关配置
-export MODEL_AGENT_NAME=your_model_name
-export MODEL_AGENT_API_KEY=your_model_api_key
-```
-
-**📝 注意事项:**
-
-- 请将 `your_ak`、`your_sk` 等占位符替换为您的实际配置值
-- `AGENTKIT_TOOL_ID` 从火山引擎控制台创建沙箱工具后获取
-
-**🧪 测试环境配置(可选):**
-
-如果您的沙箱工具实例,是创建在测试环境账号下(如PPE),您需要在环境变量中显示指定 endpoint,否则默认连接正式环境,可能会导致调用失败。配置如下:
-
-```bash
-export AGENTKIT_TOOL_HOST=agentkit-ppe.cn-beijing.volces-test.com
-export AGENTKIT_TOOL_SERVICE_CODE=agentkit_ppe
-```
-### 3. 本地启动智能体服务
-
-配置完环境变量后,运行以下命令启动智能体:
-
-```bash
-python simple_agent_tool.py
-```
-
-服务启动成功后,将监听 `http://0.0.0.0:8000`,您可以通过该地址调用智能体。
-### 4. 调用智能体
-
-#### Session ID 机制说明
-
-Built-in Tools 采用智能的会话管理机制:
-
-- **自动创建**:首次使用某个 `session_id` 调用时,系统会自动创建对应的沙箱会话实例
-- **会话复用**:相同 `session_id` 的多次请求将共享同一个沙箱实例,保持代码执行的上下文连续性
-- **生命周期**:每个会话实例默认有效期为 30 分钟,超时后自动销毁
-- **隔离性**:不同 `session_id` 的请求使用独立的沙箱环境,互不干扰
-
-#### 调用示例
-使用以下 curl 命令测试智能体的代码执行能力:
-
-```bash
-curl --location 'http://localhost:8000/invoke' \
- --header 'Content-Type: application/json' \
- --header 'user_id: veadk-test' \
- --header 'session_id: local_session' \
- --data '{"prompt": "给我在50和100之间一个随机的质数"}'
-```
-
-**参数说明:**
-
-- `user_id`:用户标识符
-- `session_id`:会话标识符,用于关联沙箱实例
-- `prompt`:用户的自然语言请求
-
-#### 执行日志示例
-
-调用成功后,控制台会输出详细的执行日志:
-```
-2025-10-24 14:50:23 | DEBUG | runner.py:265 - Auto create session: local_session, user_id: veadk-test, app_name: veadk_default_app
-2025-10-24 14:50:53 | DEBUG | runner.py:280 - Function call: id='call_1w6gamjirm56uvi8kl8dc0hr' args={'code': 'import random\nimport math\n\ndef is_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(math.sqrt(n)) + 1, 2):\n if n % i == 0:\n return False\n return True\n\nprimes = [n for n in range(50, 101) if is_prime(n)]\nrandom_prime = random.choice(primes)\nprint(random_prime)', 'language': 'python3'} name='run_code'
-2025-10-24 14:50:53 | DEBUG | run_code.py:41 - Running code in language: python3, session_id=local_session
-2025-10-24 14:51:08 | DEBUG | run_code.py:68 - Invoke run code response: {'ResponseMetadata': {'RequestId': '', 'Action': 'InvokeTool', 'Version': '2025-10-30', 'Service': '', 'Region': ''}, 'Result': {'ToolId': 't-ye7i0e39c0c1kdxxxxxx', 'UserSessionId': 'local_session', 'SessionId': 's-ye7kmw6ps0c1kdxxxxxx', 'Endpoint': 'xxx', 'InternalEndpoint': '', 'Result': '{\n "success": true,\n "message": "Code executed successfully",\n "data": {\n "kernel_name": "python3",\n "session_id": "xxxx",\n "status": "ok",\n "execution_count": 1,\n "outputs": [\n {\n "output_type": "stream",\n "name": "stdout",\n "text": "83\\n",\n "data": null,\n "metadata": {},\n "execution_count": null,\n "ename": null,\n "evalue": null,\n "traceback": null\n }\n ],\n "code": "import random\\nimport math\\n\\ndef is_prime(n):\\n if n \\u003c= 1:\\n return False\\n if n == 2:\\n return True\\n if n % 2 == 0:\\n return False\\n for i in range(3, int(math.sqrt(n)) + 1, 2):\\n if n % i == 0:\\n return False\\n return True\\n\\nprimes = [n for n in range(50, 101) if is_prime(n)]\\nrandom_prime = random.choice(primes)\\nprint(random_prime)",\n "msg_id": "c4a5f58d-7c9b8b8a17118fe6d1c65aae_94_2"\n }\n}'}}
-2025-10-24 14:51:24 | DEBUG | runner.py:288 - Event output: 在50和100之间随机生成的质数为:83。
-
-(注:通过Python代码筛选50-100间的质数列表[53, 59, 61, 67, 71, 73, 79, 83, 89, 97],并随机选择得到结果。)
-2025-10-24 14:51:24 | WARNING | runner.py:332 - No tracer is configured in the agent, no trace id provided.
-INFO: 127.0.0.1:58727 - "POST /invoke HTTP/1.1" 200 OK
-```
-
-## 部署到生产环境
-
-完成本地开发和测试后,您可以将智能体部署到 Agentkit 平台:
-
-1. **打包代码**:确保所有依赖都已正确配置在 `requirements.txt` 中
-2. **平台部署**:参考Runtime [快速开始](../1.introduction/3.quickstart.md) 部分部署tool,主要有以下几步:
- - 在项目根目录运行 `agentkit init` 命令,初始化项目,会生成 `agentkit.yaml` 文件(如果前面已执行,跳过此步)
- - 确保`agentkit.yaml`文件配置,应用入口设置为您刚才已经调通的应用代码`simple_agent_tool.py`,即:
- ```yaml
- entry_point: simple_agent_tool.py
- ```
- - 确保所有依赖都已正确配置在 `requirements.txt` 中
- - 根据[快速开始]指南,通过`agentkit config`和`agentkit launch`命令,配置和部署应用。
-3. **调用应用**:部署完成后,您可以通过平台提供的 API 或 SDK 调用智能体。调用示例:
- ```bash
- agentkit invoke "给我在50和100之间一个随机的质数"
- ```
-
----
-
-## 常见问题
-
-### Q: 如何查看沙箱支持的编程语言?
-A: 当前支持 Python3、JavaScript 等主流语言,具体支持列表请参考工具文档。
-
-### Q: Session 超时后的数据会保留吗?
-A: 不会。Session 超时后,沙箱实例及其中的所有数据都会被清理,下次请求会创建新的实例。
-
-### Q: 如何处理长时间运行的任务?
-A: 建议将长时间任务拆分为多个步骤,或考虑使用异步任务队列方案。
-
----
diff --git a/docs/content/6.memory/1.memory_quickstart.md b/docs/content/6.memory/1.memory_quickstart.md
deleted file mode 100644
index fd2e647..0000000
--- a/docs/content/6.memory/1.memory_quickstart.md
+++ /dev/null
@@ -1,166 +0,0 @@
-# AgentKit Memory 快速开始指南
-
-AI Agent 运行过程中面临多轮任务日益复杂、上下文窗口不足的问题,需要有记忆能力来进行上下文保持与个性化定制。Agentkit Memory 提供统一的记忆库使用接口并与主流框架进行对接,为 Agent 运行记忆库支持提供跨会话、上下文感知和个性化交互,实现 Agent 的持续学习与演进。本章节将指导您安装依赖项并实现长期记忆功能。
-
-# 使用示例
-
-步骤如下
-
-- 创建包含语义策略的记忆资源
-- 将事件(对话历史)写入记忆资源。
-- 从长期记忆中检索记忆记录
-
-## 创建记忆库
-
-通过火山引擎控制台,为智能体创建记忆库[Agentkit-Memory](https://console.volcengine.com/agentkit/region:agentkit+cn-beijing/memory)
-
-### 获取记忆资源的连接信息
-
-在记忆详情-集成代码页面,获取连接信息。
-
-- 对于 Mem0 类型的记忆资源,您可以看到类似如下的环境变量:
-
-```
-DATABASE_MEM0_BASE_URL="https://mem0-your-mem-url.mem0.volces.com:8000"
-DATABASE_MEM0_API_KEY="xxxxxx-xxxxxxx"
-```
-
-- 对于 VikingDB 类型的记忆资源,您可以看到类似如下的环境变量:
-
-```
-DATABASE_VIKINGMEM_COLLECTION=Quickly build and deploy Agent applications to the Volcengine AgentKit Platform