Skip to content

Conversation

Copy link

Copilot AI commented Dec 21, 2025

  • Review existing plugin and utility patterns in BotSharp
  • Add BotSharp.Plugin.Sandbox with utility callbacks and hooks for AIO Sandbox APIs
  • Add or update tests validating sandbox utilities integration
  • Add README for BotSharp.Plugin.Sandbox
Original prompt

AIO Sandbox:https://github.com/agent-infra/sandbox 采用 Sidecar(边车)隔离模式 解决了这一难题。它作为一个独立的 Docker 容器运行,与 BotSharp 宿主进程完全隔离。二者之间仅通过定义明确的 HTTP API 进行通信,形成了一道“逻辑气隙”(Logical Air Gap)。这种架构确保了即便代理在沙箱中执行了 rm -rf /,受损的也仅仅是临时的沙箱容器,而不会波及核心业务系统
BotSharp 遵循严格的组件化设计原则,其核心架构通过 插件(Plugins) 和 钩子(Hooks) 来解耦业务逻辑。在 BotSharp 中,代理的能力扩展主要依赖于 Agent Utility(代理实用工具) 的概念。
Utility Functions(实用工具函数): 这是代理能力的原子单元。与传统的硬编码逻辑不同,实用工具函数是动态挂载的。通过继承机制,特定的 Task Agent(如“运维代理”或“Python 工程师代理”)可以继承一组特定的工具,而其他代理则不可见 5。
IFunctionCallback 接口: 这是 BotSharp 与外部世界交互的标准契约。每一个封装了 AIO Sandbox API 的 C# 类都必须实现此接口。其核心的 Execute 方法负责接收 LLM 生成的结构化参数(JSON),调用 AIO Sandbox 的 HTTP 接口,并将执行结果(如 Shell 输出或文件内容)反序列化后反馈给 LLM 6。
Prompt Engineering 与元数据注入: 仅仅编写代码是不够的,LLM 必须“知道”它拥有这些工具。通过 IAgentHook,我们可以在代理加载阶段(OnAgentLoaded)动态地将工具的功能描述(Function Definition)注入到系统提示词(System Prompt)中,从而引导模型在适当的时机调用这些工具 。
AIO Sandbox 提供了一套丰富的 RESTful API,旨在涵盖开发与运维的各个方面。为了实现“将所有的 AIO Sandbox API 都封装成 Utility Function”这一目标,我们必须对 API 表面积进行详尽的梳理,并建立 1:1 的映射关系。

下表展示了核心 API 端点与 BotSharp 实用工具函数的命名对应关系 1:

功能域 AIO Sandbox 端点 HTTP 方法 BotSharp 工具名称 (Function Name) 功能描述
环境感知 /v1/sandbox GET util-sandbox-get_context 获取沙箱环境信息(版本、资源状态)
Shell 执行 /v1/shell/exec POST util-sandbox-shell_exec 执行 Shell 命令(支持超时设置)
Shell 异步 /v1/shell/wait POST util-sandbox-shell_wait 等待异步命令执行完成
文件读取 /v1/file/read POST util-sandbox-file_read 读取指定路径的文件内容
文件写入 /v1/file/write POST util-sandbox-file_write 向指定路径写入文本内容
文件列表 /v1/file/list POST util-sandbox-file_list 列出指定目录下的文件结构
文件搜索 /v1/file/search POST util-sandbox-file_search 在文件中搜索特定字符串
文本编辑 /v1/file/str_replace_editor POST util-sandbox-file_editor 基于字符串替换的精准文件编辑
浏览器 /v1/browser/screenshot POST util-sandbox-browser_screenshot 获取当前浏览器视口的截图
Jupyter /v1/jupyter/execute POST util-sandbox-jupyter_exec 执行交互式 Python/Jupyter 代码
Jupyter /v1/jupyter/sessions/create POST util-sandbox-jupyter_create_session 创建新的 Jupyter 会话
包管理 /v1/sandbox/packages/{lang} GET util-sandbox-check_packages 检查已安装的 Python/Nodejs 包

这种映射不仅是对 API 的简单透传,更涉及对输入输出数据的清洗、截断与格式化,以适应 LLM 有限的上下文窗口(Context Window)。

将AIOSandbox作为插件集成到Botsharp中,命名为 BotSharp.Plugin.Sandbox,将API实现为 Agent Utility(代理实用工具)。这种独立的程序集设计保证了 BotSharp 核心的纯净性,并允许按需加载插件


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add sidecar isolation mode implementation Add AIO sandbox sidecar utilities plugin and expose functions via Utility Assistant Dec 21, 2025
Copilot AI requested a review from geffzhang December 21, 2025 03:02
@geffzhang geffzhang marked this pull request as ready for review December 21, 2025 03:36
@geffzhang
Copy link

@copilot 为plugin BotSharp.Plugin.Sandbox 添加一个READMEmd

Copy link
Author

Copilot AI commented Dec 21, 2025

@copilot 为plugin BotSharp.Plugin.Sandbox 添加一个READMEmd

Added README for BotSharp.Plugin.Sandbox with config and exposed utility list (dd24b7f).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants