Skip to content

fix(subagents): say when a background report comes from a resumed run - #991

Merged
agegr merged 1 commit into
agegr:mainfrom
Light1002:fix/subagent-resumed-notification
Sep 30, 2026
Merged

agegr merged 1 commit into
agegr:mainfrom
Light1002:fix/subagent-resumed-notification

Conversation

@Light1002

Copy link
Copy Markdown

Refs #985.

Problem

resume reruns a child under the same session id, and its completion notification uses the same template as the first run's: Subagent <id> completed. followed by the result. A parent that already handled the first report cannot tell the resumed run's report from a repeat of it, and may redo the work. This is the "framed identically both times" part of #985.

Change

  • lib/subagent-runtime.ts: a run started by resume carries an in-memory resumed: true flag. It is not persisted.
  • lib/subagent-extension.ts: subagentNotificationText() adds one line for such runs, after the 在 subagent 的结果前拼接一句说明,防止污染 compaction #875 prefix: This report is from a resumed run of subagent <id>; it supersedes any earlier report from the same subagent.

First-run notifications, Agent / get_subagent_result tool results, and the notification details are unchanged. There is no UI change.

This does not claim to close #985. That issue also asks whether a single run can be emitted twice, and this PR does not change delivery.

Tests

tsc and lint are clean. npm test: the only failures are the existing Windows-host ones, and they fail on main too.

resume reruns a child under the same session ID, and the completion
notification was built from the same template as the first run's:
"Subagent <id> completed." followed by the result. A parent that already
handled the first report had no way to tell the resumed run's report
apart from a repeat of it, and could redo the work (agegr#985).

Mark runs started by resume with an in-memory resumed flag and add one
line to their notification saying it comes from a resumed run and
supersedes any earlier report from that subagent. First runs, tool
results, and the notification details are unchanged.

Refs agegr#985
@agegr

agegr commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Reviewed. The ambiguity in #985 is real: resume reruns the child under the same session id, so a resumed run's notification reads exactly like the first run's, and the parent can't tell a new result from one it already acted on.

The fix is minimal. resumed is an in-memory flag set only by resume, and it adds one line after the #875 prefix. First-run notifications, the Agent / get_subagent_result tool results, and the notification details are unchanged. Agreed that this addresses the framing half of #985, not delivery.

The new tests fail against main and pass here. I also merged #989, #990 and #991 together onto current main: no conflicts, and tsc --noEmit, eslint, and the full unit suite pass (same pre-existing macOS-only worktree.test.mjs failure as main). LGTM 👍


Generated by Claude Code

@agegr
agegr merged commit 2a71c57 into agegr:main Sep 30, 2026
2 checks passed
Kano-u pushed a commit to Kano-u/pi-web that referenced this pull request Oct 2, 2026
…gr#976 agegr#974 agegr#989 agegr#990 agegr#991)

这 8 个提交与我们的分叉没有文本冲突,直接并入:
- agegr#1011 回合答案出现后折叠过程详情
- agegr#1012 移动端打开模型选择器不弹键盘
- agegr#972/agegr#976 行内链接在 CJK 标点处停止、行内公式与货币格式
- agegr#974 首条消息前即报告 system prompt
- agegr#989/agegr#990/agegr#991 子代理:收集标记按 run 计、重启后的中断报告、续跑背景报告标注
@Light1002
Light1002 deleted the fix/subagent-resumed-notification branch October 17, 2026 12:38
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 6, 2026
…agegr#991)

resume reruns a child under the same session ID, and the completion
notification was built from the same template as the first run's:
"Subagent <id> completed." followed by the result. A parent that already
handled the first report had no way to tell the resumed run's report
apart from a repeat of it, and could redo the work (agegr#985).

Mark runs started by resume with an in-memory resumed flag and add one
line to their notification saying it comes from a resumed run and
supersedes any earlier report from that subagent. First runs, tool
results, and the notification details are unchanged.

Refs agegr#985

Co-authored-by: CLAY777 <[email protected]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 8, 2026
…agegr#991)

resume reruns a child under the same session ID, and the completion
notification was built from the same template as the first run's:
"Subagent <id> completed." followed by the result. A parent that already
handled the first report had no way to tell the resumed run's report
apart from a repeat of it, and could redo the work (agegr#985).

Mark runs started by resume with an in-memory resumed flag and add one
line to their notification saying it comes from a resumed run and
supersedes any earlier report from that subagent. First runs, tool
results, and the notification details are unchanged.

Refs agegr#985

Co-authored-by: CLAY777 <[email protected]>
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.

Background subagent completion is injected into the parent session twice for the same subagent, framed identically both times

2 participants