Open
Conversation
新增 sandbox 类型 SubAgent,自动创建 Docker 容器作为隔离执行环境, 在容器内执行命令/文件操作,任务完成后容器数据保留。 主要变更: - SandboxManager:封装 Docker 容器生命周期(创建/复用/执行/清理) - SandboxAgent:继承 SubAgent,覆盖工具集和系统提示词 - 沙箱工具集:容器内版本的 shell/read/write/edit/python 工具 - 默认注册 sandbox 角色(accepted_task_types: sandbox/system_analysis/experiment/benchmark) - 派遣集成:builtin.py + personal_assistant.py 自动检测 sandbox_config - 生命周期:lifespan 关闭时清理 72h 过期容器 - 45 个单元测试全部通过,总测试 457 通过 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
robscc
added a commit
that referenced
this pull request
Mar 19, 2026
…ds (#20) ## Summary 实现模块化 Agent 运行时架构,支持可插拔的执行后端: - 定义标准化的运行时接口(BaseSubAgentRuntime) - 内置 InternalSubAgentRuntime(进程内执行)和 HTTPSubAgentRuntime(远程 RPC) - 运行时注册表机制,支持动态扩展 - 集成 dispatch_sub_agent,支持通过 runtime_type 选择后端 ## Backend Changes - **agentpal/runtimes/**: 新增运行时核心模块 - `base.py`: RuntimeConfig、ExecutionResult、BaseSubAgentRuntime 基类 - `internal.py`: 进程内运行时,复用现有 SubAgent 逻辑 - `http.py`: HTTP RPC 运行时,支持分布式部署 - `registry.py`: 运行时注册表和工厂函数 - **agentpal/services/task_event_bus.py**: 任务事件总线原型 - **agentpal/models/session.py**: 新增 TaskStatus 枚举和 SubAgentTask.meta 字段 - **agentpal/tools/builtin.py**: 重构 dispatch_sub_agent 使用新运行时架构 - **agentpal/api/v1/endpoints/tasks.py**: 新增任务管理 API 端点 - Tests: 添加单元测试和集成测试 ## Frontend Changes - **src/api/index.ts**: 新增任务相关 API 客户端方法 - **src/pages/TasksPage.tsx**: 增强任务页面功能 - **src/pages/SessionsPage.tsx**: 优化会话展示 - **src/components/TaskArtifactViewer.tsx**: 新增任务产物查看组件 - **src/hooks/useTaskArtifacts.ts**: 新增任务产物拉取钩子 ## Testing - 26 个单元测试全部通过 ✓ - 2 个集成测试验证运行时与数据库集成 ✓ - 代码可正确编译导入 ✓ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
robscc
added a commit
that referenced
this pull request
Mar 19, 2026
feat: Modular agent runtime architecture — pluggable execution backends (#20)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sandbox/manager.py):封装 Docker 容器生命周期管理(创建/复用/命令执行/文件读写/过期清理),所有 Docker SDK 调用通过run_in_executor异步化agents/sandbox_agent.py):继承 SubAgent,覆盖_build_toolkit()(加载沙箱工具集)和_build_sub_system_prompt()(注入容器环境说明),惰性创建 Docker 容器并拷贝 workspace 上下文文件builtin.py和personal_assistant.py的dispatch_sub_agent自动检测sandbox_config,按需实例化 SandboxAgent 或普通 SubAgent新增文件
sandbox/__init__.pysandbox/manager.pysandbox/tools.pyagents/sandbox_agent.py修改文件
pyproject.tomldocker>=7.0.0依赖config.pysandbox_enabled/image/memory_limit配置models/agent.pySubAgentDefinition新增sandbox_config列database.pysandbox_config列迁移agents/registry.pytools/builtin.pyagents/personal_assistant.pymain.pyTest plan
🤖 Generated with Claude Code