运行时与部署Runtime & deployment · 单元Unit 11
运行时与沙箱:把智能体安全地跑起来Runtime and sandboxes: run agents safely
运行时负责服务化、调度与部署,沙箱负责隔离执行。学完本单元,你能设计无状态服务、选择隔离后端,并建立超时、灰度与回滚机制。Runtime handles serving, scheduling and deployment; sandboxes isolate execution. After this unit you can design stateless services, choose isolation backends and add timeouts, canaries and rollback.
学习目标Learning goals
- 选择 Local、Docker、E2B、Daytona、K8s 等工作区后端Choose Local, Docker, E2B, Daytona or K8s workspaces
- 把智能体进程设计为无状态服务Design agent processes as stateless services
- 为工具执行设置隔离、超时与资源上限Set isolation, timeouts and resource limits for tool execution
概念闪卡Concept cards
点击卡片翻面查看解释。Click a card to flip it and reveal the explanation.
关键 APIKey APIs
点击进入对应的 Python 或 Java 参考页。Open the exact Python or Java reference for each type.
问题巩固Check yourself
完成 10 道题;答错会自动进入错题本。Answer all ten questions. Wrong answers are added to your wrong-answer book automatically.
01Python 工作区的抽象基类是?What is the Python workspace base class?
解析Why WorkspaceBase 统一 initialize、close、工具/MCP/技能管理和上下文卸载。WorkspaceBase unifies initialize, close, tool/MCP/skill management and context offloading.
02在 Docker 容器中隔离执行的工作区是?Which workspace isolates execution in a Docker container?
解析Why DockerWorkspace 通过容器提供文件系统与进程隔离,适合自托管场景。DockerWorkspace provides filesystem and process isolation through containers for self-hosting.
03下列哪组属于远程/集群沙箱后端?Which group contains remote or cluster sandbox backends?
解析Why E2B 与 Daytona 是托管沙箱,K8sWorkspace 适合集群内隔离。E2B and Daytona are hosted sandboxes; K8sWorkspace targets in-cluster isolation.
04Java 官方沙箱扩展构件包括?Which official Java sandbox extension artifacts exist?
解析Why 此外还有 sandbox-daytona、sandbox-kubernetes 和 sandbox-agentrun。There are also sandbox-daytona, sandbox-kubernetes and sandbox-agentrun.
05智能体服务水平扩容的前提是?What is required for horizontal scaling of agent services?
解析Why 无状态才能让负载均衡把请求发到任意实例而不丢上下文。Only statelessness lets a load balancer route to any instance without losing context.
06控制面与数据面应该?How should control and data planes be arranged?
解析Why 分离后配置变更和流量治理不会干扰请求执行,故障域也更清晰。Separation keeps config changes and traffic governance away from request execution and clarifies failure domains.
07上线最小安全配置包括?What is the minimum safe release configuration?
解析Why 缺少超时和熔断时,单个慢工具会拖垮整个实例。Without timeouts and circuit breakers, one slow tool can take down an instance.
08每个请求应该具备什么?What should every request have?
解析Why 请求级超时能防止资源被慢请求长期占用,取消则释放下游资源。Per-request timeouts prevent slow requests from holding resources; cancellation releases downstream resources.
09工作区初始化通常调用?How is a workspace initialized?
解析Why WorkspaceBase.initialize 准备后端、工具与技能;使用前必须完成初始化。WorkspaceBase.initialize prepares the backend, tools and skills and must run before use.
10工作区生命周期结束时应调用?What should be called at the end of a workspace lifecycle?
解析Why close 释放容器、远程沙箱和文件句柄;reset 只重置状态,不保证释放资源。close releases containers, remote sandboxes and file handles; reset only resets state.