跳到正文Skip to content
Agent J Beta
菜单Menu
中文EN
登录Sign in

搜索文档和页面Search docs and pages

文档Docs

换 AI 编程工具:先检查,能用才切Switch AI coding tool — checked first, switched only if it works

在手机菜单里发换 AI 工具的命令,主 Agent 先解释、扫描这台Agent J 主机上的 Claude Code、Codex、OpenCode,并用无头方式试一下各自的登录;能用的才切,切完新工具先自报家门,不通就自动切回。Send the switch command from the phone menu; your main Agent explains, scans the Agent J host for Claude Code, Codex and OpenCode, tries each sign-in headless, switches only to one that works, and the new tool introduces itself — or Agent J switches back by itself.

AI 编程工具就是这台Agent J 主机上真正动脑子、动手干活的那个程序:Claude Code、Codex 或 OpenCode。Agent J 是你手机通往它的那条线。换工具,换的是谁来回答你;工作目录、手机、审批和安全规则都不变。

怎么发起

  • 在输入框左边的 ≡「全部命令」里,「一键执行」一组(/customize 下面)有一条换 AI 工具的命令(/switch-harness),点一下就发给主 Agent。想直接说切到哪个,也可以在输入框里打这条命令,后面补一句「切换到 Codex」再发。
  • 或者直接说「切换到 OpenCode」「切回 Claude Code」。

点了不会马上切换。这条命令交给现在的主 Agent,由它按一套固定流程来做。

主 Agent 会怎么做

  1. 先说明。 你什么都没补就发过来,它会先用两三句话解释它说的是哪种工具,再告诉你接下来怎么切。
  2. 扫描。 看这台Agent J 主机装了哪几个 AI 编程工具、各是什么版本。
  3. 试登录。 对每个装了的工具,用你自己的登录、用它切过去后会用的模型,做一次很小的无头调用(不带任何工具权限,每个最多 60 秒),看它现在能不能正常回答。这一步在Agent J 主机上的一个独立小任务里做,用的是 Agent J 后台服务的环境,也就是切过去以后那个工具真正会拿到的环境。只读:不改配置,不读出、不显示任何密钥。
  4. 告诉你结果。 比如「现在能切到:Codex、OpenCode」,或者「这台Agent J 主机只有现在这一个能用,没法切换,要切得先装一个别的」。装了却用不了的,会说明原因:没登录、token 失效,或者网络 / 代理不通。
  5. 帮你装、教你登。 没装的,你同意后它按 安装 AI 命令行工具 帮你装。登录要你自己来,它会一步步告诉你在自己的终端里运行什么、会看到什么、该点哪里:Claude Code 是 claude auth login,Codex 是 codex login,OpenCode 是 opencode auth login。模型的 API key 不进聊天,走手机上的密钥卡。装好、登好,它会再试一次。
  6. 切换。 只有目标刚刚试通、你也明确要切,它才动手。

切换时会发生什么

主 Agent 先跟你说一句:Agent J 会重启,遥控器断开几秒后自动连上。然后它运行 agentj agent switch <目标>:

  • 这条命令会再试一次目标的登录,这是最后一道闸。试不通就什么都不改,主 Agent 会告诉你原因。
  • 试通了,切换交给Agent J 主机上一个独立的小任务:等这一轮说完,换成新的工具,重启 Agent J,然后检查新的工具起来没有、能不能回答。
  • 换 Codex 时,这道闸还会按切换后的样子把它的长驻会话先打开一次:同一个工作目录,用你自己的 Codex 设置和里面的 MCP 服务器、插件(不会在你的 Codex 历史里留下会话,也不发任何消息)。打不开就什么都不改,并告诉你原因;打开得慢,切换后就相应多等它一会儿。
  • 重启后,新的工具只要还在启动,就会继续等,最多 8 分钟。还是不说话的话,agentj agent switch --result 和切回后的说明会讲清它停在哪一步:还在启动、卡在终端里的确认提示、在等遥控器上的批准卡、启动失败,或者已经起来但一直不说话;有报错会说报错类型,并告诉你下一步怎么做。
  • 一切正常,新的工具会先跟你打招呼,说它是谁、用的什么模型。
  • 任何一步不通,Agent J 会自动切回原来的工具,原样恢复之前的设置,再由原来的那个告诉你没切成、为什么。

所以就算你不在Agent J 主机前、不会用终端,也不会因为切到一个不能用的工具而失联。

切换前先写交接

每个工具有自己的对话,新的那个看不到你们刚才聊了什么。所以切换前,Agent J 先让现在这个工具按和压缩交接一样的格式写一份交接文件;切过去以后,Agent J 把交接内容直接放进发给新工具的第一条消息,新的工具看完再接着干,不用自己去找文件。

  • 交接在检查通过之后、真正切换之前写。只留要点:你的原话要点、进度、已经定下的决定、关键路径和命令、踩过的坑、下一步、等你回答的问题;不超过 150 行,不写任何密钥、token、密码。
  • 文件位置固定:独立会话在 <工作目录>/.agentj/handover/switch.md,共享会话在 ~/.local/state/agentj/handoff/switch.md。切回来也一样:离开的那个写,接上的那个读,同一份文件合并更新。
  • 新的工具接上后先看交接,再跟你打招呼,说它接上了什么;然后 Agent J 让它按交接里的「下一步」接着干。交接里没有进行中的事,它就等你发话。
  • 交给新工具之前,Agent J 会遮住交接里的密钥等凭据;太长时只放前面一段,并写明其余部分在哪个文件。新工具自己再读这份交接文件,不用你批准。
  • Agent J 读不到交接文件时,会把原因告诉新工具;新工具用一句话转告你,再参考本地对话摘录接着来,缺的要点会问你。新工具某一步被拦下时,也会写清原因和下一步。
  • 最多等 3 分钟。超时时会明确告诉你已等了 180 秒,切换继续,改用本机脱敏摘录。摘录包含最近的请求和回复,过长处会标出省略;进度或决定仍可能遗漏,新工具会向你核实不确定的部分。

切过去,也要切得回来

  • 切换前,除了试目标,还会用同样的办法试一下现在这个工具。现在这个在后台服务里试不通(比如它的登录只放在你终端的环境变量里),也不阻止切到检查通过的新工具,不必先修好原来的。紧急时可用 agentj agent switch <目标> --force 跳过预检;切换后的启动检查与失败回滚仍保留。
  • 已经切过去、想回去却过不了检查时,在Agent J 主机上运行 agentj agent switch --undo(或者让主 Agent 运行):不再预检,直接原样换回上一次切走前的那个;换回去起不来,会自动回到现在这个。
  • 后台服务找不到 Claude Code 的登录时,会直接告诉你怎么办:在终端运行 claude,输入 /login 登录一次(Mac 上登录存进钥匙串,后台也能用);或者在能用 claude 的终端里运行 agentj service import-key CLAUDE_CODE_OAUTH_TOKEN,再运行 agentj service restart。
  • 工具自己升级过(比如 Codex 从 0.156 升到 0.162),后台服务以前记下的旧版本路径会自动作废,改用你终端里找到的那个,扫描结果里会写明。

切换不用管理员密码

不管现在是哪个工具在干活,包括在隔离里运行的 OpenCode、Kimi Code、Qwen Code,切换、扫描和 --undo 都交给 Agent J 自己的后台服务去做:不用管理员密码,也不用你回Agent J 主机前开终端。

  • Agent 要是说「后台服务没加载」,要你输管理员密码,或者让你去终端运行 agentj service start,不用照做。它在隔离里看不到系统的服务管理器,才会以为服务停了。
  • 想确认服务在不在运行,就运行 agentj service status。它直接问正在运行的服务本身,有应答就显示「后台服务在运行(serve 在应答)」。
  • Agent J 也不会为管理它自己的后台服务弹管理员密码卡,这种请求会被直接拒绝。

OpenCode 没有 key 也能用

  • OpenCode 自带几个免费模型(opencode/…,名字多半以 -free 结尾),不用注册、不用 key、不用付钱。用的是这种模型时,没有 key 也算能用;切过去写成 agentj agent switch opencode --model opencode/<免费模型>,opencode models opencode 列出现在有哪些(几乎每天在变)。
  • 免费模型的检查走和正常聊天同一条路(OpenCode 会拒绝不像它自己客户端的请求);刚装好的头一两分钟偶尔被拒,检查会自己等一会儿再试,最多多花一分钟多。
  • 有几个免费模型的服务商会记录对话或拿去训练模型,选中它们时切换结果和手机「模型和 API Key」卡上会多一句提示。别在里面发个人或机密信息;长期用建议换成你自己的模型。
  • 切换写进设置后,Agent J 会确认选中的 AI 工具已启动并能应答,模型名不同不会触发回退。切到 Claude Code 时,未指定 --model 就使用它自己的默认或当前模型;明确指定的模型照常保存。

等的时候手机上看到什么

扫描最多要三分钟左右,切换还要重启一次。这段时间回复卡不会空着:正文开头是一个跳舞的小机器人,后面跟着 Agent J 自己写的进度,说的是正在探测哪一个(第几个、共几个)、正在切换到哪一个,或者已经切回原来那个、它马上说明原因。机器人还在跳,就说明消息没丢、进程没断。

几件要知道的事

  • 每个工具有自己的对话记录。切过去是那边的对话,切回来接着原来的。
  • 隔离、共享会话还是独立会话、工作目录、审批规则,切换都不改。
  • 共享模式下,新的工具要有可以接上的会话:Claude Code 要在Agent J 主机上开着;Codex 和 OpenCode 没有开着的会话时,会在同一个目录里新开一个。
  • Agent J 主机上的 Codex 对话如果是只读权限,它运行不了切换命令,会把 Codex 的拒绝原话告诉你;那条对话要改成「完全访问」才行。
  • 想看上一次切换的结果,在Agent J 主机上运行 agentj agent switch --result,或者问主 Agent。
agentj agent switch --scan
agentj agent switch codex --dry-run

第一条看现在能切到哪些(用后台服务的环境逐个试);第二条只检查能不能切到 Codex,不切。

换成 Kimi Code

Kimi Code CLI(kimi,月之暗面出品,MIT 开源,2.2.0 或更新)是 Agent J 能切换的第四个 AI 编程工具。在用不了 Claude Code 和 Codex 的地方(中国大陆、香港、澳门),它是常见的选择。Agent J 通过 Agent Client Protocol(kimi acp)跟它对话:每个 Agent 一段长驻对话,回复整段发到手机,每次审批都在你手机上。

  • 切换:agentj agent switch kimi;在海外站 kimi.ai 买的会员加 --region global。先检查、写交接、不通自动切回,这些和别的工具一样。Kimi Code 只支持独立会话(暂时不能接Agent J 主机上开着的终端会话)。
  • 手机上登录:设置 → 紧急修复 → ③ AI 账号登录失效 → AI 登录救援 → Kimi Code →「重新登录(设备码)」。Agent J 主机运行官方的 kimi login,手机上显示一个链接和一次性设备码,你在任何登录了 Kimi 的设备上确认就行。在Agent J 主机上登录是 kimi login --region mainland-cn(国内站 kimi.com,默认)或 kimi login --region global(海外站 kimi.ai)。kimi.com 会员的 key 在 api.kimi.com 和 api.kimi.ai 两个地址都能用。
  • 也可以用 Kimi Code 控制台的 API key:让 Agent 发手机密钥卡存 KIMI_API_KEY,不要把 key 发在聊天里。只有 Kimi 自己没登录时,Agent J 才把这把 key 在内存里交给它。
  • 审批权在你手里。Kimi 自己的 hook 出错或超时会默认放行,所以 Agent J 不依赖它:每段 Kimi 对话都固定在 Kimi 的手动审批模式,每个权限请求都变成手机卡片,你点同意只算这一次,绝不是以后都同意。Kimi 要是自己切到 Auto 或 YOLO 模式,Agent J 会马上切回来。Kimi 没有自带沙箱:它在 Agent J 的隔离里运行,危险命令拦截强制打开。你自己在 ~/.kimi-code/config.toml 里写的放行规则还是你的,agentj doctor 会告诉你有几条。
  • 技能:Kimi 读 ~/.agents/skills,Agent J 的随包技能本来就链接在那里,直接能用。广场里的包给 Kimi 装的是 Codex 版。
  • 想用 OpenCode 接 Kimi 模型?那条路线还在,agentj agent route 两种都会给。

换成 Qwen Code

Qwen Code(qwen,阿里出品,Apache-2.0 开源,0.25 或更新)是 Agent J 能切换的第五个 AI 编程工具,在中国大陆和阿里百炼 Token Plan 正好配成一对(怎么配)。Agent J 和它对话用的也是 Agent Client Protocol(qwen --acp),和 Kimi Code 一样。

  • 切换:agentj agent switch qwen。先检查、写交接、不通自动切回,这些和别的工具一样。只支持独立会话。
  • 它的免费登录 2026-04-15 已经停了,key 就是它的登录:让 Agent 发手机密钥卡存 BAILIAN_TOKEN_PLAN_API_KEY。Agent J 只在内存里把 key 交给 Qwen Code;你自己配过 ~/.qwen/settings.json 的,以你的为准。
  • 审批权在你手里。Qwen Code 默认的模式会让一个分类器自己批准一部分操作;Agent J 把每段对话都切回「每次都问」,每个请求都变成手机卡片,只批这一次。
  • 手机上的 /model 列出套餐里的模型,名字后面带“看图”两个字的能读截图。换模型会重启 Qwen Code,接着原来的对话。
  • 你自己的定时任务也可以用 Token Plan 的 key(长时间连续跑的后台任务服务商可能限流,可改用按量付费的 key);客服 bot 是在服务别人,Agent J 不会把这把 key 交给 bot。

换成 DeepSeek dsh

dsh(DeepSeek Harness,DeepSeek 出品,MIT 开源,0.2.0-rc.2 或更新,还是开发者预览版)是 Agent J 能切换的第六个 AI 编程工具。Olares 自带的 Agent「Lares」用的就是它;它也能接任何 OpenAI 兼容的模型服务(怎么配)。Agent J 和它对话用的也是 Agent Client Protocol(dsh --profile acp),和 Kimi Code 一样。

  • 切换:agentj agent switch dsh。先检查、写交接、不通自动切回,这些和别的工具一样。只支持独立会话。
  • 还没配模型?检查结果会告诉你。运行 agentj agent dsh --base-url https://<服务>/v1 --model <模型 id> 配一条,key 只走手机密钥卡(DSH_ROUTER_API_KEY;DeepSeek 官方 API 用 DEEPSEEK_API_KEY)。你自己配过 dsh 的,按你的来。
  • 审批权在你手里。Agent J 让 dsh 以只读方式启动,每次都问:改文件、跑不是只读的命令,每一个都变成手机卡片,只批这一次,没有「总是允许」。
  • 手机上的 /model 列出路线里的模型和 DeepSeek 的模型,/context 也能用。对话快满时 dsh 会自己压缩(它没有 /compact)。用你自己的模型服务,就没有套餐额度一说。
  • 暂时只能读文字。定时任务也能用它,但拿不到密钥卡里的 key。

同一个 AI 换账号

换账号不是换 AI:Claude Code 还是 Claude Code,只是换一个登录。设置 →「Agent 的功能」→「备用 AI 账号」专门管理 Claude Code、Codex 额度用完时自动切换的备用账号。主账号与「模型和 API Key」显示同一份配置,在这里只能查看,点链接到「模型和 API Key」修改;这里只添加或管理备用账号:「添加账号」走官方登录,新账号单独保存,不覆盖已有的;点「设为当前」一键切换,主 Agent 从下一条消息起用新账号,接着原来的对话;正在跑的后台任务用完原来的账号为止。也可以在聊天里说「换 Claude 备用账号」,或在 Agent J 主机上运行 agentj account use claude 备用。不要把 token 发进聊天。步骤详见用户手册。

新增 Codex 备用账号时,先在官方授权网页确认你登录的是另一个 ChatGPT 账号。若提示“已登记过”,换到要添加的账号再试,不用删除主号。账号添加与 AI 登录救援分别显示自己的结果;批准添加后,仍可在原账号页查看成功或失败。

若提示“当前登录与登记在用账号不一致”,先到 AI 登录救援登录一个已登记的账号,成功后再切换。Agent J 不会为了切换而覆盖一个身份不一致的当前登录。

Claude 有多个版本

mise/asdf 装了多个 Claude 版本时,ambiguous_install 表示有多份安装。Agent J 默认选最高的可执行版本;明确设置的 AGENTJ_CLAUDE_BIN 或 mise/asdf 版本优先。如果选定的版本不存在,请选已安装的版本,或设置 AGENTJ_CLAUDE_BIN,错误码不会是 not_installed。

手机消息排队时可以点「停止当前任务」,走原有 Stop 操作。排队超过三分钟、上一件也连续三分钟没有新输出时,页面会提示;有新输出就重新计时,刷新页面后重新观察。

确认切换的最终结果

安排切换和启动程序都表示切换还在进行。新 AI 必须收到手机的问候消息并正常回复,才算切换成功。从 0.26.1 起,已经回答但仍在工作或等你批准时,Agent J 会保留它,并在最终结果里说明;不会因为回答后还在忙就切回。手机会显示最终结果;在发起切换的终端里运行 agentj agent switch --result --wait 900,可等待最多 15 分钟。退出码 0 表示成功(probe_ok 仅为检查演练),3 表示失败或已回退,4 表示仍在等待。回退时会说明已经切回原来的 AI,以及失败原因,不要根据中间状态重复切换。

旧 AI 写交接最多等 3 分钟;如果它已经结束却没有写好文件,会直接继续切换。Agent J 会从本机最近的请求和回复中提取更完整的脱敏摘录交给新 AI;摘录可能不完整,不能代替进度确认,也不增加工具权限。

主 Agent 在隔离里也能读取宿主的切换结果。请求已排队、结果还在等待,都表示尚未确认,不能说成成功或失败。离开的 Agent 会先结束当前回复,让切换继续,下一轮再用 agentj agent switch --result 查结果;不用你到网页菜单重发切换。暂时读不到宿主结果时,仍按尚未确认处理。

内置 AI 预览:开放条件与服务商隐私

内置 Agent J AI 是主动选择的预览功能,只有主机服务已经设置 AGENTJ_CORE=1 时才显示。阅读本页不会启用它,也不会切换当前 AI。请协助设置的 Agent 查看主机当前预设;列出了预设或配置了 key,不代表账号有权限或服务商调用已成功。密钥通过密钥卡填写,不发到聊天里。

预览支持已配置的 Chat、Anthropic Messages 和 Responses 连接。Responses 请求使用 store:false,续接保存在本机,不依赖服务商会话 ID;这个请求选项不保证服务商的数据保留政策。Chat 和 Anthropic 是否流式输出取决于预设。工具调用被截断或不完整时,在执行前拒绝。原有审批和隔离规则继续有效,更换连接类型需要明确选择。

预览中的 MCP 服务器

MCP 服务器列表由主人掌握。申请添加时,手机审批卡会显示命令或地址。本地命令服务器在会话隔离范围内运行,只获得白名单环境变量,不带服务商密钥。Streamable HTTP 使用 HTTPS,仅本机回环地址允许 HTTP;配置的 key 按变量名在主机读取,只放进 Authorization 请求头,不进入网址或工具环境。不跟随重定向。

每次 MCP 工具调用都先申请批准,除非主人添加服务器时明确允许该工具免确认。研究任务只能使用已允许的工具;服务器自称「只读」不构成授权。同一张单内的拒绝对其他会话也有效。小模型档不接收 MCP 工具。这些设置不扩大原生工具或其他会话的权限。

压缩与交接

上下文接近上限时,内核先裁旧工具输出,再总结较早的对话,最近消息保留原文。摘要列出改过的文件,保存到本机会话和压缩交接文件;恢复会话时使用这份摘要。模型报告上下文溢出后,只压缩并重试一次,不无限重试。生成摘要仍可能消耗模型 token。

在这项预览里,/compact 可附重点,/context 查看上下文组成,/cost 和 /usage 查看上次 /clear 以来各模型用量,/model 列出已配置 key 的连接,/status 查看当前模型、会话和隔离。数字取决于实际用量上报,账单以服务商为准;能选择模型不代表已验证服务商连通。

预览中的补丁编辑

配置为补丁编辑的模型可以请求 apply_patch,其他模型继续使用精确文本编辑。新增、更新、移动和删除都限制在项目与本单可写范围内;删除文件、移除移动源和访问凭据路径仍需原有审批。上下文缺失或不唯一时,先重新读取,不猜测匹配。

先检查并暂存修改,再逐个原子替换文件。多文件补丁不是一次文件系统事务:提交过程中磁盘报错,可能只改完一部分。继续前先检查文件,说明部分完成的情况。预览不替代安装设置,不放宽来源或沙箱限制,也不自动选择新服务商。

An AI coding tool is the program on the Agent J host that actually thinks and does the work: Claude Code, Codex or OpenCode. Agent J is the line from your phone to it. Switching changes who answers you; the work folder, the phone, approvals and the safety rules stay the same.

How to start

  • In ≡ "All commands" left of the message box, the "Run now" group (under /customize) has the switch command (/switch-harness); one tap sends it to your main Agent. To name the target yourself, type the command in the box, add "switch to Codex" after it and send it.
  • Or just say "switch to OpenCode" or "back to Claude Code".

Nothing switches when you tap it. The command goes to your current main Agent, which follows a fixed procedure.

What your main Agent does

  1. Explains. If you sent the command with no words, it first says in two or three sentences which kind of tool it means and how to switch.
  2. Scans which AI coding tools the Agent J host has, and their versions.
  3. Tries each sign-in. For every installed tool it makes one tiny headless call with your own login and the model the tool would run with (no tool permissions, at most 60 seconds each) to see whether it answers now. This runs in a separate small job on the Agent J host, in the environment of Agent J's background service — exactly what the tool gets after a switch. Read-only: no config is changed, no key is read out or shown.
  4. Tells you, for example, "you can switch to: Codex, OpenCode" — or "only the current one works on the Agent J host; to switch, install another one first". For an installed one that does not work it says why: not signed in, an expired token, or no network / proxy.
  5. Helps install, guides the sign-in. With your yes it installs a missing one following Set up AI command-line tools. Signing in is yours: it tells you step by step what to run in your own terminal, what you will see and what to click — claude auth login for Claude Code, codex login for Codex, opencode auth login for OpenCode. A model API key never goes through the chat; it uses the masked key card on your phone. Then it tries again.
  6. Switches only to a target that just passed, and only when you clearly ask.

What happens during the switch

Your main Agent first says: Agent J restarts, the remote disconnects for a few seconds and reconnects by itself. Then it runs agentj agent switch <target>:

  • The command tries the target's sign-in once more — the last gate. If it fails, nothing changes and your Agent tells you why.
  • If it passes, a separate small job on the Agent J host takes over: it waits for the current reply to finish, switches, restarts Agent J and checks that the new tool is up and answers.
  • For Codex the gate also opens its long-running session once, the way it will run after the switch: the same work folder, your own Codex settings with their MCP servers and plugins (nothing is kept in your Codex history, no message is sent). If that session cannot open, nothing changes and you get the reason. If it opens slowly, the switch waits for it accordingly.
  • After the restart, a tool that is still visibly starting is waited for, up to 8 minutes. If it still says nothing, agentj agent switch --result and the switch-back message say where it stopped — still starting, waiting at a prompt in a terminal, waiting for an approval card, failed to start, or started but silent — plus the error type if it printed one, and what to do next.
  • When all is well, the new tool greets you first: which one it is and which model it runs.
  • If any step fails, Agent J switches back to the previous tool by itself, restores the earlier settings exactly, and the previous one tells you it did not work and why.

So even away from the Agent J host, without a terminal, you cannot be cut off by switching to a tool that does not work.

A handoff before every switch

Each tool keeps its own conversation, so the new one cannot see what you just talked about. Before switching, Agent J has the tool you use now write a handoff file in the same format as the compaction handoff; after the switch Agent J puts the handoff straight into the new tool's first message, so the new tool reads it there, then carries on without looking for the file.

  • The handoff is written after the checks pass and right before the switch. Only the essentials: your key points in your own words, progress, decisions already made, key paths and commands, pitfalls, the next step and questions waiting for you; at most 150 lines, never a key, token or password.
  • Fixed places: <work folder>/.agentj/handover/switch.md for an independent session, ~/.local/state/agentj/handoff/switch.md for a shared one. Switching back works the same way: the one leaving writes, the one taking over reads, and the same file is merged and updated.
  • The new tool reads the handoff before it greets you and says what it picked up; then Agent J has it carry on with the handoff's next step. If nothing was in progress, it waits for you.
  • Before handing it over, Agent J hides keys and other credentials in it; a very long handoff is cut, with a note saying which file has the rest. If the new tool reads the handoff file itself, you are not asked to approve.
  • If Agent J cannot read the handoff file, it tells the new tool why; the new tool tells you in one sentence, goes on from a local excerpt of the conversation and asks about anything missing. When one of the new tool's steps is refused, the reason and the next step are given too.
  • Agent J waits at most 3 minutes. On timeout, it tells you that 180 seconds have passed and the switch will continue with a local redacted excerpt. The excerpt includes recent requests and replies, with omissions marked; it may miss progress or decisions, so the new tool checks anything uncertain with you.

Switching there means being able to come back

  • Before switching, the tool you use now is tried the same way as the target. If it fails in the background service (for example because its login lives only in your terminal's environment), it does not block switching to a target that passed its check. You do not have to repair the original tool first. In an emergency use agentj agent switch <target> --force to skip the pre-switch probes; startup checks and rollback still apply.
  • Already switched and the check will not let you go back? Run agentj agent switch --undo on the Agent J host (or ask the main Agent to): with no pre-check it restores the tool from before the last switch exactly as it was; if that one does not come up, Agent J returns to the current one by itself.
  • When the background service finds no Claude Code login, it says what to do: run claude in a terminal and /login once (on a Mac the login goes to the Keychain, which the service can use too), or in a terminal where claude works run agentj service import-key CLAUDE_CODE_OAUTH_TOKEN, then agentj service restart.
  • When a tool has updated itself (say Codex from 0.156 to 0.162), an older path the background service had saved is dropped and the one your terminal finds is used; the scan says so.

Switching never needs the admin password

Whichever tool is working now, including OpenCode, Kimi Code and Qwen Code running inside the isolation, switching, scanning and --undo go through Agent J's own background service: no admin password, and no need to go back to the Agent J host and open a terminal.

  • If your Agent says "the service is not loaded" and asks for the admin password, or asks you to run agentj service start in a terminal, you don't need to. Inside the isolation it can't see the system's service manager, so it may think the service has stopped.
  • To check whether the service is running, run agentj service status. It asks the running service itself and says it is running whenever the service answers.
  • Agent J never asks for the admin password to manage its own background service either; such a request is refused.

OpenCode with no key

  • OpenCode comes with a few free models of its own (opencode/…, mostly ending in -free): no account, no key, no payment. With one of them OpenCode counts as usable without a key; switch with agentj agent switch opencode --model opencode/<free-model> — opencode models opencode lists the current ones (they change almost daily).
  • A free model is checked on the same path as a normal chat (OpenCode refuses requests that do not look like its own client); in the first minute or two after installing it is sometimes refused, and the check waits and retries by itself — at most a minute or so longer.
  • Some free models' providers log the conversation or train on it: when you pick one, the switch result and the phone's "Models & API keys" page add one sentence saying so. Keep personal or confidential things out of it, and use a model of your own for everyday use.
  • After writing the setting, Agent J checks that the selected AI coding tool is running and can respond. A different model name does not cause a switch-back. When switching to Claude Code without --model, it uses its own default or current model; an explicit --model is saved as requested.

What the phone shows while you wait

A scan can take about three minutes, and a switch restarts Agent J once. The reply card is never blank meanwhile: its text starts with a small dancing robot followed by Agent J's own progress line: which tool it is probing (and which of how many), which one it is switching to, or that it is back on the previous one, which will tell you why in a moment. As long as the robot dances, your message is not lost and nothing has stopped.

Good to know

  • Each tool keeps its own conversation. After a switch you are in that one's conversation; switching back continues the earlier one.
  • Isolation, shared or independent session, the work folder and the approval rules are unchanged by a switch.
  • In shared mode the new tool needs a session to attach to: Claude Code must be open on the Agent J host; Codex and OpenCode start a new one in the same folder when none is open.
  • A Codex conversation that is read-only cannot run the switch command; your Agent tells you Codex's refusal — that conversation needs Full access.
  • To see the last switch's outcome, run agentj agent switch --result on the Agent J host, or ask your main Agent.
agentj agent switch --scan
agentj agent switch codex --dry-run

The first shows which ones you can switch to now (each tried in the background service's environment); the second only checks whether Codex would pass, without switching.

Kimi Code

Kimi Code CLI (kimi, by Moonshot AI, MIT licence, 2.2.0 or newer) is the fourth AI coding tool Agent J can switch to — a common choice where Claude Code and Codex are not offered (mainland China, Hong Kong, Macau). Agent J talks to it over the Agent Client Protocol (kimi acp): one long-running conversation per Agent, replies in whole pieces, every approval on your phone.

  • Switch with agentj agent switch kimi; a membership bought on kimi.ai adds --region global. The same check-first gate, handoff and automatic switch-back apply. Kimi Code runs in an independent session only (no shared terminal session yet).
  • Sign in from the phone: Settings → Emergency repair → ③ AI account signed out → AI login rescue → Kimi Code → Sign in again (device code). the Agent J host runs the official kimi login, the phone shows a link and a one-time code, and you confirm on any device signed in to Kimi. At the Agent J host it is kimi login --region mainland-cn (kimi.com, the default) or kimi login --region global (kimi.ai). A key from a kimi.com membership works on both api.kimi.com and api.kimi.ai.
  • A Kimi Code console API key works too: the Agent sends a phone key card for KIMI_API_KEY — never paste it into the chat. Agent J hands it to Kimi in memory, and only when Kimi has no login of its own.
  • Approvals stay with you. Kimi's own hooks let a call through when they fail or time out, so Agent J does not rely on them: every Kimi conversation is kept in Kimi's manual mode, each permission request becomes a phone card, and a yes covers this one call only, never later ones. If Kimi switches itself to Auto or YOLO, Agent J switches it straight back. Kimi has no sandbox of its own: it runs inside Agent J's isolation, with its dangerous-command guard forced on. Allow rules you wrote yourself in ~/.kimi-code/config.toml stay yours; agentj doctor says how many there are.
  • Skills: Kimi reads ~/.agents/skills, where Agent J already links its bundled skills, so they work unchanged. A plaza package installs its Codex version for Kimi.
  • Prefer OpenCode with a Kimi model? That route stays; agentj agent route offers both.

Qwen Code

Qwen Code (qwen, by Alibaba, Apache-2.0, 0.25 or newer) is the fifth AI coding tool Agent J can switch to, a natural pair with an Alibaba Cloud Bailian Token Plan in mainland China (setup). Agent J talks to it over the same Agent Client Protocol as Kimi Code (qwen --acp).

  • Switch with agentj agent switch qwen. The same check-first gate, handoff and automatic switch-back apply. Independent sessions only.
  • Its free sign-in ended on 2026-04-15, so a key is its login: the Agent sends a phone key card for BAILIAN_TOKEN_PLAN_API_KEY. Agent J hands the key to Qwen Code in memory only; your own ~/.qwen/settings.json, if you set one up, wins.
  • Approvals stay with you. Qwen Code starts in a mode where a classifier approves some actions by itself; Agent J switches every conversation back to asking, and each request becomes a phone card for that one action.
  • /model on the phone lists the plan's models; those marked as reading images can look at screenshots. Changing the model restarts Qwen Code and continues the same conversation.
  • Your own scheduled tasks may use the Token Plan key too (the provider may rate-limit long, continuous background work; you can switch those to a pay-as-you-go key); a support bot serves other people, so Agent J never gives it that key.

DeepSeek dsh

DeepSeek's dsh (DeepSeek Harness, MIT, 0.2.0-rc.2 or newer, a developer preview) is the sixth AI coding tool Agent J can switch to. It is the engine inside Olares' own agent Lares, and it works with any OpenAI-compatible model server (setup). Agent J talks to it over the same Agent Client Protocol as Kimi Code (dsh --profile acp).

  • Switch with agentj agent switch dsh. The same check-first gate, handoff and automatic switch-back apply. Independent sessions only.
  • No model yet? The check says so: agentj agent dsh --base-url https://<server>/v1 --model <model id> sets one up. A key goes only through the phone key card (DSH_ROUTER_API_KEY, or DEEPSEEK_API_KEY for DeepSeek's own API). Your own dsh setup, if you have one, is used as it is.
  • Approvals stay with you. Agent J starts dsh read-only, asking every time: each file change or command that is not read-only becomes a phone card for that one action, never "always".
  • /model on the phone lists the route's model and DeepSeek's models; /context works. dsh compacts its own conversation when it gets near the limit (there is no /compact for it). A model server of your own has no plan quota.
  • It reads text only for now. Scheduled tasks may use it, but never get a key from the key card.

Same AI tool, another account

Switching accounts is not switching tools: Claude Code stays Claude Code, only the sign-in changes. Settings → "Agent tools" → "Backup AI accounts" manages the backup accounts Claude Code and Codex switch to automatically when quota runs out. The primary account is read-only and shows the same configuration as Models & API keys, with a link there to change it. Add or manage only backups here: "Add backup account" uses the official sign-in and saves the new account on its own, never over an existing one; "Make current" switches with one tap, and the main Agent uses the new account from its next message, in the same conversation; background tasks already running finish on the old account. You can also say “switch to my Claude backup account” in the chat, or run agentj account use claude Backup at the Agent J host. Never paste a token into the chat. Steps: User guide.

When adding a Codex backup, check that the official authorization page is signed in to the other ChatGPT account. If Agent J says it is already added, select the account you meant to add and try again; keep the main account. Adding an account and AI login rescue show their own results. After approving an addition, check its success or failure on the account page you started from.

If the current Codex sign-in differs from the saved account marked as current, use AI login rescue to sign in to a saved account, then switch again. Agent J preserves an unmatched current sign-in rather than overwriting it.

Multiple Claude versions

For mise/asdf Claude installs, ambiguous_install means several versions were found. Agent J defaults to the highest executable numeric version. An explicit AGENTJ_CLAUDE_BIN or mise/asdf choice takes priority. If the selected version is missing, select an installed version or set AGENTJ_CLAUDE_BIN; this is not “not installed”.

Queued phone messages offer Stop current task, using the usual Stop action. After three minutes queued and three minutes with no new output from the earlier task, the page offers a reminder. New output resets the silence timer; a reload starts a fresh observation window.

Confirm the final switch result

“Scheduled” and “started” mean the switch is still in progress. The new AI must receive the phone greeting and reply before the switch counts as successful. Since 0.26.1, if it has answered but is still working or waiting for your approval, Agent J keeps it and says so in the final result; being busy after answering does not cause a switch-back. The phone receives the final outcome. In the terminal that requested it, run agentj agent switch --result --wait 900 to wait up to 15 minutes. Exit 0 means success (probe_ok is only a dry run), 3 means failed or rolled back, and 4 means still pending. A rollback names the previous AI and the reason; do not request another switch based on an intermediate state.

The outgoing AI gets up to three minutes to write its handoff. If it finishes without writing the file, the switch continues immediately. Agent J passes a larger local redacted excerpt of recent requests and replies to the new AI. The excerpt may be incomplete: verify uncertain progress, and keep the usual tool permissions.

Your main Agent can read the host's switch result from inside isolation. A queued request or a pending result means the switch is not yet confirmed; it does not mean success or failure. The outgoing Agent ends its current reply so the switch can proceed, then checks agentj agent switch --result on the next turn. You do not need to send the switch again from the web menu. If the host result is unavailable, the outcome remains unconfirmed.

Built-in AI preview: availability and provider privacy

The built-in Agent J AI is an opt-in preview, hidden unless the host service already has AGENTJ_CORE=1. Reading this guide does not enable it or switch your current AI. Ask the Agent helping with setup to inspect the host's current presets; a listed preset or configured key is not proof of account access or a successful provider call. Enter keys through the secret card, not chat.

The preview supports configured Chat, Anthropic Messages and Responses connections. Responses requests use store:false and keep continuation locally rather than relying on a provider conversation ID; this request option does not guarantee a provider's retention policy. Chat and Anthropic streaming depend on the preset. A truncated or incomplete tool call is refused before execution. Existing approval and isolation rules still apply, and changing connection type requires an explicit selection.

MCP servers in the preview

The MCP server list belongs to the owner. A proposed addition shows the command or address on a phone approval card. Local-command servers run inside the session's isolation with an allow-listed environment and no provider keys. Streamable HTTP uses HTTPS, except loopback HTTP; a configured key is read by variable name on the host and goes only in its Authorization header, never a URL or tool environment. Redirects are refused.

Each MCP tool call asks for approval unless the owner explicitly allowed that tool when adding the server. Research orders may use only allowed tools; a server's own “read only” annotation does not grant permission. A refusal applies across the same order, including other sessions. The small-model tier receives no MCP tools. These controls do not grant native tools or other sessions wider authority.

Compaction and handover

As context fills, the kernel trims older tool outputs first, then summarizes the older conversation while keeping recent messages verbatim. The summary names touched files and is saved in the local session and compaction handover file. Resume uses that saved summary. A context-overflow response permits one compaction and one retry, not repeated unbounded retries. Summarizing may still use model tokens.

In this preview, /compact can include a focus, /context shows context parts, /cost and /usage show per-model usage since /clear, /model lists keyed connections, and /status shows the current model, session and isolation. Figures depend on reported usage and your provider's bill; a model choice does not verify provider connectivity.

Patch editing in the preview

Models configured for patch editing can request apply_patch; other models keep exact-text editing. Add, update, move and delete operations remain inside the project and the order's write scope. Deleting files, removing a move source and touching credential paths retain their approval requirements. Missing or ambiguous context asks for a fresh read instead of guessing.

Edits are checked and staged before individual files are atomically replaced. A multi-file patch is not one filesystem transaction: a disk error during commit can leave partial changes. Inspect the files and report partial completion before continuing. This preview does not replace installation setup, loosen source or sandbox restrictions, or automatically choose a new provider.

这一页的 Markdown 原文This page as Markdown: zh.md · en.md