打开文档导航

Host、Guest 与 Run

一句话

Host 决定一次执行能做什么并记录结果,Guest 执行 Agent Program 的普通 Python 控制流,一个 Run/attempt 绑定一次 physical backend execution 与一个 Guest;同一 logical request 只在 typed non-replay promotion 下才会产生 child attempt。

先看一个例子

假设 Host 已配置 workspace_files,并把相应 capability 投影进本次 Plan。Agent Program 要读取工作区中的 notes/today.txt,统计非空行数:

text = workspace.read_text("notes/today.txt")
lines = [line for line in text.splitlines() if line.strip()]
result = {"non_empty_lines": len(lines)}

列表推导式、分支、变量和 len 都在 Guest 中运行。workspace.read_text 却不会因为 Python 写出了这个名字就自动拥有文件权限。调用必须经过 Host 提供的 capability 入口;Host 检查本次 Run 的 Plan、参数 schema、预算和 approval,再决定是否 dispatch handler。

Guest 拿到 bounded response 后继续计算。Host 最后验证响应、投影自己产生的 receipt/evidence,并关闭本次 Guest。这个完整单元就是一次 Run。

真实机制

对象负责什么不是什么
Host请求 admission、artifact/profile、资源限制、Plan/Broker、workspace、evidence 和终态不只是启动 Python 的父进程
Guest一个 physical attempt 的 Python interpreter、globals、局部变量、栈和 WASM memory不自动拥有网络、凭据或 Host 文件
Agent ProgramRequest 中的 Python source 与 inputs,决定普通控制流不是授权配置
Run/attempt一次 physical backend execution、一个 Guest、response 与 terminal disposition不等于整个 parent/child orchestration,也不等于长期存在的 engine 或 artifact
Logical requestExact RunRequest 及其 parent decision;窄 typed promotion 可产生一个 child attempt不会让两个 attempt 共享 Guest state

RunRequest 是不可信输入。它可以带 run_id、code、inputs、output schema 和 requirements,但不带 capability grant、credential、mount、environment 或 budget。Request 的 run_id 只是诊断标签,不等于 Host 的 runIdentity;native attempt 还会得到独立 executionID。这些身份都不能由请求标签自动获得 authority。Host-owned RunConfig 另外设置 timeout、请求/响应大小、memory、artifact、execution profile 和 capabilities。

Guest 通过 bounded ABI 调用 Host。Broker 在 Host 侧重新核对 Plan、schema、预算和 approval,handler 也由 Host 注册。Guest 不能把自填的 receipt、Plan identity 或 execution reference 变成可信 evidence;Host 会拒绝或覆盖这些字段。

Fresh Guest 只说明本次 Python/WASM hidden state 不作为下一次 Run 的隐式输入。Host engine、编译 artifact、immutable records 和 operator config 可以拥有更长生命周期。

为什么重要

技术上: 角色分开后,Python 控制流不承担授权职责,Host 也无需解释每个普通 Python statement。错误可以定位到 request admission、Guest execution、Host call 或 cleanup,而不是混成一段异常文字。

产品和业务上: 平台可以让 Agent 使用熟悉的 Python,同时集中管理权限确认、资源上限、workspace 和运营证据。调用者可以区分“请求未启动”“Guest 报错”“Host operation ambiguous”等状态。

不能推出什么

  • Guest 不是支持任意 Python、shell、network 和 native extension 的 generic container。
  • Fresh Run 不是 checkpoint、外部 effect replay 或完整 transaction。
  • Receipt 和 observation 不是外部世界真值。
  • WASM 与 native backend 共享 authority 原则,不表示 response、evidence 和性能字节级等价。

术语卡

  • Host:掌握 authority、资源和 evidence 的宿主侧。
  • Guest:一次 physical attempt 执行 Agent Program 的受限实例。
  • Agent Program:由 Agent 生成并交给 runtime 的 Python 程序。
  • Run/attempt:一次带 identity、限制、一个 Guest 生命周期和终态的 physical execution。
  • Capability:由 Host 暴露并检查的外部操作入口。

继续阅读