Repository navigation
fix(claude): 在子代理视图里提交的提示也能被确认送达 - #3182
Merged
Merged
Conversation
Task/Agent 子代理运行期间投递的输入写入 <sid>/subagents/*.jsonl,主会话 jsonl 在子代理返回前没有 user 事件,送达确认会误判失败。指纹查找新增 includeSubagentTranscripts(仅用于布尔判定,不会把子代理文件钉为监听目标)。 Co-Authored-By: Claude Code <[email protected]>
Co-authored-by: TRAE CLI <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
TUI 正在查看子代理时提交的提示只进该代理的 jsonl:代理仍在运行时在其下一步写成 attachment(queued_command),已停止时以 isMeta + origin.kind=human 的 user 记录恢复。 - 新增独立开关 includeQueuedCommandAttachments,只有 recheck 打开;会话切换扫描、 confirmSubmit 目录兜底和末次 fan-out 不变 - 子代理 user 记录收紧为 isMeta 且 origin.kind=human,排除父代理消息、任务通知和系统提醒 - 子代理候选不再匹配 queue-operation Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 8, 2026 07:49
Co-Authored-By: Claude Fable 5 <[email protected]>
deepcoldy
pushed a commit
to hu5h/botmux
that referenced
this pull request
Nov 8, 2026
git merge-tree 三方合并干净、无内容冲突,merge 后 tree 与预测树 1b1924d 字节一致,未改写作者任何提交。 同文件交集均为两边独立追加、自动合并: - test/write-input.test.ts:deepcoldy#3182 在 claude-code writeInput 块(约 1477 行起) 新增两个子代理送达用例,本 PR 的 Pi paste submission 块在 292 行起,互不相邻。 - src/adapters/cli/types.ts、test/cli-adapters.test.ts:整段 delta 有交集, 本次三方合并无冲突,门控字段与 Kimi 字段并列、各自测试块均保留。 - package.json 仅随 deepcoldy#3159 把 packageManager 升到 [email protected],bun.lock 未变。 Co-Authored-By: Claude Fable 5 <[email protected]>
|
🚀 Released in v3.59.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
接管 #1974,保留 wzono 署名;合码时 squash-pr 加 --co-author "wzono [email protected]";评审在原 #1974 评审群继续。
改了什么
在 Claude Code 的 TUI 里切到某个 Task/Agent 子代理的视图后,输入框提交的提示会交给该子代理,只写进
<projectDir>/<sid>/subagents/agent-*.jsonl,bridge 监听的会话 jsonl 里没有任何记录。送达确认只扫顶层文件,于是误报submit_unconfirmed,尽管提示已经送达。本 PR 保留 #1974 的 4 个原始提交(子代理目录扫描
includeSubagentTranscripts、共用的jsonlTailMatchFingerprint、时间下限修正、开场任务指令排除),合入最新 master,并修掉评审提出的 1 个 P2 和 2 个 P3:attachment(queued_command),文本在attachment.prompt。原扫描只认role:user,对这种情形不生效。新增独立开关includeQueuedCommandAttachments,匹配queued_command(排除commandMode: 'task-notification');子代理候选另外要求attachment.origin.kind === 'human'。谓词不依赖isMeta。recheck()布尔判定打开它(连同includeSubagentTranscripts)。worker 会话切换扫描、confirmSubmit目录兜底、末次跨项目 fan-out 这三个会把匹配路径钉为新监听目标的调用点都不传,参数与 master 相同。isMeta === true && origin.kind === 'human',这是 Claude 把人类消息转给已停止的子代理时写下的形状。选结构字段而不是包装文案前缀,前缀是展示文本,跨版本更容易变。实证:哪个入口、写下什么
评审时的 PTY 探针(2.1.312 / 2.1.317)是在主输入框里输入,人类消息照常进主会话 jsonl。投递到子代理只发生在 TUI 正在查看子代理时(任务面板按 ↓ 选中 agent、回车进入其视图),此时输入框把提交交给该代理。
在 Claude Code 2.1.319 上用 tmux PTY 加本地假 API 复现(临时 HOME,与在线环境隔离)。进入子代理视图后输入消息,主会话 jsonl 0 命中,子代理 jsonl 里分别出现:
代理仍在运行(代理下一步时写入,本次约晚 22 秒):
{"type":"attachment","isSidechain":true,"agentId":"<id>","timestamp":"…","attachment":{"type":"queued_command","prompt":"<原文>","source_uuid":"<uuid>","origin":{"kind":"human"},"isMeta":true}}代理已停止(立即写入,并恢复该代理):
{"type":"user","isSidechain":true,"isMeta":true,"origin":{"kind":"human"},"timestamp":"…","message":{"role":"user","content":"The user sent a new message while you were working:\n<原文>\n\n…"}}本机 110 个子代理转录的普查:isMeta user 记录 38 条(无 origin 29、coordinator 6、task-notification 3),没有一条是
origin.kind === 'human';queued_command附件 58 条(task-notification 51、coordinator 7);queue-operation0 条。收紧后这些既有记录都不会被当成送达证据。评审意见处理
影响面
services/claude-transcript.ts、adapters/cli/claude-code.ts。不改core/、config.ts、bot-registry.ts、im/lark/,不动worker.ts。confirmSubmit目录兜底、末次 fan-out 参数不变;子代理 jsonl 和 queued_command 记录不会被钉成监听目标,也不会当作会话切换证据。subagents/,只读 60 秒内修改过的文件,每个文件最多读尾部 1MB,与顶层扫描一致。已知限制
代理仍在运行时,记录在它下一步才写入。如果这一步晚于 worker 的延迟复查窗口(约 2 × 20 秒,忙碌时会延长),仍会发出提醒。
测试验证
新增或改写的用例:
变异复验(每次只改一处,跑上面两个测试文件,全部变红):
includeQueuedCommandAttachments判断(分支无条件生效)includeQueuedCommandAttachmentsconfirmSubmit目录兜底传新开关includeSubagentTranscriptsworker.ts未改,会话切换扫描的参数不变;它的参数形状在 transcript 层用例里钉住,没有另加 worker 层用例。Follow-up
origin,子代理转发记录不会被识别,结果是回到原来的误报,不会误确认;如需兼容,可加包装文案前缀兜底。🤖 Generated with Claude Code