Skip to content

/agent:助手的电脑忙时,新会话按负载开到空闲的电脑上 - #33

Merged
NginxL merged 2 commits into
mainfrom
feat/agent-load-placement
Nov 26, 2026
Merged

NginxL merged 2 commits into
mainfrom
feat/agent-load-placement

Conversation

@NginxL

@NginxL NginxL commented Nov 26, 2026

Copy link
Copy Markdown
Owner

做了什么

新的 /agent 会话以前开在哪台电脑上,由「/agent 在哪台电脑上跑」决定:设置了就开在那台,没设置就开在助手所在的电脑上。现在没设置时会看负载:

  • 平常不变:新会话照旧开在助手所在的电脑上,请求里不带电脑,和以前完全一样。
  • 它忙的时候才分出去:「忙」指 1 分钟负载超过 CPU 核数的 75%,或者可用内存不到 2 GiB。这时新会话开到别的电脑上,选法是在线、装了 Claude Code、Persona 没把它标成工作电脑/待批准/节点不兼容、两项读数都有且都不忙的电脑里负载最低的那台。
  • 同一个任务不换电脑:
    • 话题里接着问的,照旧发给原来那个会话,在原来那台电脑上。
    • 同一话题里再开新会话,也回到这个话题之前的电脑。另一个请求还在启动时,就跟它去同一台;那台电脑被列为离线时才重新选。
    • 一次启动只选一次电脑:选定的电脑、提示词、启动器跟着操作号一起保存,重试和重启后续跑都发同样的内容。
  • 拿不准就照旧:hub 太旧或者读不到电脑列表、助手的电脑没有最近的读数、别的电脑都忙、读数超时(总共约 8 秒),都按以前的方式开。在别的电脑上没开起来,就按原来的失败流程走,不会换电脑再开一次:回应可能丢了,不能让同一个请求跑两遍。
  • 开在别的电脑上的会话会被告知限制:
    • Agent 存的图片在那台电脑上,扩展这边读不到,所以说明里不让带图片回复。万一还是带了,文字照发、图片不发,并告诉它原因。
    • 消息里的图片,只有 hub 能把图片直接给模型(tool_images)时才保留看图提示;文件不给下载提示。
  • 新开关「忙时分到空闲的电脑」默认打开,飞书和微信都有。设置了电脑或启动器就不分流。
  • 新增 hub 权限 machines.read,用来读电脑列表和负载。升级时 Persona 会显示「需要批准」。

怎么验证的

  • bash scripts/test.sh 三组测试都通过:727、240(跳过 2)、159。
  • 新测试:tests/test_agent.py 的 LoadPlacementTest(22 个)和 PlacementReadingTest,tests/test_agent_image.py 的 RemoteTest,tests/test_feishu_media.py 新增的两个。改动前的代码上跑会失败。
  • 变异检查都能抓到:去掉话题粘性、每次重试重新选电脑、去掉启动中请求的预约、去掉远端图片的拦截、远端仍给下载提示。
  • codex(gpt-6.2-astra,ultra,只读)审了 15 轮,每轮的真实问题都已修掉。最大的一处改动:去掉了"在别的电脑上失败就回助手的电脑重开",因为回应丢失时会让同一个请求开两次。下面列的是有意接受的限制。

没做什么 / 已知限制

  • Persona 不告诉扩展「Lark /agent」用哪个启动器、每台电脑上有哪些启动器。内置的 claude 每台都有;换成只有 Mac 上才有的启动器时,请关掉这个开关或者指定电脑。
  • 列表里没有标出来的工作电脑,这里识别不了。
  • 读图片默认在扩展所在的电脑上读,并且假定它就是助手所在的电脑。这是以前就有的前提。
  • 话题粘性只在运行记录保留期内有效(3 天、200 条)。
  • 8 秒预算是大约值:hub 很慢时,一次放置最多约 12 秒。
  • 没有在真实环境里验证分流:现在 Mac 不忙,devbox 上原生 Claude Code 的模型也还在配。上线后要观察 /agent: a new conversation on … 这行日志。

🤖 Generated with Claude Code

NginxL and others added 2 commits November 26, 2026 19:59
…ssistant's is busy

With agent_machine unset and the new agent_balance on (the default), a new
/agent conversation still starts on the assistant's computer as before, unless
that computer is busy: its 1-minute load is over 0.75 per core, or less than
2 GiB of memory is free. Then it starts on the least loaded computer that is
online, has Claude Code, is not marked work/pending/incompatible, and reads
idle on both counts. A thread keeps to one computer: follow-ups go to their
conversation, a new conversation in a thread goes back to the thread's
computer, and a request still starting holds it for the thread. The choice is
kept with the start operation, so every try and a resume send the same body.
Anything unclear starts as before, and a start that fails elsewhere is never
started again elsewhere. A conversation on another computer is told it cannot
attach pictures; a picture it attaches anyway is skipped while the text goes;
download hints are given only for pictures on a hub that takes them.
New hub permission: machines.read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ation goes to an idle computer while the assistant's is busy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NginxL
NginxL merged commit 9d3932c into main Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant