云端执行与跨设备接力
CC 做「会话级」云端化(--remote 推上去、--teleport 拉回来、Remote Control 本地跑远程看);Codex 做「diff 级」云端化(codex cloud 提交任务、apply 把补丁拉回本地)
云端执行与跨设备接力
结论
两家云端执行的根本差异在接力的粒度。Claude Code 把云端会话当作一等公民:claude --remote 把任务推到 Anthropic 托管 VM,claude --teleport 把云端会话连同分支和完整对话历史拉回终端继续;另有 Remote Control 反向方案——会话留在本机执行,claude.ai/手机只是窗口[一手文档]。Codex 的云端(codex cloud,backend 是 https://chatgpt.com/backend-api)是任务-补丁模型:Exec 提交、Status/List 查询、Diff 查看、Apply 把 diff 打到本地工作区,支持 best-of-N(1-4 attempts),但不存在「把云端对话搬回本地 TUI 继续聊」的会话级接力[一手源码]。沙箱哲学也相反:CC 云端默认 Trusted 网络白名单(放行包管理器等),Codex 云端 agent 阶段默认完全断网(仅 setup 脚本联网)[一手文档]。harness 的机会在于补齐两家都缺的「本地↔云端统一视图」。
研究问题
- CC 的 --remote / --teleport / Remote Control 三者会话迁移模型是什么?
- Codex cloud 的任务模型和本地集成点?
- 本地与云端的沙箱/网络边界差异?
- 本地 harness(Yoda)与云端执行是互补还是竞争?
各 Agent 设计与实现
Claude Code
云端执行(claude.ai/code)[一手文档]
每个 session 一台 "fresh Anthropic-managed VM",资源约 4 vCPU / 16 GB RAM / 30 GB 磁盘(claude-code-on-the-web.md:148-152),Ubuntu 24.04,setup 脚本以 root 运行(:179)。配置携带规则很清晰:进 repo 的才存在——CLAUDE.md、.claude/settings.json hooks、.mcp.json、.claude/skills|agents|commands 都可用;用户级 ~/.claude/ 的一概不带(:62-76)。环境缓存:setup 脚本跑完后快照文件系统复用,约 7 天过期(:198-204)。
网络是四档模型(:284-289):None / Trusted(默认,白名单覆盖各语言包管理器 + GitHub + 容器仓库 + 云厂商 API)/ Full / Custom。两层代理:GitHub proxy——"git client uses a scoped credential inside the sandbox, which the proxy verifies and translates to your actual GitHub authentication token",且 push 限制在当前工作分支(:307-311);Security proxy——所有出站 HTTP 过代理做过滤限流(:315-319)。凭据隔离原则:"sensitive credentials such as git credentials or signing keys are never inside the sandbox"(:770)。会话内可用 CLAUDE_CODE_REMOTE=true 区分云端,CLAUDE_CODE_REMOTE_SESSION_ID(cse_ 前缀)反推 transcript URL(:118-124)。
本地→云(--remote):claude --remote "<prompt>" 创建云端会话,VM 从 GitHub clone 当前分支("push first if you have local commits",:595)。无 GitHub remote 时自动 fallback 成本地 bundle 上传(全分支历史 + 未提交的 tracked 变更,<100 MB,超限逐级降级到单分支、再到 squash 快照;CCR_FORCE_BUNDLE=1 可强制,:633-646)。多次 --remote 即并行多任务,/tasks 统一监控(:621-629)。
云→本地(--teleport):claude --teleport [session-id]、会话内 /teleport(/tp)、/tasks 按 t、或网页 "Open in CLI" 四个入口(:650-655)。teleport 做四项校验:本地 git 干净、同一仓库(非 fork)、云端分支已推到 remote、同一 claude.ai 账号(:663-670),然后 fetch + checkout 分支并加载完整对话历史。注意不对称性:"session handoff is one-way: you can pull cloud sessions into your terminal with --teleport, but you can't push an existing terminal session to the web"——CLI 的 --remote 只能开新会话,已有本地会话推上云只有 Desktop 的 Continue in 菜单能做(:584)。
Remote Control(执行位置反转)[一手文档]:claude remote-control(server 模式,默认容量 32 个并发会话,--spawn worktree 可按连接开 worktree)或 --remote-control / /rc。"Claude keeps running locally the entire time, so nothing moves to the cloud"(remote-control.md:15)——本地文件系统、MCP、工具全保留,web/mobile 只是视图。网络模型是纯出站:"makes outbound HTTPS requests only and never opens inbound ports",注册到 Anthropic API 后轮询,多重短时效单用途凭据(remote-control.md:139-141)。--teleport 复用同一套 Remote Control 基础设施(claude-code-on-the-web.md:787)。
沙箱差异(本地 vs 云):云端会话天然 VM 隔离 + 代理出网;本地 Remote Control 默认不开沙箱(--sandbox off by default,remote-control.md:60)。即本地执行的隔离责任在用户,云端的在 Anthropic。
Codex CLI
codex cloud 子命令[一手源码]:cli/src/main.rs:189 注册 #[clap(name = "cloud", alias = "cloud-tasks")],五个动作(cloud-tasks/src/cli.rs:15-27):
pub enum Command {
Exec(ExecCommand), // 提交云任务(--env <ENV_ID>、--attempts 1..=4、--branch)
Status(StatusCommand),
List(ListCommand),
Apply(ApplyCommand), // "Apply the diff for a Codex Cloud task locally"
Diff(DiffCommand),
}backend 默认 https://chatgpt.com/backend-api(cloud-tasks/src/lib.rs:49-50)——Codex cloud 寄生在 ChatGPT 账号体系。环境自动探测按本地 git origin 匹配(/environments/by-repo/{org}/{repo},env_detect.rs:30-43)。CloudBackend trait 的方法面(cloud-tasks-client/src/api.rs:134-162):list_tasks / get_task_summary / get_task_diff / get_task_messages / list_sibling_attempts(best-of-N 的兄弟尝试)/ apply_task_preflight / apply_task(可带 diff_override)/ create_task。--attempts 限 1-4(cli.rs:52-60)。
云端运行模型(developers.openai.com/codex/cloud/environments,访问于 2026-06-11)[一手文档]:容器 + universal 基础镜像(开源参考 openai/codex-universal),流程是 checkout → setup 脚本(联网)→ 应用 internet access 设置 → agent 循环(读 AGENTS.md 找 lint/test 命令)→ 输出答案 + diff,可开 PR。容器缓存 + 可选 maintenance 脚本。
网络默认值与 CC 相反(developers.openai.com/codex/cloud/internet-access,访问于 2026-06-11)[一手文档]:"By default, Codex blocks internet access during the agent phase. Setup scripts still run with internet access"。开启后可配域名白名单 + HTTP 方法白名单(CC 没有方法级控制),文档用一个真实 prompt injection 例子(GitHub issue 里藏 git show HEAD | curl -X POST 外传指令)论证默认断网的理由。
入口矩阵:chatgpt.com/codex 网页、IDE 扩展 cloud delegation、GitHub 上 @codex 提及(developers.openai.com/codex/cloud.md,访问于 2026-06-11)。会话级接力不存在:本地 TUI 里能浏览/对比/应用云任务的 diff(cloud-tasks crate 本身是个 TUI app,含 scrollable_diff),但没有把云端对话历史载入本地继续的机制[一手源码][推断]。
差异矩阵
| 维度 | Claude Code | Codex |
|---|---|---|
| 云端载体 | claude.ai/code,Anthropic VM(4c/16G/30G,Ubuntu 24.04) | chatgpt.com/backend-api,容器(universal 镜像) |
| 本地→云 | claude --remote(GitHub clone 或本地 bundle 上传) | codex cloud exec --env <ID>(GitHub 仓库) |
| 云→本地 | --teleport:分支 + 完整对话历史回到 TUI | codex cloud apply:只回 diff |
| 接力粒度 | 会话级(双向,CLI 推送受限) | 补丁级(单向取回) |
| 并行 | 多次 --remote 并行;/tasks 监控 | best-of-N attempts(1-4)+ 多任务 |
| 网络默认 | Trusted 白名单(包管理器/GitHub/云 API 可达) | agent 阶段默认全断网(仅 setup 联网) |
| 网络细粒度 | 域名白名单(None/Trusted/Full/Custom) | 域名白名单 + HTTP 方法白名单 |
| 凭据隔离 | GitHub proxy + scoped credential,真 token 不进沙箱 | GitHub App 集成(细节在云侧,本地源码不可见) |
| 反向方案 | Remote Control:本地执行、云端只是窗口(出站-only) | 未见等价物 [推断] |
| 无 GitHub 仓库 | 本地 bundle 上传(<100 MB,逐级降级) | 未见等价物(环境绑定 GitHub repo) |
| 账号要求 | claude.ai 订阅(API key/Bedrock/Vertex 不可用) | ChatGPT Plus/Pro/Business/Edu/Enterprise |
最小复现
# CC:推任务上云(需 claude.ai 登录 + GitHub 访问,/web-setup 或 GitHub App)
claude --remote "Fix the flaky test in auth.spec.ts"
# 监控
claude
> /tasks # 按 t 可 teleport 进某个云会话
# 拉回本地(要求:git 干净、同仓库、分支已推、同账号)
claude --teleport
# Codex:提交云任务并取回补丁
codex cloud exec "fix the failing unit tests" --env <ENV_ID> --attempts 2
codex cloud list
codex cloud diff <TASK_ID>
codex cloud apply <TASK_ID>(命令形态依据文档与 clap 定义;云端流程未在本机实测。)
Harness 接入建议(Yoda 实践)
Yoda 是本地编排器(PTY + worktree + SQLite),与云端执行是互补而非竞争——云端解决"机器关了还在跑",Yoda 解决"本地多 runtime 并行 + 统一观测"。具体接入:
- 云任务做"只读集成":两家都有可编程查询面——CC 的
/tasks、Codex 的codex cloud list/status(stdout 可解析)。Yoda 侧栏可以聚合展示两家云任务状态,点击跳转官方 UI,不要试图代理云端会话流。 - 接力点选在 git 层:CC teleport 和 Codex apply 殊途同归——最终都落到「分支/diff 回到本地工作区」。Yoda 已有 worktree 基建,云任务完成后自动 fetch 分支(CC)或 apply diff(Codex)到新 worktree,再用本地 agent 接续 review,是两家都没有的跨厂商工作流。
- Remote Control 是 Yoda mobile 的直接竞品,但有空档:RC 一个交互进程只挂一个远程会话、且依赖 claude.ai 订阅。Yoda 的 mobile gateway(token 保护、apps/mobile Expo 应用)覆盖全部 26 个 provider,差异化在多 runtime 而非单家深度。
- 教训照搬:teleport 的四项 preflight(git 干净/同仓库/分支存在/同身份)值得抄——Yoda 在 worktree 间移动任务时做同样校验,能避免大部分脏状态事故。
- 网络策略上对齐 Codex 的保守默认:Yoda 触发的无人值守本地 run 应默认限制网络(CC 本地 sandbox 是 off by default,不能指望 runtime 自己兜底)。
失效条件
- CC web 处于 research preview:资源配额(4c/16G/30G)、缓存 7 天、bundle 100 MB 上限都标注"may change"
-
--remote/--teleport/Remote Control 依赖 claude.ai 订阅与组织开关,企业策略(ZDR、IP allowlist)会整体禁用云会话(claude-code-on-the-web.md:51,806) - Codex cloud backend URL(chatgpt.com/backend-api)与
wham/environments路径是内部 API,随时可能变(env_detect.rs 同时探测两套路径说明正在迁移) - Codex
--attempts上限 4、environment 自动探测逻辑基于 b89ce9a,需随版本回归 - "Codex 无会话级接力 / 无 Remote Control 等价物"是基于本地源码与已抓取文档的阴性结论,新功能发布即失效
参考资料
- CC 文档:
claude-code-docs/docs/claude-code-on-the-web.md、docs/remote-control.md、docs/web-quickstart.md - Codex 源码(b89ce9a,2026-06-06):
codex-rs/cloud-tasks/src/{cli.rs,lib.rs,env_detect.rs}、codex-rs/cloud-tasks-client/src/api.rs、codex-rs/cli/src/main.rs:189 - Codex 云文档:https://developers.openai.com/codex/cloud 、https://developers.openai.com/codex/cloud/environments 、https://developers.openai.com/codex/cloud/internet-access (均访问于 2026-06-11)
- codex-universal 镜像:https://github.com/openai/codex-universal (文档引用,未实测)
- Yoda:
coding/yoda/agents/architecture/{overview.md,mobile.md}